Re: [R] [R-sig-Geo] Using RGDAL to copy header information...

2008-11-06 Thread Roger Bivand

On Wed, 5 Nov 2008, Jonathan Greenberg wrote:


R-geographers...

I'm trying to solve a problem to implement a line-by-line tiled processing 
using RGDAL (read 1 line of an image, process the one line, write one line of 
the image to a binary file).  Everything except for the final step I'm able 
to do using a combination of RGDAL and r-base commands.  Below is the basic 
structure, the input file elev can be any image file GDAL supports -- the 
code below just copies the image one line at a time:


###

library(rgdal)
infile='elev'
outfile_base='testout'
outfile_ext='.bil'
outfile=paste(outfile_base,outfile_ext,sep='')
outcon - file(outfile, wb)

infile_info=GDALinfo(infile)
nl=infile_info[[1]]
ns=infile_info[[2]]

for (row in 1:nl) {
   templine - readGDAL(infile,region.dim=c(1,ns),offset=c(row-1,0))
   writeBin(templine[[1]], outcon,size=4)
}
close(outcon)
#  Below doesn't work
#  writeGDAL(templine,outfile_base,drivername='EHdr',type=Float32)

###

The issue is this: I need to be able to effectively copy the 
geographic/header information from the input file (the last line almost 
works, but as you can see it sets the line #s to 1, not ns), and parse it 
over to the output file (which is some form of a flat binary file -- in this 
case, an Arc Binary Raster, but an ENVI binary output would also be good) -- 
ideally I'd like to be able to modify this header, particularly the number 
type (e.g. if the input file is an integer, and I'm writing out a floating 
point binary, I need that reflected in the output header).  I can do this by 
*manually* creating the output header via a series of ascii-writes, but I was 
wondering if there is a more effective way of doing this using RGDAL that 
might apply generically to the header of any binary image file I might write? 
Thanks!


It is the internals of writeGDAL() and create2GDAL() without the bands:

data(meuse.grid)
gridded(meuse.grid) - ~x+y

d.drv - new(GDALDriver, EHdr)

gp - gridparameters(meuse.grid)
cellsize - gp$cellsize
offset - gp$cellcentre.offset
dims - gp$cells.dim

nbands - 1
tds.out - new(GDALTransientDataset, driver = d.drv, rows = dims[2],
  cols = dims[1], bands = nbands, type = Float32)

gt - c(offset[1] - 0.5 * cellsize[1], cellsize[1], 0.0,
  offset[2] + (dims[2] -0.5) * cellsize[2], 0.0, -cellsize[2])
.Call(RGDAL_SetGeoTransform, tds.out, gt, PACKAGE = rgdal)

list.files(tempdir())

fn - tempfile()

saveDataset(tds.out, fn)

list.files(tempdir())

GDAL.close(tds.out)

list.files(tempdir())

However, the driver does commit the data file too, so you'd need to run 
the above code to produce the header so as not to overwrite your output 
data. The key thing is to get the input grid parameters right, but you've 
got them anyway. If you want the projection information out too, look in 
create2GDAL for the .Call() you need. Note that passing unchecked 
variables through .Call may crash your session - going through 
GridTopology should make sure that they are stored correctly.


Hope this helps,

Roger




--j





--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

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


[R] Mean Computation for Data from External File

2008-11-06 Thread christabel jane

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


[R] Data manipulation question

2008-11-06 Thread Peter Jepsen
Dear R-listers,

I am a relatively inexperienced R-user currently migrating from Stata. I
am deeply frustrated by this data manipulation question: I know how I
could do it in Stata, but I cannot make it work in R.

I have a data frame of hospitalization data where each row represents an
admission. I need to know when patients were first discharged, but the
problem is that patients were sometimes transferred between hospital
departments. In my data a transfer looks like a new admission, except
that it has a 'start' date equal to the previous admission's 'stop'
date.

Here is an example:

id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
data - as.data.frame(cbind(id,start,stop))
data
#id start stop
# 1   a 06
# 2   a 6   12
# 3   a17   20
# 4   a20   30
# 5   b 01
# 6   b 1   10
# 7   c 03
# 8   c 5   10
# 9   c10   11
# 10  c11   30
# 11  c50   55
# 12  d 06

So, what I want to end up with is this:

id start stop
a  0 12   # This patient was transferred at time 6 and discharged at
time 12. The admission starting at time 17 is therefore irrelevant.
b  0 10   
c  0 3
d  0 6

I have tried tons of variations over lapply, sapply, split, for etc.,
all to no avail. 

Thank you in advance for any assistance.

Best regards,
Peter Jepsen, MD.

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


Re: [R] Reshape a matrix

2008-11-06 Thread ONKELINX, Thierry
Dear Dinesh,

Have a look at ?cast for the reshape package

 dataset - data.frame(Col1 = LETTERS[1:3], Col2 =
sort(rev(LETTERS)[1:3]), value = 1:3)
 dataset
  Col1 Col2 value
1AX 1
2BY 2
3CZ 3
 library(reshape)
 cast(Col1 ~ Col2, data = dataset, fill = 0)
  Col1 X Y Z
1A 1 0 0
2B 0 2 0
3C 0 0 3

HTH,

Thierry




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

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens dinesh kumar
Verzonden: donderdag 6 november 2008 1:53
Aan: r-help@r-project.org
Onderwerp: [R] Reshape a matrix

Dear R users,

I have a matrix like

A  X1
B  Y2
C  Z3

I want to reshape this matrix into this format

X  Y  Z
A  1
B 2
C 3



Thanks in advance for your help.


Dinesh

-- 
Dinesh Kumar Barupal
Junior Specialist
Metabolomics Fiehn Lab
UCD Genome Center
451 East Health Science Drive
GBSF Builidng
University of California
DAVIS
95616
http://fiehnlab.ucdavis.edu/staff/kumar

[[alternative HTML version deleted]]

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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


Re: [R] Memory limits for large data sets

2008-11-06 Thread Uwe Ligges



Alan Cohen wrote:

Hello,

I have several very large data sets (1-7 million observations, sometimes 
hundreds of variables) that I'm trying to work with in R, and memory seems to 
be a big issue.  I'm currently using a 2 GB Windows setup, but might have the 
option to run R on a server remotely.  Windows R seems basically limited to 2 
GB memory if I'm right; is there the possibility to go much beyond that with 
server-based R?  In other words, am I limited by R or by my hardware, and how 
much might R be able to handle if I get the hardware necessary?


Hi,

R under Windows can handle up to 2GB, and under certain conditions up to 
3GB. Note that no 64-bit version for Windows is available yet.


Anyway, under 64-bit Linux their are almost no limits other than 
hardware restrictions.


Best wishes,
Uwe



Also, any possibility of using web-based R for this kind of thing?





Cheers,
Alan Cohen

Alan Cohen
Post-doctoral Fellow
Centre for Global Health Research
70 Richmond St. East, Suite 202A
Toronto, ON M5C 1N8
Canada
(416) 854-3121 (cell)
(416) 864-6060 ext. 3156 (0ffice)

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


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


Re: [R] Methods dispatch and inheritance R.oo

2008-11-06 Thread Yuri Volchik

Thanks for reply Henrik, seems obvious now.
Can child class (B) access argument of the parent class, i.e. can i rewrite
definition of the class B as

setConstructorS3(ClassB, function() {
  extend(ClassA(), ClassB,
.size2 = A
  );
})

it didn't work for me, so guess i'm doing smth wrong and i couldn't find any
reference on inheritance in the help files.

-- 
View this message in context: 
http://www.nabble.com/Methods-dispatch-and-inheritance-R.oo-tp20339090p20358341.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] lars

2008-11-06 Thread Sohail
Hi,

Can anyone tell me how we can have the optimal value of lambda from lars
package? I want to extract the estimates against this optimal value of
lambda. I have tried the predict.lars and coef.lars but these provide
entire sequence of coefficients. I don't know how to have the optimal one.

Cheers,

-- 
Sohail Chand

[[alternative HTML version deleted]]

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


[R] splinefun and interpSpline

2008-11-06 Thread Rune Schjellerup Philosof
On the splinefun help page it refers to the interpSpline function from
the splines package.
What are the differences in the results, other than splinefun returns a
function and with interpSpline you use predict.
The only difference from the help pages seems to be the deriv option of
splinefun, are there other differences?

--
Rune

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


Re: [R] unlist dataframes

2008-11-06 Thread Naira

I have forgotten to say that the elements in the list are not necessarily
equal... meaning that x1 and x2 are from different dimensions so I can't use
data.frame(l) 

More suitable example: 

x1=data.frame(Name=LETTERS[1:2],Age=1:2)
x2=data.frame(Name=LETTERS[3:5],Age=3:5)
l=list(x1,x2)
l
 l
[[1]]
  Name Age
1A   1
2B   2

[[2]]
  Name Age
1C   3
2D   4
3E   5

Naira


Naira wrote:
 
 Dear all,
 
 I would like to know whether it is possible to unlist elements and keep
 the original format of the data.
 To make it more clear, let me give an exemple:
 I have a list l of dataframes that I created with apply but which looks
 like this:
 
 x1=data.frame(Name=LETTERS[1:2],Age=1:2)
 x2=data.frame(Name=LETTERS[3:4],Age=3:4)
 l=list(x1,x2)
 l
 [[1]]
   Name Age
 1A   1
 2B   2
 
 [[2]]
   Name Age
 1C   3
 2D   4
 
 I would like to unlist l to create a dataframe with 2 columns and 4 rows
 but keeping the format of Name (character) and Age (numeric).
 
 Now when I unlist l, I obtain :
 
 unlist(l)
 Name1 Name2  Age1  Age2 Name1 Name2  Age1  Age2
 1 2 1 2 1 2 3 4
 
 Is there a way to at least obtain something like
 A 1 B 2 C 3 D 4 as result from the unlist??
 
 Thanks a lot for your replies
 Naira
 
 
 

-- 
View this message in context: 
http://www.nabble.com/unlist---dataframes-tp20358993p20359097.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R Mixed Anova

2008-11-06 Thread Mark Difford

Hi Rodrigo,

Here are two options; for each type, the second version gives 2nd order
interactions

## aov
T.aovmod - aov(response ~ Season + Beach + Line + Error(Block/Strata))
T.aovmod - aov(response ~ (Season + Beach + Line)^2 + Error(Block/Strata))

## lme
library(nlme)
T.lmemod - lme(response ~ Season + Beach + Line, random = ~ 1 |
Block/Strata)
T.lmemod - lme(response ~ (Season + Beach + Line)^2, random = ~ 1 |
Block/Strata)
anova(T.lmemod)
?anova.lme

## Use package multcomp for doing post-hoc analysis.

Regards, Mark.


Rodrigo Aluizio wrote:
 
 Hi list, I was searching how to properly write a command line for a mixed
 ANOVA. Well honestly, there are so many material on the older post of the
 list that just confused me.
 
 I have five factors.
 
  
 
 Season (fixed)
 
 Beach (fixed)
 
 Line (fixed)
 
 Block (random)
 
 Strata (random) nested in Block
 
  
 
 And for each of the tree strata per block I got 3 replicates. 
 
  
 
 I saw lots of things about “different” linear models commands… lm, lme… On
 R
 help I found aov and anova…
 
  
 
 Any one knows what should be more adequate and how I write and appropriate
 command line? I need an ANOVA table, a p value, and be able to run post
 hoc
 tests.
 
  
 
 Thanks for your attention and patience.
 
  
 
 ___
 MSc.  mailto:[EMAIL PROTECTED] Rodrigo Aluizio
 Centro de Estudos do Mar/UFPR
 Laboratório de Micropaleontologia
 Avenida Beira Mar s/n - CEP 83255-000
 Pontal do Paraná - PR - BRASIL
 Fone: (0**41) 3455-1496 ramal 217
 Fax: (0**41) 3455-1105
 
 
 
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/R-Mixed-Anova-tp20358811p20359309.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] unlist dataframes

2008-11-06 Thread Naira

Thanks a lot :)

It is doing exactly what I want 

Naira


David Freedman wrote:
 
 try
 
 newdata=do.call(rbind,l)
 
 David Freedman, Atlanta
 
 
 
 
 Naira wrote:
 
 Dear all,
 
 I would like to know whether it is possible to unlist elements and keep
 the original format of the data.
 To make it more clear, let me give an exemple:
 I have a list l of dataframes that I created with apply but which looks
 like this:
 
 x1=data.frame(Name=LETTERS[1:2],Age=1:2)
 x2=data.frame(Name=LETTERS[3:4],Age=3:4)
 l=list(x1,x2)
 l
 [[1]]
   Name Age
 1A   1
 2B   2
 
 [[2]]
   Name Age
 1C   3
 2D   4
 
 I would like to unlist l to create a dataframe with 2 columns and 4 rows
 but keeping the format of Name (character) and Age (numeric).
 
 Now when I unlist l, I obtain :
 
 unlist(l)
 Name1 Name2  Age1  Age2 Name1 Name2  Age1  Age2
 1 2 1 2 1 2 3 4
 
 Is there a way to at least obtain something like
 A 1 B 2 C 3 D 4 as result from the unlist??
 
 Thanks a lot for your replies
 Naira
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/unlist---dataframes-tp20358993p20359182.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to make a multiple plot

2008-11-06 Thread baptiste auguie
perhaps you could also look into ggplot2 or lattice package to display  
several plots on the same page.
They take care of important but annoying details such as scaling,  
layout, limits, legend, ... Admittedly, there is a learning curve when  
you're used to base graphics, but in the long term it is a more  
efficient, robust and elegant approach.


Baptiste




On 6 Nov 2008, at 07:15, Dieter Menne wrote:


amy rheanita amee_86 at yahoo.com writes:

I'm a student. now, I'm studying Nelson-Siegel Extended, a term  
structure
model. I can analyze - estimate parameters and make aplot  -  
manually,

from data  bond in a day.
I can analyze bond data in a month, like make multiple plot for  
different

bont date and make a multiple
plot to compare parameters in different date.


Try

par(mfrow=c(2,2))

before creating the plot.

Dieter

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


Re: [R] unlist dataframes

2008-11-06 Thread Henrique Dallazuanna
Try this:

unlist(lapply(l, t))


On Thu, Nov 6, 2008 at 9:05 AM, Naira [EMAIL PROTECTED] wrote:


 I have forgotten to say that the elements in the list are not necessarily
 equal... meaning that x1 and x2 are from different dimensions so I can't
 use
 data.frame(l)

 More suitable example:

 x1=data.frame(Name=LETTERS[1:2],Age=1:2)
 x2=data.frame(Name=LETTERS[3:5],Age=3:5)
 l=list(x1,x2)
 l
  l
 [[1]]
  Name Age
 1A   1
 2B   2

 [[2]]
  Name Age
 1C   3
 2D   4
 3E   5

 Naira


 Naira wrote:
 
  Dear all,
 
  I would like to know whether it is possible to unlist elements and keep
  the original format of the data.
  To make it more clear, let me give an exemple:
  I have a list l of dataframes that I created with apply but which looks
  like this:
 
  x1=data.frame(Name=LETTERS[1:2],Age=1:2)
  x2=data.frame(Name=LETTERS[3:4],Age=3:4)
  l=list(x1,x2)
  l
  [[1]]
Name Age
  1A   1
  2B   2
 
  [[2]]
Name Age
  1C   3
  2D   4
 
  I would like to unlist l to create a dataframe with 2 columns and 4 rows
  but keeping the format of Name (character) and Age (numeric).
 
  Now when I unlist l, I obtain :
 
  unlist(l)
  Name1 Name2  Age1  Age2 Name1 Name2  Age1  Age2
  1 2 1 2 1 2 3 4
 
  Is there a way to at least obtain something like
  A 1 B 2 C 3 D 4 as result from the unlist??
 
  Thanks a lot for your replies
  Naira
 
 
 

 --
 View this message in context:
 http://www.nabble.com/unlist---dataframes-tp20358993p20359097.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] r script

2008-11-06 Thread Paul Hiemstra

Alfredo Alessandrini wrote:

A simple question :-)

I'm writing a R scritp(#!/usr/bin/Rscript)

How can execute a bash command inside the script, like the command for
change the directory (cd)?


Thanks in advance,

Alfredo

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

?system

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

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


[R] r script

2008-11-06 Thread Alfredo Alessandrini
A simple question :-)

I'm writing a R scritp(#!/usr/bin/Rscript)

How can execute a bash command inside the script, like the command for
change the directory (cd)?


Thanks in advance,

Alfredo

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


Re: [R] unlist dataframes

2008-11-06 Thread David Freedman

try

newdata=do.call(rbind,l)

David Freedman, Atlanta




Naira wrote:
 
 Dear all,
 
 I would like to know whether it is possible to unlist elements and keep
 the original format of the data.
 To make it more clear, let me give an exemple:
 I have a list l of dataframes that I created with apply but which looks
 like this:
 
 x1=data.frame(Name=LETTERS[1:2],Age=1:2)
 x2=data.frame(Name=LETTERS[3:4],Age=3:4)
 l=list(x1,x2)
 l
 [[1]]
   Name Age
 1A   1
 2B   2
 
 [[2]]
   Name Age
 1C   3
 2D   4
 
 I would like to unlist l to create a dataframe with 2 columns and 4 rows
 but keeping the format of Name (character) and Age (numeric).
 
 Now when I unlist l, I obtain :
 
 unlist(l)
 Name1 Name2  Age1  Age2 Name1 Name2  Age1  Age2
 1 2 1 2 1 2 3 4
 
 Is there a way to at least obtain something like
 A 1 B 2 C 3 D 4 as result from the unlist??
 
 Thanks a lot for your replies
 Naira
 
 
 


-
David Freedman
Atlanta
-- 
View this message in context: 
http://www.nabble.com/unlist---dataframes-tp20358993p20359063.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] gamlss.dist

2008-11-06 Thread Michael Kubovy
Hi,

I'm not sure how use curve(dexGAUS(…

None of the following four works:

rt- rexGAUS(100, mu=300, nu=100, sigma=35)
m1-gamlss(rt~1, family=exGAUS)
curve(dexGAUS(rt=x, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- 
GAUS  density mu=300 ,sigma=35,nu=100)
curve(dexGAUS(x=rt, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- 
GAUS  density mu=300 ,sigma=35,nu=100)
curve(dexGAUS(y=rt, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- 
GAUS  density mu=300 ,sigma=35,nu=100)
curve(dexGAUS(rt=y, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- 
GAUS  density mu=300 ,sigma=35,nu=100)
But this does:

y- rexGAUS(100, mu=300, nu=100, sigma=35)
m1-gamlss(y~1, family=exGAUS)
curve(dexGAUS(y=x, mu=300 ,sigma=35,nu=100), 100, 600, main = The ex- 
GAUS  density mu=300 ,sigma=35,nu=100)



_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/




[[alternative HTML version deleted]]

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


Re: [R] read Idrisi file

2008-11-06 Thread Roger Bivand
Abdou Ali a.ali at agrhymet.ne writes:

 
 Dear Sirs,
 
 Is there a R function to read an Idrisi image (*.rdc  *.rst)

Yes, please see the rgdal package, which can read this format. The Spatial 
Task View (CRAN) might have got you the information you need without posting. 
Depending on the size of your data, used the GDAL bindings directly, or use 
sp classes if the raster isn't huge.

Roger Bivand

 
 Thanks


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


[R] Inference and confidence interval for a restricted cubic spline function in a hurdle model

2008-11-06 Thread Erik Lampa
Dear list,

I'm currently analyzing some count data using a hurdle model. I've used 
the rcspline.eval function in the Hmisc-library to contruct the spline 
terms for the regression model, and what I want in the end is the ability 
to compute coefficients and confidence intervals for different changes in 
the smooth function as well as plotting the smooth function along with the 
confidence interval at the values of the x-variable.

An example using the zero-part of the hurdle model:

library(Hmisc)
library(pscl)

# Simulate some data

set.seed(1)
y-c(rep(0,50),rnbinom(50,0.9,0.2))
x-sin(y)+rnorm(100)

# Set up the spline terms
ssp-rcspline.eval(x,inclx=T)

# Fit the model and construct the smooth function
f-hurdle(y~ssp)
knots-attr(ssp,knots)
coef-f$coefficients$zero
w-rcspline.restate(knots,coef)
fun-eval(attr(w,function))

The coefficient for a change in x from -0.1 to 0.1 is fun(0.1)-fun(-0.1). 
My question is therefore how do I compute the confidence interval for this 
change?

This is easy to do with the Design-library for the zero-part but as far 
as I know, zero-truncated negative binomial data can't be fitted using 
Design's functions as they are. Does someone know any neat tricks that 
would make this possible?

Any help on this would be greatly appreciated. Thanks for your time.

/Erik Lampa, Statistician, Uppsala University Hospital, Sweden

[[alternative HTML version deleted]]

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


Re: [R] How to get the length of an UTF-8 string

2008-11-06 Thread Prof Brian Ripley

On Thu, 6 Nov 2008, Fán Lóng wrote:


Hi there,

I am intending to get the length of an UTF-8 string which contains
some Japanese characters (let's say, rstr) in R language.
I try to use the nchar(rstr) to get its length, however, it returns
the NA for it contains some multi-byte characters.

Is there any alternatives to return the length of this rstr?


Use a UTF-8 locale, then nchar() will get it right.

Or convert it to the Japanese locale on your system, and use nchar in that 
locale.




Any suggestion is  appreciated.

Long

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


Please do: we are missing the 'at a minimum' information needed to answer 
this question.  Locales do matter.



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


Re: [R] mean computation for external data

2008-11-06 Thread Uwe Ligges



christabel_jane prudencio wrote:


 
I have an external data (.txt) for

annual peak flood. The first column is the year, second column is the
observation date, and the last is the observed discharge. My task is to
calculate the mean, skewness and kurtosis of the said data. I was advised to use
read.table() to read the entire data. Please help me on how to perform the
required computation. I am obviously a new user of this statistical software.
Thank you so much for helping.


Then please read the posting guide of this list and learn that we will 
not solve your homeworks.


Uwe Ligges




Christabel Jane P. Rubio
M.S. Student
Water Resources Engineering
Dept. of Construction  Environmental Engineering 
Kongju National University (Cheonan Campus)

102th Office,The 5th Engineering Building,
275, Budae-dong, Cheonan-si, Chungnam-do, 330-717, Korea
TEL : +82-41-521-9316 
FAX : +82-41-568-0287


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


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


Re: [R] Simple rep() question duplicating times and dates.

2008-11-06 Thread Solveig Mimler
Hi John,

I had the same problem yesterday and solved it like following:

seq(ISOdate(Year,Month,Day,Hour), by=hour, length=24*365)

for example: seq(ISOdate(2005,1,1,0), by=hour, length=8760)

Regards,
Solveig 


EIFER
Europäisches Institut für Energieforschung
Institut européen de recherche sur l'énergie
European Institute for Energy Research

Solveig Mimler 
Sociologist M.A.
Emmy-Noether-Straße 11
76131 Karlsruhe
Tel: +49 721 6105 1351
Fax: +49 721 6105 1332
mailto: [EMAIL PROTECTED]
_

EIFER
Europäisches Institut für Energieforschung, 
Electricité de France / Universität Karlsruhe (TH) EWIV 
Sitz der europäischen wirtschaftlichen Interessenvereinigung: Karlsruhe
Handelsregister: Amtsgericht Karlsruhe HRA 4823 
Vorsitzender des Aufsichtsrats: Prof. Dr.-Ing. RAINER REIMERT
Geschäftsführer: Dr. FREDERIC BARON (Institutsleiter) 
_

This e-mail and any attachment is for authorized use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by any other party.
If you are not an intended recipient then please promptly delete this 
e-mail and any attachment and all copies and inform the sender.
_

Message: 27
Date: Wed, 5 Nov 2008 16:14:19 +0100
From: Gustaf Rydevik [EMAIL PROTECTED]
Subject: Re: [R] Simple rep() question duplicating times and dates.
To: [EMAIL PROTECTED]
Cc: R R-help [EMAIL PROTECTED]
Message-ID:
 [EMAIL PROTECTED]
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Nov 5, 2008 at 4:02 PM, John Kane [EMAIL PROTECTED] wrote:

 I want to create a data.frame of time and date for a year.  I started 
with the idea of simply producing two vectors (time and date)

 The first part ( time) is easy.
  rep(1:24, 365)

 But how do I get a series of 24 dates for O1 January 2005 and repeat 
this to 31 December 2005.

 It should be easy but I don't see it.

 Thanks


Hi John,

?Date leads you to (among other things) ?seq.Date.

Something like this should work:

time-rep(1:24, 365)
dates-seq(as.Date(01012005,format=%d%m%Y),as.Date(31122005,format=%d%m%Y),by=1)
TimeFrame-data.frame(time)
TimeFrame$dates-rep(dates,each=24)


Regards,
Gustaf
-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik



--

Message: 28
Date: Wed, 5 Nov 2008 07:30:31 -0800 (PST)
From: John Kane [EMAIL PROTECTED]
Subject: Re: [R] Simple rep() question duplicating times and dates.
To: Gustaf Rydevik [EMAIL PROTECTED]
Cc: R R-help [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii

I don't have R on this machine to try it but it looks good to me.  I had 
even got as far as seq() but completely missed the use of each. 

Thanks very much.

--- On Wed, 11/5/08, Gustaf Rydevik [EMAIL PROTECTED] wrote:

 From: Gustaf Rydevik [EMAIL PROTECTED]
 Subject: Re: [R] Simple rep() question duplicating times and dates.

 Cc: R R-help [EMAIL PROTECTED]
 Received: Wednesday, November 5, 2008, 10:14 AM
 On Wed, Nov 5, 2008 at 4:02 PM, John Kane

 
  I want to create a data.frame of time and date for a
 year.  I started with the idea of simply producing two
 vectors (time and date)
 
  The first part ( time) is easy.
   rep(1:24, 365)
 
  But how do I get a series of 24 dates for O1 January
 2005 and repeat this to 31 December 2005.
 
  It should be easy but I don't see it.
 
  Thanks
 
 
 Hi John,
 
 ?Date leads you to (among other things) ?seq.Date.
 
 Something like this should work:
 
 time-rep(1:24, 365)
 
dates-seq(as.Date(01012005,format=%d%m%Y),as.Date(31122005,format=%d%m%Y),by=1)
 TimeFrame-data.frame(time)
 TimeFrame$dates-rep(dates,each=24)
 
 
 Regards,
 Gustaf
 -- 
 Gustaf Rydevik, M.Sci.
 tel: +46(0)703 051 451
 address:Essingetorget 40,112 66 Stockholm, SE
 skype:gustaf_rydevik


[[alternative HTML version deleted]]

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


[R] mean computation for external data

2008-11-06 Thread christabel_jane prudencio


 
I have an external data (.txt) for
annual peak flood. The first column is the year, second column is the
observation date, and the last is the observed discharge. My task is to
calculate the mean, skewness and kurtosis of the said data. I was advised to use
read.table() to read the entire data. Please help me on how to perform the
required computation. I am obviously a new user of this statistical software.
Thank you so much for helping.

Christabel Jane P. Rubio
M.S. Student
Water Resources Engineering
Dept. of Construction  Environmental Engineering 
Kongju National University (Cheonan Campus)
102th Office,The 5th Engineering Building,
275, Budae-dong, Cheonan-si, Chungnam-do, 330-717, Korea
TEL : +82-41-521-9316 
FAX : +82-41-568-0287

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


[R] RES: R Mixed Anova

2008-11-06 Thread Rodrigo Aluizio
Thanks Mark, it was exactly what I was looking for.

-Mensagem original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Em nome de Mark Difford
Enviada em: quinta-feira, 6 de novembro de 2008 09:22
Para: r-help@r-project.org
Assunto: Re: [R] R Mixed Anova


Hi Rodrigo,

Here are two options; for each type, the second version gives 2nd order
interactions

## aov
T.aovmod - aov(response ~ Season + Beach + Line + Error(Block/Strata))
T.aovmod - aov(response ~ (Season + Beach + Line)^2 + Error(Block/Strata))

## lme
library(nlme)
T.lmemod - lme(response ~ Season + Beach + Line, random = ~ 1 |
Block/Strata)
T.lmemod - lme(response ~ (Season + Beach + Line)^2, random = ~ 1 |
Block/Strata)
anova(T.lmemod)
?anova.lme

## Use package multcomp for doing post-hoc analysis.

Regards, Mark.


Rodrigo Aluizio wrote:
 
 Hi list, I was searching how to properly write a command line for a mixed
 ANOVA. Well honestly, there are so many material on the older post of the
 list that just confused me.
 
 I have five factors.
 
  
 
 Season (fixed)
 
 Beach (fixed)
 
 Line (fixed)
 
 Block (random)
 
 Strata (random) nested in Block
 
  
 
 And for each of the tree strata per block I got 3 replicates. 
 
  
 
 I saw lots of things about “different” linear models commands… lm, lme… On
 R
 help I found aov and anova…
 
  
 
 Any one knows what should be more adequate and how I write and appropriate
 command line? I need an ANOVA table, a p value, and be able to run post
 hoc
 tests.
 
  
 
 Thanks for your attention and patience.
 
  
 
 ___
 MSc.  mailto:[EMAIL PROTECTED] Rodrigo Aluizio
 Centro de Estudos do Mar/UFPR
 Laboratório de Micropaleontologia
 Avenida Beira Mar s/n - CEP 83255-000
 Pontal do Paraná - PR - BRASIL
 Fone: (0**41) 3455-1496 ramal 217
 Fax: (0**41) 3455-1105
 
 
 
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/R-Mixed-Anova-tp20358811p20359309.html
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] replicate and as.matrix: different behaviour between batch and non-batch mode

2008-11-06 Thread Oliver Bandel
Hello,


for a simulation  I tried the following:

=
sampmeanvec - function (from, n, repititions)
{
  print( paste(samplesize n:, n, repititions:, repititions) )
  samples.mat - as.matrix( replicate( repititions, sample(from, n) ) )

  # would that case-check be necessary?
  #if( n == 1 )
  #{
  #  samples.mat - t (samples.mat)
  #}

  print( Dim of matrix:)
  print( dim(samples.mat) )

  meanvec - apply(samples.mat, 2, mean)
  return(meanvec)
}


gleichsamp - runif(1)

for( sampsize in c(1,2,4,8,16,32,64,128) )
{
  sampmeanvec(gleichsamp, sampsize, 20)
}

=

The following result:
--
 source(central_limit_theorem.R)
[1] samplesize n: 1 repititions: 20
[1] Dim of matrix:
[1] 20  1
[1] samplesize n: 2 repititions: 20
[1] Dim of matrix:
[1]  2 20
[1] samplesize n: 4 repititions: 20
[1] Dim of matrix:
[1]  4 20
[1] samplesize n: 8 repititions: 20
[1] Dim of matrix:
[1]  8 20
[1] samplesize n: 16 repititions: 20
[1] Dim of matrix:
[1] 16 20
[1] samplesize n: 32 repititions: 20
[1] Dim of matrix:
[1] 32 20
[1] samplesize n: 64 repititions: 20
[1] Dim of matrix:
[1] 64 20
[1] samplesize n: 128 repititions: 20
[1] Dim of matrix:
[1] 128  20


Look at the first dimension: there the cols and rows are
changed.

I tried directly in the R-shell:


 x - 1:20
 dim( as.matrix(replicate(1, sample(x, length(x)) )  ))
[1] 20  1
 dim( as.matrix(replicate(2, sample(x, length(x)) )  ))
[1] 20  2
 dim( as.matrix(replicate(3, sample(x, length(x)) )  ))
[1] 20  3
 dim( as.matrix(replicate(4, sample(x, length(x)) )  ))
[1] 20  4


This looks good (and correct to me).


Can you locate my problem here?

Why is the cols and rows dimensions be changed?

Without using as.matrix the result of replicte is just a vector.
So I have to use it.
But only in the script/batch-mode.

Typed in directly (see above), it works as expected.

Any ideas on this behaviour?

Ciao,
   Oliver

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


Re: [R] r script

2008-11-06 Thread Barry Rowlingson
2008/11/6 Paul Hiemstra [EMAIL PROTECTED]:

 How can execute a bash command inside the script, like the command for
 change the directory (cd)?

 ?system

 The system function won't work for changing the working directory of R though:

 getwd()
[1] /home/rowlings
 system(cd /)
 getwd()
[1] /home/rowlings

 For that you need R the function setwd(newWorkingDirectory).

Barry

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


[R] RE : Text function in 3D graph

2008-11-06 Thread EVANS David-William
I produced the 3D plot with cloud function (lattice package), but rgl package 
works well: I can easily plot in 3D and annotate.

Thank you very much for your help.

Sebastian.

-
Merci de répondre à cette adresse e-mail et à [EMAIL PROTECTED]  
Please reply both to this email address and to [EMAIL PROTECTED] 
 

-Message d'origine-
De : Duncan Murdoch [mailto:[EMAIL PROTECTED] 
Envoyé : mercredi 5 novembre 2008 19:02
À : EVANS David-William
Cc : r-help@r-project.org
Objet : Re: [R] Text function in 3D graph

On 11/5/2008 10:59 AM, EVANS David-William wrote:
 Fellow R users,
 
  
 
 I often use « text » to annotate plots in 2 dimensions.  Having grown up to 3 
 dimensions recently, I am looking for a similar function.  Could anyone 
 provide code for how to annotate points in a 3-d plot?

You need to describe how you are producing the 3d plot.  The rgl package 
has text3d, but it's different in the scatterplot3d package or lattice.

Duncan Murdoch

  
 
 Your help is greatly appreciated.
 
  
 
 For Sébastien Velazquez.
 
  
 
 -
 
 Merci de répondre à cette adresse e-mail et à [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] .  
 
 Please reply both to this email address and to [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] . 
 
  
 
  
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] R Mixed Anova

2008-11-06 Thread Rodrigo Aluizio
Hi list, I was searching how to properly write a command line for a mixed
ANOVA. Well honestly, there are so many material on the older post of the
list that just confused me.

I have five factors.

 

Season (fixed)

Beach (fixed)

Line (fixed)

Block (random)

Strata (random) nested in Block

 

And for each of the tree strata per block I got 3 replicates. 

 

I saw lots of things about “different” linear models commands… lm, lme… On R
help I found aov and anova…

 

Any one knows what should be more adequate and how I write and appropriate
command line? I need an ANOVA table, a p value, and be able to run post hoc
tests.

 

Thanks for your attention and patience.

 

___
MSc.  mailto:[EMAIL PROTECTED] Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia
Avenida Beira Mar s/n - CEP 83255-000
Pontal do Paraná - PR - BRASIL
Fone: (0**41) 3455-1496 ramal 217
Fax: (0**41) 3455-1105




[[alternative HTML version deleted]]

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


[R] Queries about step() and stepAIC()

2008-11-06 Thread Philip Whittall
I have been learning how to use these functions and would like to know
the following as
I have so far been unable to find the answers in the documentation.

1) What stopping rules are used ?

2) Can the stopping rules be changed?

3) Can the results of each step be stored as objects in R and if so how
?

4) Is there a worked example somewhere of using the keep= argument ?

Many thanks in anticipation,

Philip
 



This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy by 
an authorised signatory.  The contents of this email may relate to dealings 
with other companies within the Detica Group plc group of companies.

Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.



[[alternative HTML version deleted]]

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


[R] How to get the length of an UTF-8 string

2008-11-06 Thread Fán Lóng
Hi there,

I am intending to get the length of an UTF-8 string which contains
some Japanese characters (let's say, rstr) in R language.
I try to use the nchar(rstr) to get its length, however, it returns
the NA for it contains some multi-byte characters.

Is there any alternatives to return the length of this rstr?

Any suggestion is  appreciated.

Long

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


[R] unlist dataframes

2008-11-06 Thread Naira

Dear all,

I would like to know whether it is possible to unlist elements and keep the
original format of the data.
To make it more clear, let me give an exemple:
I have a list l of dataframes that I created with apply but which looks like
this:

x1=data.frame(Name=LETTERS[1:2],Age=1:2)
x2=data.frame(Name=LETTERS[3:4],Age=3:4)
l=list(x1,x2)
l
[[1]]
  Name Age
1A   1
2B   2

[[2]]
  Name Age
1C   3
2D   4

I would like to unlist l to create a dataframe with 2 columns and 4 rows but
keeping the format of Name (character) and Age (numeric).

Now when I unlist l, I obtain :

unlist(l)
Name1 Name2  Age1  Age2 Name1 Name2  Age1  Age2
1 2 1 2 1 2 3 4

Is there a way to at least obtain something like
A 1 B 2 C 3 D 4 as result from the unlist??

Thanks a lot for your replies
Naira


-- 
View this message in context: 
http://www.nabble.com/unlist---dataframes-tp20358993p20358993.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Calling optim and .C

2008-11-06 Thread Armin Meier
Thanks,
your answer just helped me to find the error.

Armin

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


Re: [R] Data manipulation question

2008-11-06 Thread bartjoosen

How about: 

id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) 
start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) 
stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) 
data - data.frame(id,start,stop)

f - function(data){
m - match(data$start,data$stop) + 1
if (length(m)==1  is.na(m)) m - 1 
if (length(m)  1  is.na(m[2])) m - 1
data$stop[min(m,na.rm=T)]
}

by(data,data$id,f)

The if statements in the function are for some special cases, in all the
other cases the firs line will do the trick.
I would like to add that using data is a somewhat bad behavior, as this
overwrites the build in data function of R.
And I changed the way you made up the data.frame, as your method would
convert everything to factors.

Good luck

Bart



Peter Jepsen wrote:
 
 Dear R-listers,
 
 I am a relatively inexperienced R-user currently migrating from Stata. I
 am deeply frustrated by this data manipulation question: I know how I
 could do it in Stata, but I cannot make it work in R.
 
 I have a data frame of hospitalization data where each row represents an
 admission. I need to know when patients were first discharged, but the
 problem is that patients were sometimes transferred between hospital
 departments. In my data a transfer looks like a new admission, except
 that it has a 'start' date equal to the previous admission's 'stop'
 date.
 
 Here is an example:
 
 id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
 start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
 stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
 data - as.data.frame(cbind(id,start,stop))
 data
 #id start stop
 # 1   a 06
 # 2   a 6   12
 # 3   a17   20
 # 4   a20   30
 # 5   b 01
 # 6   b 1   10
 # 7   c 03
 # 8   c 5   10
 # 9   c10   11
 # 10  c11   30
 # 11  c50   55
 # 12  d 06
 
 So, what I want to end up with is this:
 
 id start stop
 a  0 12   # This patient was transferred at time 6 and discharged at
 time 12. The admission starting at time 17 is therefore irrelevant.
 b  0 10   
 c  0 3
 d  0 6
 
 I have tried tons of variations over lapply, sapply, split, for etc.,
 all to no avail. 
 
 Thank you in advance for any assistance.
 
 Best regards,
 Peter Jepsen, MD.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Data-manipulation-question-tp20356835p20358624.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Data manipulation question

2008-11-06 Thread cruz
On Thu, Nov 6, 2008 at 4:23 PM, Peter Jepsen [EMAIL PROTECTED] wrote:

 Here is an example:

 id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
 start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
 stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
 data - as.data.frame(cbind(id,start,stop))
 data
 #id start stop
 # 1   a 06
 # 2   a 6   12
 # 3   a17   20
 # 4   a20   30
 # 5   b 01
 # 6   b 1   10
 # 7   c 03
 # 8   c 5   10
 # 9   c10   11
 # 10  c11   30
 # 11  c50   55
 # 12  d 06

 So, what I want to end up with is this:

 id start stop
 a  0 12   # This patient was transferred at time 6 and discharged at
 time 12. The admission starting at time 17 is therefore irrelevant.
 b  0 10
 c  0 3
 d  0 6


Try this:

result - list()
num - length(levels(factor(data$id)))
length(result) - 3*num
dim(result) - c(3,num)
result - data[data$start == 0,]
Y - as.integer(row.names(result))

for (i in 1:num) {
  if (Y[i] == dim(data)[1]) (result[i,3] - data[dim(data)[1],3])
  else (result[i,3] - data[Y[i]+1,3])
}
result


Sorry it is ugly cuz i am new too but hopefully it gives you some ideas.

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


[R] mean computation for external data

2008-11-06 Thread christabel jane

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


Re: [R] Data manipulation question

2008-11-06 Thread Peter Jepsen
Thank you for your prompt assistance, cruz and Bart. 

Bart set me on the right track, and I modified his proposal to this:

f - function(data){
m - match(data$stop,data$start) 
n - min(length(m),which(is.na(m)))
data$stop[n]
}
by(data,data$id,f)

It also handles some special cases outside my small example dataset.

Thank you again!
Peter.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of bartjoosen
Sent: 6. november 2008 11:31
To: r-help@r-project.org
Subject: Re: [R] Data manipulation question


How about: 

id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) 
start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) 
stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) 
data - data.frame(id,start,stop)

f - function(data){
m - match(data$start,data$stop) + 1
if (length(m)==1  is.na(m)) m - 1 
if (length(m)  1  is.na(m[2])) m - 1
data$stop[min(m,na.rm=T)]
}

by(data,data$id,f)

The if statements in the function are for some special cases, in all the
other cases the firs line will do the trick.
I would like to add that using data is a somewhat bad behavior, as this
overwrites the build in data function of R.
And I changed the way you made up the data.frame, as your method would
convert everything to factors.

Good luck

Bart



Peter Jepsen wrote:
 
 Dear R-listers,
 
 I am a relatively inexperienced R-user currently migrating from Stata.
I
 am deeply frustrated by this data manipulation question: I know how I
 could do it in Stata, but I cannot make it work in R.
 
 I have a data frame of hospitalization data where each row represents
an
 admission. I need to know when patients were first discharged, but the
 problem is that patients were sometimes transferred between hospital
 departments. In my data a transfer looks like a new admission, except
 that it has a 'start' date equal to the previous admission's 'stop'
 date.
 
 Here is an example:
 
 id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
 start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
 stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
 data - as.data.frame(cbind(id,start,stop))
 data
 #id start stop
 # 1   a 06
 # 2   a 6   12
 # 3   a17   20
 # 4   a20   30
 # 5   b 01
 # 6   b 1   10
 # 7   c 03
 # 8   c 5   10
 # 9   c10   11
 # 10  c11   30
 # 11  c50   55
 # 12  d 06
 
 So, what I want to end up with is this:
 
 id start stop
 a  0 12   # This patient was transferred at time 6 and discharged
at
 time 12. The admission starting at time 17 is therefore irrelevant.
 b  0 10   
 c  0 3
 d  0 6
 
 I have tried tons of variations over lapply, sapply, split, for etc.,
 all to no avail. 
 
 Thank you in advance for any assistance.
 
 Best regards,
 Peter Jepsen, MD.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context:
http://www.nabble.com/Data-manipulation-question-tp20356835p20358624.htm
l
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] need help in plotting barchart

2008-11-06 Thread Kurapati, Ravichandra (Ravichandra)
Df contains  

 Session_Setup   DCT RevDataVols_bincounts
comp

1Session_Setup   RLL   1NA
Session_Setup+RLL+1

2Session_Setup   RLL   2NA
Session_Setup+RLL+2

3Session_Setup   RLL   3NA
Session_Setup+RLL+3

4Session_Setup   RLL   4NA
Session_Setup+RLL+4

5Session_Setup   RLL   5NA
Session_Setup+RLL+5

6Session_Setup   RLL   6NA
Session_Setup+RLL+6

7Session_Setup   RLL   7NA
Session_Setup+RLL+7

8Session_Setup   RLL   8NA
Session_Setup+RLL+8

9Session_Setup   RLL   9NA
Session_Setup+RLL+9

10   Session_Setup   RLL  10NA
Session_Setup+RLL+10

11   Session_Setup   RLL  11NA
Session_Setup+RLL+11

12   Session_Setup   RLL  12NA
Session_Setup+RLL+12

13   Session_Setup   RLL  13NA
Session_Setup+RLL+13

14   Session_Setup   RLL  14NA
Session_Setup+RLL+14

15   Session_Setup   RLL  15NA
Session_Setup+RLL+15

16   Session_Setup   RLL  16NA
Session_Setup+RLL+16

17   Session_Setup   RLL  17NA
Session_Setup+RLL+17

18   Session_Setup   RLL  18NA
Session_Setup+RLL+18

19   Session_Setup   RLL  19NA
Session_Setup+RLL+19

20   Session_Setup   RLL  20NA
Session_Setup+RLL+20

21   Session_Setup   RLL  21NA
Session_Setup+RLL+21

22   Session_Setup   RLL  22NA
Session_Setup+RLL+22

23   Session_Setup   RLL  23NA
Session_Setup+RLL+23

24   Session_Setup   RLL  24NA
Session_Setup+RLL+24

25   Session_Setup   RLL  25NA
Session_Setup+RLL+25

26   Session_Setup   RLL  26NA
Session_Setup+RLL+26

27   Session_Setup   RLL  27NA
Session_Setup+RLL+27

28   Session_Setup   RLL  28NA
Session_Setup+RLL+28

29   Session_Setup   RLL  29NA
Session_Setup+RLL+29

30   Session_Setup   RLL  30NA
Session_Setup+RLL+30

31  User_Initiated   RLL   1  8.487840
User_Initiated+RLL+1

32  User_Initiated   RLL   2  6.066089
User_Initiated+RLL+2

33  User_Initiated   RLL   3NA
User_Initiated+RLL+3

34  User_Initiated   RLL   4NA
User_Initiated+RLL+4

35  User_Initiated   RLL   5  5.906891
User_Initiated+RLL+5

36  User_Initiated   RLL   6NA
User_Initiated+RLL+6

37  User_Initiated   RLL   7NA
User_Initiated+RLL+7

38  User_Initiated   RLL   8NA
User_Initiated+RLL+8

39  User_Initiated   RLL   9NA
User_Initiated+RLL+9

40  User_Initiated   RLL  10NA
User_Initiated+RLL+10

41  User_Initiated   RLL  11NA
User_Initiated+RLL+11

42  User_Initiated   RLL  12NA
User_Initiated+RLL+12

43  User_Initiated   RLL  13NA
User_Initiated+RLL+13

44  User_Initiated   RLL  14NA
User_Initiated+RLL+14

45  User_Initiated   RLL  15NA
User_Initiated+RLL+15

46  User_Initiated   RLL  16NA
User_Initiated+RLL+16

47  User_Initiated   RLL  17NA
User_Initiated+RLL+17

48  User_Initiated   RLL  18NA
User_Initiated+RLL+18

49  User_Initiated   RLL  19NA
User_Initiated+RLL+19

50  User_Initiated   RLL  20NA
User_Initiated+RLL+20

51  User_Initiated   RLL  21NA
User_Initiated+RLL+21

52  User_Initiated   RLL  22NA
User_Initiated+RLL+22

53  User_Initiated   RLL  23NA
User_Initiated+RLL+23

54  User_Initiated   RLL  24NA
User_Initiated+RLL+24

55  User_Initiated   RLL  25NA
User_Initiated+RLL+25

56  User_Initiated   RLL  26NA
User_Initiated+RLL+26

57  User_Initiated   RLL  27NA
User_Initiated+RLL+27

58  User_Initiated   RLL  28NA
User_Initiated+RLL+28

59  User_Initiated   RLL  29NA
User_Initiated+RLL+29

60  User_Initiated   RLL  30NA
User_Initiated+RLL+30

61   Session_Setup NoRLL   1  8.906891
Session_Setup+NoRLL+1

62   Session_Setup NoRLL   2NA
Session_Setup+NoRLL+2

63   Session_Setup NoRLL   3NA
Session_Setup+NoRLL+3

64   Session_Setup NoRLL   4NA
Session_Setup+NoRLL+4

65   Session_Setup NoRLL   5NA
Session_Setup+NoRLL+5

66   Session_Setup NoRLL   6NA
Session_Setup+NoRLL+6

67   Session_Setup NoRLL   7NA
Session_Setup+NoRLL+7

68   

[R] Bio7 1.3 for Linux released!

2008-11-06 Thread Bio7

Release notes:

http://www.nabble.com/Bio7-1.3-Linux-released!-td20360723.html#a20360723
http://www.nabble.com/Bio7-1.3-Linux-released!-td20360723.html#a20360723 

With kind regards

M.Austenfeld 
-- 
View this message in context: 
http://www.nabble.com/New-version-of-ecological-modeling-software-using-R-tp20318525p20362952.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
Hi all,

I'm trying to write up some recommendations for what graphics formats
are most useful for inclusion into ms office and openoffice.  There
have been a few discussions on the list in the past, but I haven't
seen a summary.  These are the options I've seen so far, along with
there costs and benefits:

 * high-resolution (600-dpi) png output (or tiff or jpg or other
raster format).  The main disadvantage is that it's a raster format,
so you need to know the eventual output size.

 * windows metafile: works well in MS office, but does not support
transparency.  Can only be produced on windows, and openoffice support
isn't great

 * encapsulated postscript: supported by both MS office and open
office, but won't display a preview image unless you add one with an
external program.  Prints fine.

 * svg: R output devices still experimental and open office import
still experimental.  No support in ms office.

Have I missed anything?  Is the information correct?

Hadley

-- 
http://had.co.nz/

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


Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread Philippe Grosjean

Hello Hadley,

I have started this: 
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export.


One solution that works not too bad in OpenOffice is to output the graph 
in XFig format, and then use fig2dev from transfig to get an EMF file. 
That one is rather well readable by OpenOffice. There are some 
limitations of XFig with R graphs, see ?xfig.


Best,

Philippe
..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

hadley wickham wrote:

Hi all,

I'm trying to write up some recommendations for what graphics formats
are most useful for inclusion into ms office and openoffice.  There
have been a few discussions on the list in the past, but I haven't
seen a summary.  These are the options I've seen so far, along with
there costs and benefits:

 * high-resolution (600-dpi) png output (or tiff or jpg or other
raster format).  The main disadvantage is that it's a raster format,
so you need to know the eventual output size.

 * windows metafile: works well in MS office, but does not support
transparency.  Can only be produced on windows, and openoffice support
isn't great

 * encapsulated postscript: supported by both MS office and open
office, but won't display a preview image unless you add one with an
external program.  Prints fine.

 * svg: R output devices still experimental and open office import
still experimental.  No support in ms office.

Have I missed anything?  Is the information correct?

Hadley



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


[R] wireframe

2008-11-06 Thread Bill Szkotnicki

I've been using lattice/wireframe succesfully to visualize some data.
I have one question.
I want to be able to change the viewpoint ( i.e. rotate the plotted 
figure a bit left or right or up and down )

Is there a way to do that?
Or is there some other package around that could help?
Thanks.

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


[R] Re : Dataframe help

2008-11-06 Thread Olivier ETERRADOSSI

Hi Ramya,
Sorry if I missed something, but unless I have problems reading your 
message it seems that there is no line in your example matching both 
your test conditions...

Hope this helps. Olivier



Hi there,

I have a dataframe length.unique.info
  

 length.unique.info


abc 12  345
def  16  550
lmn  6   600
I want those names that fall under the condition (length.unique.info[,2][i]
=5  length.unique.info[,3][i] =500)

abcder-length.unique.info[which(length.unique.info[,2][i] =5 
length.unique.info[,3][i] = 500),1]

will  look for both the condition.It isnt returning names is there
anything i am missing.Kindly suggest me the way to do it.

Regards
Ramya


--
Olivier ETERRADOSSI
Maître-Assistant
CMGD / Equipe Propriétés Psycho-Sensorielles des Matériaux
Ecole des Mines d'Alès
Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
tel std: +33 (0)5.59.30.54.25
tel direct: +33 (0)5.59.30.90.35 
fax: +33 (0)5.59.30.63.68

http://www.ema.fr

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


[R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber

Dear all,

How can I replace text in objects that are of class formula?

y=a * x + b
class(y)=formula
grep(x,y)
y[1]

Suppose I would like to replace the x by w in the formula object y.

How can this be done? Somehow, the methods that can be used in character objects do not work 1:1 in 
formula objects...


Many thanks and best wishes
Christoph



--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

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


[R] comparing matrices using max or min

2008-11-06 Thread Diogo André Alagador
Dear all,
 
I have 3 matrices with the same dimension, A,B,C and I would like to produce
a matrix D where in each position would retrieve the max(or min) value along
A,B,C taken from the same position.
I guess that apply functions should fit, but for matrices objects I am not
getting it.
 
thanks in advance,
 
Diogo André Alagador

[[alternative HTML version deleted]]

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


Re: [R] wireframe

2008-11-06 Thread Kornelius Rohmeyer
Am Donnerstag, den 06.11.2008, 10:38 -0500 schrieb Bill Szkotnicki:
 I've been using lattice/wireframe succesfully to visualize some data.
 I have one question.
 I want to be able to change the viewpoint ( i.e. rotate the plotted 
 figure a bit left or right or up and down )
 Is there a way to do that?

Take a look at the parameter screen in ?wireframe:

The viewing direction is given by a sequence of rotations specified by
the 'screen' argument, starting from the positive Z-axis.

e.g. screen = list(z = 20, x = -70, y = 3) from the example section.

Kornelius.

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


Re: [R] wireframe

2008-11-06 Thread jim holtman
Try the 'rgl' package.

On Thu, Nov 6, 2008 at 10:38 AM, Bill Szkotnicki [EMAIL PROTECTED] wrote:
 I've been using lattice/wireframe succesfully to visualize some data.
 I have one question.
 I want to be able to change the viewpoint ( i.e. rotate the plotted figure a
 bit left or right or up and down )
 Is there a way to do that?
 Or is there some other package around that could help?
 Thanks.

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

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


Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread Max Kuhn
  * svg: R output devices still experimental

I've been using the svg device in the Cairo package for a while now.
I've never had any issues with it and wouldn't characterize it as
experimental (of course, others may have had issues).

I have had problems generating svg using some of the non-Cairo
packages, but this was some time ago.

Until OO can import them without going to great lengths, I guess it is
a moot point.

-- 

Max

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


Re: [R] replicate and as.matrix: different behaviour between batch and non-batch mode

2008-11-06 Thread Charles C. Berry

On Thu, 6 Nov 2008, Oliver Bandel wrote:


Hello,


for a simulation  I tried the following:

=
sampmeanvec - function (from, n, repititions)
{
 print( paste(samplesize n:, n, repititions:, repititions) )
 samples.mat - as.matrix( replicate( repititions, sample(from, n) ) )

 # would that case-check be necessary?
 #if( n == 1 )
 #{
 #  samples.mat - t (samples.mat)
 #}

 print( Dim of matrix:)
 print( dim(samples.mat) )

 meanvec - apply(samples.mat, 2, mean)
 return(meanvec)
}


gleichsamp - runif(1)

for( sampsize in c(1,2,4,8,16,32,64,128) )
{
 sampmeanvec(gleichsamp, sampsize, 20)
}

=

The following result:
--

source(central_limit_theorem.R)

[1] samplesize n: 1 repititions: 20
[1] Dim of matrix:
[1] 20  1
[1] samplesize n: 2 repititions: 20
[1] Dim of matrix:
[1]  2 20
[1] samplesize n: 4 repititions: 20
[1] Dim of matrix:
[1]  4 20
[1] samplesize n: 8 repititions: 20
[1] Dim of matrix:
[1]  8 20
[1] samplesize n: 16 repititions: 20
[1] Dim of matrix:
[1] 16 20
[1] samplesize n: 32 repititions: 20
[1] Dim of matrix:
[1] 32 20
[1] samplesize n: 64 repititions: 20
[1] Dim of matrix:
[1] 64 20
[1] samplesize n: 128 repititions: 20
[1] Dim of matrix:
[1] 128  20




Look at the first dimension: there the cols and rows are
changed.

I tried directly in the R-shell:



x - 1:20
dim( as.matrix(replicate(1, sample(x, length(x)) )  ))

[1] 20  1

dim( as.matrix(replicate(2, sample(x, length(x)) )  ))

[1] 20  2

dim( as.matrix(replicate(3, sample(x, length(x)) )  ))

[1] 20  3

dim( as.matrix(replicate(4, sample(x, length(x)) )  ))

[1] 20  4


This looks good (and correct to me).


Look again .

It is not the same as what you have above.

If studying your code does not reveal your error, you might put a 
browser() call in your function after the samples.mat - ... line to

get a sense of what is happening. See

?browser






Can you locate my problem here?

Why is the cols and rows dimensions be changed?

Without using as.matrix the result of replicte is just a vector.




Not!


is.matrix( replicate(4, sample(x, length(x)) )  )

[1] TRUE

 So I have to use it.

But only in the script/batch-mode.

Typed in directly (see above), it works as expected.

Any ideas on this behaviour?



Get some rest. Then make a big pot of coffee. Stuff like this happens to 
many of us. You need to slow down and work thru your code before 
jumping to conclusions about odd behavior of well tested, well documented 
functions.



HTH,

Chuck




Ciao,
  Oliver

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
On Thu, Nov 6, 2008 at 10:05 AM, Max Kuhn [EMAIL PROTECTED] wrote:
  * svg: R output devices still experimental

 I've been using the svg device in the Cairo package for a while now.
 I've never had any issues with it and wouldn't characterize it as
 experimental (of course, others may have had issues).

Ah, ok.  There's a bewildering array of options for producing svg
(rsvgdevice, svg with grDevices, svg with Cairo, svg with cairoDevice,
gridSVG) and it's hard to figure out which is the most mature.  Thanks
for the info.

Hadley

-- 
http://had.co.nz/

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


[R] New to R - Errors in plotting

2008-11-06 Thread BKMooney

I am new to R and am running into trouble with the function plot.  

When I enter in the simple code: 
x-1:4
y-5:8
plot(x,y)

I get a scatter plot with 4 points as expected.  

However, with my own data, A and B are both vectors of length ~85, each
entry a decimal in [0,1].  

Using the same plot(A,B) with this data, the plot function no longer gives
me a simple plot with 85 points.  Instead there are many points, and what
looks to be several boxwhisker plots also included on the plot.  

This is a link to the actual output.  
http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp 

Why is the plot function doing this?  How can I get it to simply give me a
scatterplot?  (From there I want to do a lsline, etc..)

Any help is greatly appreciated...

Thanks!
-- 
View this message in context: 
http://www.nabble.com/New-to-R---Errors-in-plotting-tp20364310p20364310.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
Hi Phillippe,

Thanks for the pointer.  It looks like a nice resource.

Hadley

On Thu, Nov 6, 2008 at 9:34 AM, Philippe Grosjean
[EMAIL PROTECTED] wrote:
 Hello Hadley,

 I have started this:
 http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export.

 One solution that works not too bad in OpenOffice is to output the graph in
 XFig format, and then use fig2dev from transfig to get an EMF file. That one
 is rather well readable by OpenOffice. There are some limitations of XFig
 with R graphs, see ?xfig.

 Best,

 Philippe
 ..°}))
  ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..

 hadley wickham wrote:

 Hi all,

 I'm trying to write up some recommendations for what graphics formats
 are most useful for inclusion into ms office and openoffice.  There
 have been a few discussions on the list in the past, but I haven't
 seen a summary.  These are the options I've seen so far, along with
 there costs and benefits:

  * high-resolution (600-dpi) png output (or tiff or jpg or other
 raster format).  The main disadvantage is that it's a raster format,
 so you need to know the eventual output size.

  * windows metafile: works well in MS office, but does not support
 transparency.  Can only be produced on windows, and openoffice support
 isn't great

  * encapsulated postscript: supported by both MS office and open
 office, but won't display a preview image unless you add one with an
 external program.  Prints fine.

  * svg: R output devices still experimental and open office import
 still experimental.  No support in ms office.

 Have I missed anything?  Is the information correct?

 Hadley





-- 
http://had.co.nz/

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


Re: [R] Reshape a matrix

2008-11-06 Thread Gabor Grothendieck
Assuming you mean data frame and not matrix and
depending on whether the empty spaces are intended
to represent NA or 0 we have:

 DF - data.frame(V1 = LETTERS[1:3], V2 = LETTERS[24:26], V3 = 1:3)
 tapply(DF[[3]], DF[1:2], c)
   V2
V1   X  Y  Z
  A  1 NA NA
  B NA  2 NA
  C NA NA  3
 xtabs(V3 ~ V1 + V2, DF)
   V2
V1  X Y Z
  A 1 0 0
  B 0 2 0
  C 0 0 3


On Wed, Nov 5, 2008 at 7:53 PM, dinesh kumar [EMAIL PROTECTED] wrote:
 Dear R users,

 I have a matrix like

 A  X1
 B  Y2
 C  Z3

 I want to reshape this matrix into this format

X  Y  Z
 A  1
 B 2
 C 3



 Thanks in advance for your help.


 Dinesh

 --
 Dinesh Kumar Barupal
 Junior Specialist
 Metabolomics Fiehn Lab
 UCD Genome Center
 451 East Health Science Drive
 GBSF Builidng
 University of California
 DAVIS
 95616
 http://fiehnlab.ucdavis.edu/staff/kumar

[[alternative HTML version deleted]]

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


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


[R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread cruz
Hi,

I am writing this in a wrong way, can someone please correct me?

 A - matrix()
 length(A) - 6
 dim(A) - c(3,2)
 colnames(A) - c(X,Y)
 A
  X  Y
[1,] NA NA
[2,] NA NA
[3,] NA NA
 A$X
Error in A$X : $ operator is invalid for atomic vectors


Thanks,
cruz

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


Re: [R] New to R - Errors in plotting

2008-11-06 Thread jim holtman
You need to provide more information. PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Show at least an 'str' of your data if you can not include it and the
commands that you were using.

On Thu, Nov 6, 2008 at 11:18 AM, BKMooney [EMAIL PROTECTED] wrote:

 I am new to R and am running into trouble with the function plot.

 When I enter in the simple code:
 x-1:4
 y-5:8
 plot(x,y)

 I get a scatter plot with 4 points as expected.

 However, with my own data, A and B are both vectors of length ~85, each
 entry a decimal in [0,1].

 Using the same plot(A,B) with this data, the plot function no longer gives
 me a simple plot with 85 points.  Instead there are many points, and what
 looks to be several boxwhisker plots also included on the plot.

 This is a link to the actual output.
 http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp

 Why is the plot function doing this?  How can I get it to simply give me a
 scatterplot?  (From there I want to do a lsline, etc..)

 Any help is greatly appreciated...

 Thanks!
 --
 View this message in context: 
 http://www.nabble.com/New-to-R---Errors-in-plotting-tp20364310p20364310.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

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


Re: [R] replacing characters in formulae / models

2008-11-06 Thread Charles C. Berry

On Thu, 6 Nov 2008, Christoph Scherber wrote:


Dear all,

How can I replace text in objects that are of class formula?

y=a * x + b
class(y)=formula
grep(x,y)
y[1]



What exactly are you trying to accomplish??

And why did you assign 'formula' as the class of a character string?

'y' is not a valid formula object:


lm(y)

Error in terms.formula(formula, data = data) :
  argument is not a valid model

=

Perhaps, you need to review

?formula

and
11 Statistical models in R

from Introduction to R.

Oh, yes. There is the matter of reviewing the _posting guide_ before 
posting, too.


HTH,

Chuck




Suppose I would like to replace the x by w in the formula object y.

How can this be done? Somehow, the methods that can be used in character 
objects do not work 1:1 in formula objects...


Many thanks and best wishes
Christoph



--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] New to R - Errors in plotting

2008-11-06 Thread Erik Iverson

Hello -

In you example, what are the classes of x and y?

 x-1:4
 y-5:8
 plot(x,y)

class(x)
class(y)

In your 'real' data, what are the classes of A and B

class(A)
class(B)

One may be a factor?

How are you reading your data into R, read.table?  Make sure your data 
are numeric, then plot them, and it should do what you'd like.


Since you're new to R, one of my tips would be to learn the class() and 
str() functions.  Many functions, such as plot, operate differently 
depending on the class of data given to them, therefore it's very 
important to know the classes of your data objects.



BKMooney wrote:
I am new to R and am running into trouble with the function plot.  

When I enter in the simple code: 
x-1:4

y-5:8
plot(x,y)

I get a scatter plot with 4 points as expected.  


However, with my own data, A and B are both vectors of length ~85, each
entry a decimal in [0,1].  


Using the same plot(A,B) with this data, the plot function no longer gives
me a simple plot with 85 points.  Instead there are many points, and what
looks to be several boxwhisker plots also included on the plot.  

This is a link to the actual output.  
http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp 


Why is the plot function doing this?  How can I get it to simply give me a
scatterplot?  (From there I want to do a lsline, etc..)

Any help is greatly appreciated...

Thanks!


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


Re: [R] New to R - Errors in plotting

2008-11-06 Thread Duncan Murdoch

On 06/11/2008 11:18 AM, BKMooney wrote:
I am new to R and am running into trouble with the function plot.  

When I enter in the simple code: 
x-1:4

y-5:8
plot(x,y)

I get a scatter plot with 4 points as expected.  


However, with my own data, A and B are both vectors of length ~85, each
entry a decimal in [0,1].  


Using the same plot(A,B) with this data, the plot function no longer gives
me a simple plot with 85 points.  Instead there are many points, and what
looks to be several boxwhisker plots also included on the plot.  

This is a link to the actual output.  
http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp 


Why is the plot function doing this?  How can I get it to simply give me a
scatterplot?  (From there I want to do a lsline, etc..)

Any help is greatly appreciated...


Most likely your A vector is not numeric:  it's being read as strings 
like 0.4688, etc.  Take a look at str(A) and str(B) to see their 
structure.  (I can't tell from the plot, but I'd guess it's being read 
as a factor, because some of the values are not recognized as numeric.)


Duncan Murdoch

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread Erik Iverson

Hello -

cruz wrote:

Hi,

I am writing this in a wrong way, can someone please correct me?


A - matrix()
length(A) - 6
dim(A) - c(3,2)
colnames(A) - c(X,Y)
A

  X  Y
[1,] NA NA
[2,] NA NA
[3,] NA NA

A$X

Error in A$X : $ operator is invalid for atomic vectors


A[, X] may be what you want?

See the details of ?Extract about how '$' only works on recursive 
(list-like) objects, of which your matrix A is not one of.




Thanks,
cruz

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


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


Re: [R] replicate and as.matrix: different behaviour between batch and non-batch mode

2008-11-06 Thread Oliver Bandel
Hello Charles,

thank you for the hint.


Zitat von Charles C. Berry [EMAIL PROTECTED]:

[...]
  This looks good (and correct to me).

 Look again .

 It is not the same as what you have above.
[...]


OK, yes, you are right!

I mixed the two parameters...


Now I get the same problem also at the shell directly typed in:


=
 as.matrix(replicate(10, sample(x, 3) )  )
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]   12   153   12744   14620
[2,]6   11146   19   17   11   1911
[3,]   20   17683   14   19   10214

 as.matrix(replicate(10, sample(x, 2) )  )
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]4   17   18   146   115   17   1313
[2,]   143   16   12   177   20   16217

 as.matrix(replicate(10, sample(x, 1) )  )
  [,1]
 [1,]   19
 [2,]   17
 [3,]   12
 [4,]   14
 [5,]   12
 [6,]   13
 [7,]   18
 [8,]   12
 [9,]5
[10,]   20
 dim( as.matrix(replicate(10, sample(x, 3) )  ) )
[1]  3 10
 dim( as.matrix(replicate(10, sample(x, 2) )  ) )
[1]  2 10
 dim( as.matrix(replicate(10, sample(x, 1) )  ) )
[1] 10  1

=


So, the behaviour is the same...
...but is not really that fine. :(

...how could I avoid the necessity of the transposition
of the matrix in the case of only one sample?

I mean, it's not extremely a problem,
because there are not many loops aroud it,
but it looks somehow ugly. :(

Ciao,
  Oliver

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


Re: [R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber

Dear all, Dear Keith,

Well, of course in fact the problem is more complicated than that. The example was just for 
illustration.


I have several statistical models for which I want to retrieve predictions using delta.method (from 
library(alr3)).


Now for this I need a character string such as e.g.
delta.method(model, a + exp(c * x)) # model could for example be an 
exponential nls fit

where the x shall be replaced by a numeric value at which the predictions 
plus s.e. shall be returned:

delta.method(model, a + exp(c * 10))

##

Because there are many models for which this shall be done, I would like to have a function that 
does something like the following:


extract.estimates=function(model.list,xval)
for (i in 1:length(model.list)){
mod=model.list[i]

- extract the model formula using formula(mod)
- every time the variable x is present, it shall be replaced by xval
- create a pasted character string pastestring to be used by delta.method

result=list(delta.method(mod,pastestring))
return(result)
}

I hope this has helped illustrating my point.

All the best
Christoph




Keith Jewell schrieb:

Hi,

Firstly,  I'd recommend using '-' for assignment, rather than '='; it saves 
confusion
Secondly, I don't think you want 'a*x+b' as a formula, I think you want an 
expression.

Thirdly, your 'y' has only one term, a 9 character constant = a * x + b

Consider instead,
y - expression(a*x+b)
a - 2
b - 3
x - 1:10
y
eval(y)

Now, how to replace 'x' by 'w'?
I'm not an expert, but this is the kind of thing I need to do, so I'd 
welcome criticism of my approach.

I would view the expression as a list:
as.list(y)
as.list(y[[1]])

So y is an expression containing a sub-expression; that is y is  '(a*x) + b'
You want to access the sub-expression 'a*x'
y[[1]][[2]]
as.list(y[[1]][[2]])

Now you want to replace the third item in that sub-expression with the name 
(not the character) w

y[[1]][[2]][[3]] - as.name(w)
w - 11:20
y
eval(y)

hth

Keith J

P.S. Perhaps you really do want a formula; y ~ a*x+b ??
In that case I'd still probably manipulate it as a list.
---
Christoph Scherber [EMAIL PROTECTED] wrote in 
message news:[EMAIL PROTECTED]

Dear all,

How can I replace text in objects that are of class formula?

y=a * x + b
class(y)=formula
grep(x,y)
y[1]

Suppose I would like to replace the x by w in the formula object y.

How can this be done? Somehow, the methods that can be used in character 
objects do not work 1:1 in formula objects...


Many thanks and best wishes
Christoph



--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1


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

.



--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

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


Re: [R] Using a background photo in lattice--title and axes missing

2008-11-06 Thread Waichler, Scott R
 I am trying to use a background photo in a lattice plot.  I 
 am using the rimage and TeachingDemos packages to plot the 
 photo and translate from the photo coordinates in pixels to 
 geographic coordinates, which is what I want to use for 
 plotting contours, lines, etc.  The (unrunable) code below 
 does give me a plot showing the photo, color contours, 
 contour lines, and colorkey, but not the plot title or axes.  
 How can I get the title and axes to appear?

Nevermind, I figured out that all I needed was to add the statement
par(new=T) before plot(photo).

Regards,
Scott Waichler

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


[R] need help with SIGNAL module

2008-11-06 Thread Michael Tiemann
I sent this message to the maintainer's email address listed on the 
signal package, but it bounced.  Perhaps somebody on this list has more 
insight into the signal package than I do (or knows the maintainer's new 
address):


Subject:
question about buttord function in R signal module
From:
Michael Tiemann [EMAIL PROTECTED]
Date:
Thu, 06 Nov 2008 07:18:58 -0500

To:
[EMAIL PROTECTED]


Tom,

I was trying to compare lowpass and highpass filters and found that the 
buttord example in the manual worked as expected, namely the $type was 
low.  But when I reversed the Wp and Ws parameters, it resulted in an 
object with an empty $type instead of $type being high.  I looked at 
the source code and found an obvious reason why:


   if (length(Wp) == 2) {
   warning(buttord seems to overdesign bandpass and bandreject
   filters)
   if (any(stop))
   type = stop
   else type = pass
   }
   else {
   ## here we set to high or low, as expected
   if (any(stop))
   type = high
   else type = low
   }
   ## here we arbitrarily override the type if there is a stop band
   defined...why?
   if (any(stop))
   type = 

Thank you for any explanation you can provide.

M

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


[R] How to manipulate the time data without the date?

2008-11-06 Thread tedzzx

Hi,all

I only got the time data such as:
tms-c(19:30:23,18:39:10.)

I want to manipulate this time series data. For example, plus one second(or
minute) or minus one second

This data only has the time(h:m:s), without the date. I know that there are
chron package, ISOPix class and the timeDate class, but all these class need
the input of date. 

How can we manipulate the time data without the date?

Thanks advance

Ted
-- 
View this message in context: 
http://www.nabble.com/How-to-manipulate-the-time-data-without-the-date--tp20365370p20365370.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] FW: [rkward-devel] questions on RKWard

2008-11-06 Thread Horace Tso
Thought I should copy the list with Matthieu's response.

H

-Original Message-
From: Matthieu Stigler [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2008 8:29 PM
To: Horace Tso; [EMAIL PROTECTED]
Subject: Re: [rkward-devel] questions on RKWard


some answer only for the third question: do you have the package
r-doc-html installed? (on ubuntu check with dpkg -l r-*) this is maybe
the solution

Horace Tso a écrit :
 Folks,

 I'm making progress moving from Windows to Linux and have RKward up
 and running. I read somewhere that Rkward's supposed to be the Tinn-R
 for linux and Tinn-R has worked out great for me. So naturally I'd
 like to do the following, if possible,

 1. How to ask Rkward not to load the last saved image. Right now
 whenever it starts, it loads an image from some obscure corner of my
 directory. I can't quite figure out where it gets that image from. On
 the command line, I can do --no-restore. But there seems to be no
 place to sneak in these command line options under Rkward.  A startup
 config file hidden somewhere?

 2. Customize CTRL-keys. Just out of the box, many menu options do not
 have a control key associated with them. Any way to pick my favorite key?

 3. I'm used to typing ?command on the R-console and get a HTML help
 page pops up. But when I do that, a shockingly large window comes up
 and complains in many words about some error which I can't quite
 figure out what it's saying (sorry don't have linux in front of me
 right now).

 4. I see there is an 'Output' tab by default. But command results are
 sent to R-console, and nothing seems to happen in 'Output'.

 I have R 2.7.1 running under KDE on openSUSE 10.3.

 TIA.

 Horace
 

 -
 This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
 Build the coolest Linux based applications with Moblin SDK  win great prizes
 Grand prize is a trip for two to an Open Source event anywhere in the world
 http://moblin-contest.org/redirect.php?banner_id=100url=/
 

 ___
 RKWard-devel mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/rkward-devel


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


Re: [R] How to manipulate the time data without the date?

2008-11-06 Thread Prof Brian Ripley

Why not give it an arbitrary date such 2008-01-01?

On Thu, 6 Nov 2008, tedzzx wrote:



Hi,all

I only got the time data such as:
tms-c(19:30:23,18:39:10.)

I want to manipulate this time series data. For example, plus one second(or
minute) or minus one second

This data only has the time(h:m:s), without the date. I know that there are
chron package, ISOPix class and the timeDate class, but all these class need
the input of date.


And in base R there is POSIXct.


How can we manipulate the time data without the date?


Not really, as DST changes mean which day does matter.  But all other days 
will be the same.


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

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


Re: [R] How to manipulate the time data without the date?

2008-11-06 Thread Gabor Grothendieck
On Thu, Nov 6, 2008 at 12:10 PM, tedzzx [EMAIL PROTECTED] wrote:

 Hi,all

 I only got the time data such as:
 tms-c(19:30:23,18:39:10.)

 I want to manipulate this time series data. For example, plus one second(or
 minute) or minus one second

 This data only has the time(h:m:s), without the date. I know that there are
 chron package, ISOPix class and the timeDate class, but all these class need
 the input of date.

The chron package's times class does not have that restriction:

 library(chron)
 times(10:34:21)
[1] 10:34:21

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread anna freni sterrantino
Hi Cruz
you don't need to assign dimension or classes to your objects.
It's easier if you  do like this


 a=c(0,1,2,4,1,1)
 length(a)
[1] 6
 b=matrix(a,3,2,byrow=T)
 b
 [,1] [,2]
[1,]01
[2,]24
[3,]11
of course you can change the colnames and assign what 
you prefer

 colnames(b)=c(x,y)

but if you try to recall x with
b$x 
is not going to work
like that, 
you have two option:

1. switch  form matrix to a dataframe:
 c=as.data.frame(b)
 c
  x y
1 0 1
2 2 4
3 1 1
 c$x
[1] 0 2 1

no problems.

2. Can get the column  x
on the matrix b as
b[,1]
[1] 0 2 1

just giving the  position.


Hope that this helps.

Best Regards
Anna



 Anna Freni Sterrantino
Ph.D Student 
Department of Statistics
University of Bologna, Italy
via Belle Arti 41, 40124 BO.





Da: cruz [EMAIL PROTECTED]
A: r-help@r-project.org
Inviato: Giovedì 6 novembre 2008, 17:22:42
Oggetto: [R] How to avoid $ operator is invalid for atomic vectors

Hi,

I am writing this in a wrong way, can someone please correct me?

 A - matrix()
 length(A) - 6
 dim(A) - c(3,2)
 colnames(A) - c(X,Y)
 A
  X  Y
[1,] NA NA
[2,] NA NA
[3,] NA NA
 A$X
Error in A$X : $ operator is invalid for atomic vectors


Thanks,
cruz

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



  Unisciti alla community di Io fotografo e video, il nuovo corso di 
fotografia di Gazzetta dello sport:

[[alternative HTML version deleted]]

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


[R] Strang line while plotting failure curves

2008-11-06 Thread Lu, Jiang
Dear R helper,

I encountered a problem when I tried to plot the cumulative failure rate
(i.e. 1 - survival probability). I have used the following code to plot. The
scenario is that patients are randomized to different treatment arm (rev in
the code), the PCI revascularization was monitored over 5 years.

#R code
 testfit - survfit(Surv(pcifu,pci)~rev,data=subproc)
 testfit$surv - 1 - testfit$surv
 testfail - plot(testfit, mark.time=FALSE,col=1:2, main='Failure Rate')
#End of R code

I arbitarily replaced testfit$surv by computing 1 minus the original
survival rate. So far so good. However, when I plot the manipulated
testfit, there is a vertical line plotted at x=0, y=0:1. I checked
testfit$time and testfit$surv, nothing weird there. I am very confused where
the vertical line at starting point of time 0 came from. How can I get rid
of it?

Would you pleae help me with this? Thanks a lot!

Jiang

[[alternative HTML version deleted]]

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of anna freni 
 sterrantino
 Sent: Thursday, November 06, 2008 10:00 AM
 To: cruz; r-help@r-project.org
 Subject: Re: [R] How to avoid $ operator is invalid for 
 atomic vectors
 
 Hi Cruz
 you don't need to assign dimension or classes to your objects.
 It's easier if you  do like this
 
 
  a=c(0,1,2,4,1,1)
  length(a)
 [1] 6
  b=matrix(a,3,2,byrow=T)
  b
  [,1] [,2]
 [1,]01
 [2,]24
 [3,]11
 of course you can change the colnames and assign what 
 you prefer
 
  colnames(b)=c(x,y)
 
 but if you try to recall x with
 b$x 
 is not going to work
 like that, 
 you have two option:
 
 1. switch  form matrix to a dataframe:
  c=as.data.frame(b)
  c
   x y
 1 0 1
 2 2 4
 3 1 1
  c$x
 [1] 0 2 1
 
 no problems.
 
 2. Can get the column  x
 on the matrix b as
 b[,1]
 [1] 0 2 1
 
 just giving the  position.
 
 
 Hope that this helps.
 
 Best Regards
 Anna
 
 
 
  Anna Freni Sterrantino
 Ph.D Student 
 Department of Statistics
 University of Bologna, Italy
 via Belle Arti 41, 40124 BO.
 
 
 
 
 
 Da: cruz [EMAIL PROTECTED]
 A: r-help@r-project.org
 Inviato: Giovedì 6 novembre 2008, 17:22:42
 Oggetto: [R] How to avoid $ operator is invalid for atomic vectors
 
 Hi,
 
 I am writing this in a wrong way, can someone please correct me?
 
  A - matrix()
  length(A) - 6
  dim(A) - c(3,2)
  colnames(A) - c(X,Y)
  A
   X  Y
 [1,] NA NA
 [2,] NA NA
 [3,] NA NA
  A$X
 Error in A$X : $ operator is invalid for atomic vectors
 
 
 Thanks,
 cruz
 

You can also use the column name with the matrix

A[,'X']

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204
 
 

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


Re: [R] How to manipulate the time data without the date?

2008-11-06 Thread John Kane
Does this help?

library(chron)
tms-c(19:30:23,18:39:10)
mytimes - times(tms)
mytimes[1]-mytimes[2]


--- On Thu, 11/6/08, tedzzx [EMAIL PROTECTED] wrote:

 From: tedzzx [EMAIL PROTECTED]
 Subject: [R]  How to manipulate the time data without the date?
 To: r-help@r-project.org
 Received: Thursday, November 6, 2008, 12:10 PM
 Hi,all
 
 I only got the time data such as:
 tms-c(19:30:23,18:39:10.)
 
 I want to manipulate this time series data. For example,
 plus one second(or
 minute) or minus one second
 
 This data only has the time(h:m:s), without the date. I
 know that there are
 chron package, ISOPix class and the timeDate class, but all
 these class need
 the input of date. 
 
 How can we manipulate the time data without the date?
 
 Thanks advance
 
 Ted
 -- 



  __
[[elided Yahoo spam]]

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


Re: [R] Simple rep() question duplicating times and dates.

2008-11-06 Thread John Kane

Hi Solveig, 
Thanks very much, it's a nice solution and one I had not even begun to think 
about.  I MUST learn more about dates!


--- On Thu, 11/6/08, Solveig Mimler [EMAIL PROTECTED] wrote:

 From: Solveig Mimler [EMAIL PROTECTED]
 Subject: Re: Simple rep() question duplicating times and dates.
 To: [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Received: Thursday, November 6, 2008, 7:06 AM
 Hi John,
 
 I had the same problem yesterday and solved it like
 following:
 
 seq(ISOdate(Year,Month,Day,Hour), by=hour,
 length=24*365)
 
 for example: seq(ISOdate(2005,1,1,0), by=hour,
 length=8760)
 
 Regards,
 Solveig 
 
 
 EIFER
 Europäisches Institut für Energieforschung
 Institut européen de recherche sur l'énergie
 European Institute for Energy Research
 
 Solveig Mimler 
 Sociologist M.A.
 Emmy-Noether-Straße 11
 76131 Karlsruhe
 Tel: +49 721 6105 1351
 Fax: +49 721 6105 1332
 mailto: [EMAIL PROTECTED]
 _
 
 EIFER
 Europäisches Institut für Energieforschung, 
 Electricité de France / Universität Karlsruhe (TH) EWIV 
 Sitz der europäischen wirtschaftlichen
 Interessenvereinigung: Karlsruhe
 Handelsregister: Amtsgericht Karlsruhe HRA 4823 
 Vorsitzender des Aufsichtsrats: Prof. Dr.-Ing. RAINER
 REIMERT
 Geschäftsführer: Dr. FREDERIC BARON (Institutsleiter) 
 _
 
 This e-mail and any attachment is for authorized use by the
 intended
 recipient(s) only. It may contain proprietary material,
 confidential
 information and/or be subject to legal privilege. It should
 not be copied,
 disclosed to, retained or used by any other party.
 If you are not an intended recipient then please promptly
 delete this 
 e-mail and any attachment and all copies and inform the
 sender.
 _
 
 Message: 27
 Date: Wed, 5 Nov 2008 16:14:19 +0100
 From: Gustaf Rydevik
 [EMAIL PROTECTED]
 Subject: Re: [R] Simple rep() question duplicating times
 and dates.
 To: [EMAIL PROTECTED]
 Cc: R R-help [EMAIL PROTECTED]
 Message-ID:
 
 [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1
 
 On Wed, Nov 5, 2008 at 4:02 PM, John Kane
 [EMAIL PROTECTED] wrote:
 
  I want to create a data.frame of time and date for a
 year.  I started 
 with the idea of simply producing two vectors (time and
 date)
 
  The first part ( time) is easy.
   rep(1:24, 365)
 
  But how do I get a series of 24 dates for O1 January
 2005 and repeat 
 this to 31 December 2005.
 
  It should be easy but I don't see it.
 
  Thanks
 
 
 Hi John,
 
 ?Date leads you to (among other things) ?seq.Date.
 
 Something like this should work:
 
 time-rep(1:24, 365)
 dates-seq(as.Date(01012005,format=%d%m%Y),as.Date(31122005,format=%d%m%Y),by=1)
 TimeFrame-data.frame(time)
 TimeFrame$dates-rep(dates,each=24)
 
 
 Regards,
 Gustaf
 -- 
 Gustaf Rydevik, M.Sci.
 tel: +46(0)703 051 451
 address:Essingetorget 40,112 66 Stockholm, SE
 skype:gustaf_rydevik
 
 
 
 --
 
 Message: 28
 Date: Wed, 5 Nov 2008 07:30:31 -0800 (PST)
 From: John Kane [EMAIL PROTECTED]
 Subject: Re: [R] Simple rep() question duplicating times
 and dates.
 To: Gustaf Rydevik [EMAIL PROTECTED]
 Cc: R R-help [EMAIL PROTECTED]
 Message-ID:
 [EMAIL PROTECTED]
 Content-Type: text/plain; charset=us-ascii
 
 I don't have R on this machine to try it but it looks
 good to me.  I had 
 even got as far as seq() but completely missed the use of
 each. 
 
 Thanks very much.
 
 --- On Wed, 11/5/08, Gustaf Rydevik
 [EMAIL PROTECTED] wrote:
 
  From: Gustaf Rydevik [EMAIL PROTECTED]
  Subject: Re: [R] Simple rep() question duplicating
 times and dates.
  To: [EMAIL PROTECTED]
  Cc: R R-help
 [EMAIL PROTECTED]
  Received: Wednesday, November 5, 2008, 10:14 AM
  On Wed, Nov 5, 2008 at 4:02 PM, John Kane
  [EMAIL PROTECTED] wrote:
  
   I want to create a data.frame of time and date
 for a
  year.  I started with the idea of simply producing two
  vectors (time and date)
  
   The first part ( time) is easy.
rep(1:24, 365)
  
   But how do I get a series of 24 dates for O1
 January
  2005 and repeat this to 31 December 2005.
  
   It should be easy but I don't see it.
  
   Thanks
  
  
  Hi John,
  
  ?Date leads you to (among other things) ?seq.Date.
  
  Something like this should work:
  
  time-rep(1:24, 365)
  
 dates-seq(as.Date(01012005,format=%d%m%Y),as.Date(31122005,format=%d%m%Y),by=1)
  TimeFrame-data.frame(time)
  TimeFrame$dates-rep(dates,each=24)
  
  
  Regards,
  Gustaf
  -- 
  Gustaf Rydevik, M.Sci.
  tel: +46(0)703 051 451
  address:Essingetorget 40,112 66 Stockholm, SE
  skype:gustaf_rydevik


  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what you know at http://ca.answers.yahoo.com

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

Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread cruz
Thanks for all the responses, they are all very helpful:)

 you don't need to assign dimension or classes to your objects.
 It's easier if you  do like this

this is something that really bothers me, when I need to define an
object which i will later fill with data, the dimension of this object
should not be fixed because it will grow...

so in MATLAB, i.e. we define x = [ ],
what about in R?

Thanks,
cruz

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


Re: [R] mean computation for external data

2008-11-06 Thread John Kane
?mean

kurtosis
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/110186.html
 


--- On Thu, 11/6/08, christabel_jane prudencio [EMAIL PROTECTED] wrote:

 From: christabel_jane prudencio [EMAIL PROTECTED]
 Subject: [R] mean computation for external data
 To: r-help@r-project.org
 Received: Thursday, November 6, 2008, 6:07 AM
 I have an external data (.txt) for
 annual peak flood. The first column is the year, second
 column is the
 observation date, and the last is the observed discharge.
 My task is to
 calculate the mean, skewness and kurtosis of the said data.
 I was advised to use
 read.table() to read the entire data. Please help me on how
 to perform the
 required computation. I am obviously a new user of this
 statistical software.
 Thank you so much for helping.
 
 Christabel Jane P. Rubio
 M.S. Student
 Water Resources Engineering
 Dept. of Construction  Environmental Engineering 
 Kongju National University (Cheonan Campus)
 102th Office,The 5th Engineering Building,
 275, Budae-dong, Cheonan-si, Chungnam-do, 330-717, Korea
 TEL : +82-41-521-9316 
 FAX : +82-41-568-0287
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


  __
[[elided Yahoo spam]]

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


Re: [R] Strang line while plotting failure curves

2008-11-06 Thread Frank E Harrell Jr

Lu, Jiang wrote:

Dear R helper,

I encountered a problem when I tried to plot the cumulative failure rate
(i.e. 1 - survival probability). I have used the following code to plot. The
scenario is that patients are randomized to different treatment arm (rev in
the code), the PCI revascularization was monitored over 5 years.

#R code
 testfit - survfit(Surv(pcifu,pci)~rev,data=subproc)
 testfit$surv - 1 - testfit$surv
 testfail - plot(testfit, mark.time=FALSE,col=1:2, main='Failure Rate')
#End of R code

I arbitarily replaced testfit$surv by computing 1 minus the original
survival rate. So far so good. However, when I plot the manipulated
testfit, there is a vertical line plotted at x=0, y=0:1. I checked
testfit$time and testfit$surv, nothing weird there. I am very confused where
the vertical line at starting point of time 0 came from. How can I get rid
of it?

Would you pleae help me with this? Thanks a lot!

Jiang



Also see the survplot.* functions in the Design package and their fun 
argument, e.g., fun=function(y)1-y


Frank


[[alternative HTML version deleted]]

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




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

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread cruz

 Does that answer your question?


Thanks:)

I received one from Erin:

x - NULL

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread Jeffrey Horner

cruz wrote on 11/06/2008 12:16 PM:

Thanks for all the responses, they are all very helpful:)


you don't need to assign dimension or classes to your objects.
It's easier if you  do like this


this is something that really bothers me, when I need to define an
object which i will later fill with data, the dimension of this object
should not be fixed because it will grow...

so in MATLAB, i.e. we define x = [ ],
what about in R?


?numeric, ?character, others probably...

x - numeric()

x[10] - 42
print(x)
 [1] NA NA NA NA NA NA NA NA NA 42

Does that answer your question?

Jeff



Thanks,
cruz

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



--
http://biostat.mc.vanderbilt.edu/JeffreyHorner

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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread John Kane

Does this help
(mylist - list(NULL))


(mylist[[3]] - data.frame(a=1:4, b=letters[1:4]))
mylist

(mylist[[2]] - matrix(1:12, nrow=4))

mylist


--- On Thu, 11/6/08, cruz [EMAIL PROTECTED] wrote:

 From: cruz [EMAIL PROTECTED]
 Subject: Re: [R] How to avoid $ operator is invalid for atomic vectors
 To: r-help@r-project.org
 Received: Thursday, November 6, 2008, 1:16 PM
 Thanks for all the responses, they are all very helpful:)
 
  you don't need to assign dimension or classes to
 your objects.
  It's easier if you  do like this
 
 this is something that really bothers me, when I need to
 define an
 object which i will later fill with data, the dimension of
 this object
 should not be fixed because it will grow...
 
 so in MATLAB, i.e. we define x = [ ],
 what about in R?
 
 Thanks,
 cruz
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


  __
[[elided Yahoo spam]]

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


[R] PCA

2008-11-06 Thread Noela Sánchez
I need perform PCA analyst with a matrix with more variables than units.

The princomp command don't match with this matrix.

Anybody knows a good command to do it?

-- 
Noela

[[alternative HTML version deleted]]

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


Re: [R] PCA

2008-11-06 Thread stephen sefick
would you please provide a dummy example that explains your problem.
Then maybe I can help you.
thanks

Stephen

On Thu, Nov 6, 2008 at 1:42 PM, Noela Sánchez [EMAIL PROTECTED] wrote:
 I need perform PCA analyst with a matrix with more variables than units.

 The princomp command don't match with this matrix.

 Anybody knows a good command to do it?

 --
 Noela

[[alternative HTML version deleted]]

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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

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


Re: [R] PCA

2008-11-06 Thread Prof Brian Ripley

?princomp refers you to prcomp for that case:

 'princomp' only handles so-called R-mode PCA, that is feature
 extraction of variables.  If a data matrix is supplied (possibly
 via a formula) it is required that there are at least as many
 units as variables.  For Q-mode PCA use 'prcomp'.


On Thu, 6 Nov 2008, Noela Sánchez wrote:


I need perform PCA analyst with a matrix with more variables than units.

The princomp command don't match with this matrix.

Anybody knows a good command to do it?

--
Noela


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


Re: [R] PCA

2008-11-06 Thread Jorge Ivan Velez
Hi Noela,

Take a loot at ?prcomp

HTH,

Jorge



On Thu, Nov 6, 2008 at 1:42 PM, Noela Sánchez [EMAIL PROTECTED] wrote:

 I need perform PCA analyst with a matrix with more variables than units.

 The princomp command don't match with this matrix.

 Anybody knows a good command to do it?

 --
 Noela

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] mean computation for external data

2008-11-06 Thread Jorge Ivan Velez
Hi Christabel,
Take a look at the function basicStats in the fBasics package. Here is an
example:

library(fBasics)
set.seed(123)
x=rnorm(20,24,2)
basicStats(x)
#x
#nobs 20.00
#NAs   0.00
#Minimum  20.066766
#Maximum  27.573826
#1. Quartile  23.012892
#3. Quartile  25.097454
#Mean 24.283248
#Median   24.239970
#Sum 485.664952
#SE Mean   0.434989
#LCL Mean 23.372805
#UCL Mean 25.193690
#Variance  3.784311
#Stdev 1.945331
#Skewness -0.062495
#Kurtosis -0.547891


HTH,

Jorge



On Thu, Nov 6, 2008 at 6:07 AM, christabel_jane prudencio 
[EMAIL PROTECTED] wrote:




 I have an external data (.txt) for
 annual peak flood. The first column is the year, second column is the
 observation date, and the last is the observed discharge. My task is to
 calculate the mean, skewness and kurtosis of the said data. I was advised
 to use
 read.table() to read the entire data. Please help me on how to perform the
 required computation. I am obviously a new user of this statistical
 software.
 Thank you so much for helping.

 Christabel Jane P. Rubio
 M.S. Student
 Water Resources Engineering
 Dept. of Construction  Environmental Engineering
 Kongju National University (Cheonan Campus)
 102th Office,The 5th Engineering Building,
 275, Budae-dong, Cheonan-si, Chungnam-do, 330-717, Korea
 TEL : +82-41-521-9316
 FAX : +82-41-568-0287

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


[[alternative HTML version deleted]]

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


Re: [R] PCA

2008-11-06 Thread Noela Sánchez
My matrix have 436 registers and 518 variables. I need to do a PCA analyst.

Usually I use princomp command to perform PCA analyst, but this time i can't
because of my variables are more than my registers.

2008/11/6 stephen sefick [EMAIL PROTECTED]

 would you please provide a dummy example that explains your problem.
 Then maybe I can help you.
 thanks

 Stephen

 On Thu, Nov 6, 2008 at 1:42 PM, Noela Sánchez [EMAIL PROTECTED] wrote:
  I need perform PCA analyst with a matrix with more variables than units.
 
  The princomp command don't match with this matrix.
 
  Anybody knows a good command to do it?
 
  --
  Noela
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis




-- 
Noela
Grupo de Recursos Marinos y Pesquerías
Universidad de A Coruña

[[alternative HTML version deleted]]

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


Re: [R] Methods dispatch and inheritance R.oo

2008-11-06 Thread Henrik Bengtsson
Hi,

On Thu, Nov 6, 2008 at 2:12 AM, Yuri Volchik [EMAIL PROTECTED] wrote:

 Thanks for reply Henrik, seems obvious now.
 Can child class (B) access argument of the parent class, i.e. can i rewrite
 definition of the class B as

 setConstructorS3(ClassB, function() {
  extend(ClassA(), ClassB,
.size2 = A
  );
 })

 it didn't work for me, so guess i'm doing smth wrong and i couldn't find any
 reference on inheritance in the help files.

Note that 'A' is only an argument (~= local variable) of the
constructor function ClassA().  There is no way the (constructor)
function ClassB() can know about that one; compare to:

foo - function(A=1) {
}

bar - function(B=2) {
  # Inside here you have no access to 'A' in foo(), regardless if you
call foo() or not.
}

So, I'm not sure what you are trying to do in reality.  Note, since
the value of 'A' is already assigned in ClassA() and part of its
returned object, then it will also be part of the returned object from
ClassB(), so you don't really have to assign 'A' again.

I think this is a better example.  See if you want to achive what
ClassB or ClassC do:

setConstructorS3(ClassA, function(A=0) {
 extend(Object(), ClassA,
   A = A
 );
})

 objA - ClassA();
 ll(objA)
  member data.class dimension objectSize
1  Anumeric 1 32
 objA$A
[1] 0


setConstructorS3(ClassB, function(A=0, B=1) {
 extend(ClassA(A=A), ClassB,
   B = B
 );
})

 objB - ClassB(A=1, B=2);
 ll(objB);
  member data.class dimension objectSize
1  Anumeric 1 32
2  Bnumeric 1 32
 objB$A
[1] 1
 objB$B
[1] 2


If you really want to access a field from a superclass inside the
constructor function, you have to first get the object returned by the
constructor of the superclass, and then from that object retrieve the
field:

setConstructorS3(ClassC, function(B=1) {
 this - extend(ClassA(), ClassC,
   B = B
 );
 this$copyOfA - this$A;
 this;
})

 objC - ClassC(B=3);
 ll(objC);
  member data.class dimension objectSize
1  Anumeric 1 32
2  Bnumeric 1 32
 objC$A
[1] 0
 objC$B
[1] 3


Note, there is nothing magic going on inside Object(), extend() or
any other R.oo methods.  Most of the things you can think of as
regular lists and functions.  The new think is that objects inheriting
from the Object class store their values inside an environment, which
is why the object behaves as it is passed by reference.

Hope this helps

/Henrik


 --
 View this message in context: 
 http://www.nabble.com/Methods-dispatch-and-inheritance-R.oo-tp20339090p20358341.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] How to avoid $ operator is invalid for atomic vectors

2008-11-06 Thread Patrick Burns

cruz wrote:

Thanks for all the responses, they are all very helpful:)

  

you don't need to assign dimension or classes to your objects.
It's easier if you  do like this



this is something that really bothers me, when I need to define an
object which i will later fill with data, the dimension of this object
should not be fixed because it will grow...

so in MATLAB, i.e. we define x = [ ],
what about in R?
  


It is generally best in R to create an object as the size
it will end up being and then make assignments into the
object.

But using the theory of giving you enough rope to hang
yourself, you can do things like:

x - numeric(0)

or

x - NULL


Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)


Thanks,
cruz

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





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


[R] new plotrix and prettyR

2008-11-06 Thread Jim Lemon

Hi all,
I'm noting the appearance of new versions of plotrix and prettyR as I 
found a bug in the brkdn function that messed up the order of 
value.labels if they had been imported from an SPSS data file. For 
anyone using brkdn, please upgrade to the new version of prettyR 
(1.3-5) if you are importing SPSS data files. If anyone discovers other 
problems, you know where to complain. Thanks.


Jim

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


Re: [R] wireframe

2008-11-06 Thread Greg Snow
Look at the rotate.wireframe function in the TeachingDemos package.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Bill Szkotnicki
 Sent: Thursday, November 06, 2008 8:39 AM
 To: r-help@r-project.org
 Subject: [R] wireframe

 I've been using lattice/wireframe succesfully to visualize some data.
 I have one question.
 I want to be able to change the viewpoint ( i.e. rotate the plotted
 figure a bit left or right or up and down )
 Is there a way to do that?
 Or is there some other package around that could help?
 Thanks.

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

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


Re: [R] PCA

2008-11-06 Thread Lucke, Joseph F
Neola
I'm a bit rusty on this, but I believe you can conduct on singular-value 
decomposition on the 436 by 518 matrix.  The squares of your singular values 
(max of 436, 518-436 will be zero) will be your eigenvalues, the same as in the 
PC analysis.  The post-eigenvectors will be your components.  As I have said, 
my knowledge is not completely trustworthy at this point, but SVD would be 
worth looking into.
Joe 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Noela Sánchez
Sent: Thursday, November 06, 2008 1:10 PM
To: stephen sefick
Cc: r-help@r-project.org
Subject: Re: [R] PCA

My matrix have 436 registers and 518 variables. I need to do a PCA analyst.

Usually I use princomp command to perform PCA analyst, but this time i can't 
because of my variables are more than my registers.

2008/11/6 stephen sefick [EMAIL PROTECTED]

 would you please provide a dummy example that explains your problem.
 Then maybe I can help you.
 thanks

 Stephen

 On Thu, Nov 6, 2008 at 1:42 PM, Noela Sánchez [EMAIL PROTECTED] wrote:
  I need perform PCA analyst with a matrix with more variables than units.
 
  The princomp command don't match with this matrix.
 
  Anybody knows a good command to do it?
 
  --
  Noela
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/p
 osting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are 
 so little or so large that all they really do for us is puff us up and 
 make us feel like gods.  We are mammals, and have not exhausted the 
 annoying little problems of being mammals.

-K. 
 Mullis




--
Noela
Grupo de Recursos Marinos y Pesquerías
Universidad de A Coruña

[[alternative HTML version deleted]]

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


[R] Confidence limits for the parameter of the Poisson distribution

2008-11-06 Thread Hoang Trong Minh Tuan
Hi all,
  So far I only know one way to get the confidence limit for the Poisson
distribution is to use the look-up table given by the 2 parameter (the
number of observation x and the confidence level, e.g. 95%) and the table is
limit by the maximum number of observations (x = 50).
  I know the formula to compute the CI, however, mathematically it is not
easy to do it. So, anyone know an R function to do this. Thanks

Tuan.

[[alternative HTML version deleted]]

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


Re: [R] replicate and as.matrix: different behaviour between batch and non-batch mode

2008-11-06 Thread Charles C. Berry

On Thu, 6 Nov 2008, Oliver Bandel wrote:


Hello Charles,



[snip]


dim( as.matrix(replicate(10, sample(x, 3) )  ) )

[1]  3 10

dim( as.matrix(replicate(10, sample(x, 2) )  ) )

[1]  2 10

dim( as.matrix(replicate(10, sample(x, 1) )  ) )

[1] 10  1



=


So, the behaviour is the same...
...but is not really that fine. :(

...how could I avoid the necessity of the transposition
of the matrix in the case of only one sample?



use
matrix( your.result , nc = n.replicates )

or

dim( your.result ) - c( n.samples, n.replicates )

instead of as.matrix( your.result )

HTH,

Chuck



I mean, it's not extremely a problem,
because there are not many loops aroud it,
but it looks somehow ugly. :(

Ciao,
 Oliver

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] Strang line while plotting failure curves

2008-11-06 Thread Lu, Jiang
Thank you very much, Frank. I installed Design package and tried survplot().


#R code
 
survplot(testfit,time.inc=365.25,xaxt='n',xlim=c(0,1826.25),ylim=c(0,1),conf='none',
  fun=function(y)1-y,label.curves=list(keys=c('Med','Rev')),
  abbrev.label=TRUE,n.risk=TRUE)
# End of R code

I have achieved my goal with the 'fun' argument you advised. But I have a
difficult time to do the following fine tune.

1. The X axis scale was labeled as 'Days'. I would like something like
'xscale=365.25' in plot.survfit to put time into Years and label the ticks
from 0 to 5, instead of from 0 to 1826.25 by each 365.25 increment. I tried
xaxt='n' as you can see in the code above. Then I noticed that xaxt='n' only
work for plot(survfit), not in survplot(). Any advice how to change the tick
label using survplot()?

2. The n.risk was beautifully printed for each specified time point along
the x axis. However, since I am plotting the failure rate, the n.risk looks
busy with the failure rate curves. Is there a way to move the n.risk to the
top of the plot where there are lots of space?

3. I also tried label.curves=list(). It is very convenient. The curves are
labeled and the legend is created as well. Could I only keep the curve label
and get rid of the legend since the legend is not so necessary once the
curve is labeled. How do you think?

I really appreciate any help you give.

Best regards,

Jiang Lu

Statistician
Department of Epidemiology
University of Pittsburgh



On Thu, Nov 6, 2008 at 1:21 PM, Frank E Harrell Jr [EMAIL PROTECTED]
 wrote:

  Lu, Jiang wrote:

 Dear R helper,

 I encountered a problem when I tried to plot the cumulative failure rate
 (i.e. 1 - survival probability). I have used the following code to plot.
 The
 scenario is that patients are randomized to different treatment arm (rev
 in
 the code), the PCI revascularization was monitored over 5 years.

 #R code
  testfit - survfit(Surv(pcifu,pci)~rev,data=subproc)
  testfit$surv - 1 - testfit$surv
  testfail - plot(testfit, mark.time=FALSE,col=1:2, main='Failure Rate')
 #End of R code

 I arbitarily replaced testfit$surv by computing 1 minus the original
 survival rate. So far so good. However, when I plot the manipulated
 testfit, there is a vertical line plotted at x=0, y=0:1. I checked
 testfit$time and testfit$surv, nothing weird there. I am very confused
 where
 the vertical line at starting point of time 0 came from. How can I get rid
 of it?

 Would you pleae help me with this? Thanks a lot!

 Jiang


 Also see the survplot.* functions in the Design package and their fun
 argument, e.g., fun=function(y)1-y

 Frank

[[alternative HTML version deleted]]

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



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


[[alternative HTML version deleted]]

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


[R] Umlaut read from csv-file

2008-11-06 Thread Heinz Tuechler

Dear All!

Reading character strings containing an umlaut 
from a csv-file I find a (to me) surprising 
behaviour in R 2.8.0, that I did not notice in R 2.7.2.

A comparison by == results in FALSE, while grep does find the aggreement.
See the example below.
The crucial line is x==div 1-2 Veränderungen, 
with the result [1] FALSE in R 2.8.0 but

[1] TRUE in R 2.7.2.

Thank you in advance for your help

Heinz Tüchler

# in R 2.8.0 patched

x0 - div 1-2 Veränderungen # define a character string

write.csv(x0, 'chr.csv', row.names=FALSE) # write a csv-file with one line
rm(x0)

x - read.csv('chr.csv', skip=0, header=TRUE, as.is=TRUE)$x # read in csv-file
x
x==div 1-2 Veränderungen
 [1] FALSE
grep(div 1-2 Veränderungen, x)
 [1] 1
grep(div 1-2 Veränderungen, x, value=TRUE)
 [1] div 1-2 Veränderungen

unlink('chr.csv') # delete file

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = Patched
 major = 2
 minor = 8.0
 year = 2008
 month = 11
 day = 04
 svn rev = 46830
 language = R
 version.string = R version 2.8.0 Patched (2008-11-04 r46830)

Windows XP (build 2600) Service Pack 2

Locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252

Search Path:
 .GlobalEnv, package:stats, package:graphics, 
package:grDevices, package:utils, 
package:datasets, package:methods, Autoloads, package:base



# in R 2.7.2 patched


x0 - div 1-2 Veränderungen # define a character string

write.csv(x0, 'chr.csv', row.names=FALSE) # write a csv-file with one line
rm(x0)

x - read.csv('chr.csv', skip=0, header=TRUE, as.is=TRUE)$x # read in csv-file
x
x==div 1-2 Veränderungen
 [1] TRUE
grep(div 1-2 Veränderungen, x)
 [1] 1
grep(div 1-2 Veränderungen, x, value=TRUE)
 [1] div 1-2 Veränderungen

unlink('chr.csv') # delete file

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = Patched
 major = 2
 minor = 7.2
 year = 2008
 month = 09
 day = 02
 svn rev = 46486
 language = R
 version.string = R version 2.7.2 Patched (2008-09-02 r46486)

Windows XP (build 2600) Service Pack 2

Locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252

Search Path:
 .GlobalEnv, package:stats, package:graphics, 
package:grDevices, package:utils, 
package:datasets, package:methods, Autoloads, package:base


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


Re: [R] Confidence limits for the parameter of the Poisson distribution

2008-11-06 Thread Charles C. Berry

On Thu, 6 Nov 2008, Hoang Trong Minh Tuan wrote:


Hi all,
 So far I only know one way to get the confidence limit for the Poisson
distribution is to use the look-up table given by the 2 parameter (the
number of observation x and the confidence level, e.g. 95%) and the table is
limit by the maximum number of observations (x = 50).
 I know the formula to compute the CI, however, mathematically it is not
easy to do it. So, anyone know an R function to do this. Thanks



A 'marriage-of-convenience' between uniroot() and ppois() should do it.

HTH,

Chuck




Tuan.

[[alternative HTML version deleted]]

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] Confidence limits for the parameter of the Poisson distribution

2008-11-06 Thread Rolf Turner


On 7/11/2008, at 9:26 AM, Hoang Trong Minh Tuan wrote:


Hi all,
  So far I only know one way to get the confidence limit for the  
Poisson

distribution is to use the look-up table given by the 2 parameter (the
number of observation x and the confidence level, e.g. 95%) and the  
table is

limit by the maximum number of observations (x = 50).
  I know the formula to compute the CI, however, mathematically it  
is not

easy to do it. So, anyone know an R function to do this. Thanks

Tuan.


You may find the URL

http://www.math.mcmaster.ca/peter/s743/poissonalpha.html

useful.

cheers,

Rolf Turner

P.S.  The foregoing URL discusses the issues in terms of a *single*
observation.  Note that if X_1, ..., X_n are i.i.d. Poisson(lambda)
then Y = X_1 + ... + X_n is Poisson(n*lambda).

Note that the ``exact'' confidence limits are very conservative.

R. T.

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


[R] nls: Fitting two models at once?

2008-11-06 Thread Martin Ballaschk
Hello,

I'm still a newbie user and struggling to automate some analyses from
SigmaPlot using R. R is a great help for me so far!

But the following problem makes me go nuts.

I have two spectra, both have to be fitted to reference data. Problem: the
both spectra are connected in some way: the stoichiometry of coefficients
cytf.v/cytb.v is 1/2.
{{In the SigmaPlot workflow one has to copy the two spectra into one column
beneath each other and the  two spectra are somehow treated as one curve -
like in http://home.arcor.de/ballaschk/cytbf-help/sigmaplot%20formula.png}}

Can anybody help? :(

I tried to condense everything to the minimum R script below to give an
impression of what I'm talking about.

Martin




# Minimal R script reading remote data for convenience

### READ IN DATA
# first spectrum
asfe - read.table(http://home.arcor.de/ballaschk/cytbf-help/asfe.csv;)[, 1];
# second spectrum
dias - read.table(http://home.arcor.de/ballaschk/cytbf-help/dias.csv;)[, 1];

# reference data for fit, wavelength = wl
ref - read.table(http://home.arcor.de/ballaschk/cytbf-help/reference.csv;,
sep=\t, dec=., header=T);
attach(ref);

### FITTING, problem: 2*cytf.v == cytb.v

# fit first spectrum to two reference spectra
asfe.fit -
nls(
asfe ~ (cytf.v * 28) * CYTF + hp.v * B559HP,
start = list(cytf.v = 0.5, hp.v = 0.03) # arbitrary
);

# fit second spectrum to three reference spectra
dias.fit -
nls(
dias ~ (cytb.v * 24.6 * 2) * CYTB6 + lp.v * B559LP + c550.v * C550,
start = list(cytb.v = 1, lp.v = 1, c550.v = 1) # arbitrary
);


# draw stuff
plot(
1, 2,
type=n,
xlim = c(540, 575),
ylim=c(-0.002, 0.008),
);

# first spectrum and fit
lines(wl, asfe, type=b, pch=19); # solid circles
lines(wl, fitted(asfe.fit), col = red);

# second spectrum and fit
lines(wl, dias, type=b);
lines(wl, fitted(dias.fit), col = blue);

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


Re: [R] Strang line while plotting failure curves

2008-11-06 Thread Frank E Harrell Jr

Lu, Jiang wrote:
Thank you very much, Frank. I installed Design package and tried 
survplot().
 
#R code

 
survplot(testfit,time.inc=365.25,xaxt='n',xlim=c(0,1826.25),ylim=c(0,1),conf='none',
  fun=function(y)1-y,label.curves=list(keys=c('Med','Rev')),
  abbrev.label=TRUE,n.risk=TRUE)
# End of R code
 
I have achieved my goal with the 'fun' argument you advised. But I have 
a difficult time to do the following fine tune.
 
1. The X axis scale was labeled as 'Days'. I would like something like 
'xscale=365.25' in plot.survfit to put time into Years and label the 
ticks from 0 to 5, instead of from 0 to 1826.25 by each 365.25 
increment. I tried xaxt='n' as you can see in the code above. Then I 
noticed that xaxt='n' only work for plot(survfit), not in survplot(). 
Any advice how to change the tick label using survplot()?


There are options to do all that, described in the documentation.

 
2. The n.risk was beautifully printed for each specified time point 
along the x axis. However, since I am plotting the failure rate, the 
n.risk looks busy with the failure rate curves. Is there a way to move 
the n.risk to the top of the plot where there are lots of space?


May be best to move it to the bottom margin.  See the help file.

 
3. I also tried label.curves=list(). It is very convenient. The curves 
are labeled and the legend is created as well. Could I only keep the 
curve label and get rid of the legend since the legend is not so 
necessary once the curve is labeled. How do you think?


Should be options for that too.

Frank

 
I really appreciate any help you give.
 
Best regards,
 
Jiang Lu
 
Statistician

Department of Epidemiology
University of Pittsburgh


 
On Thu, Nov 6, 2008 at 1:21 PM, Frank E Harrell Jr 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Lu, Jiang wrote:

Dear R helper,

I encountered a problem when I tried to plot the cumulative
failure rate
(i.e. 1 - survival probability). I have used the following code
to plot. The
scenario is that patients are randomized to different treatment
arm (rev in
the code), the PCI revascularization was monitored over 5 years.

#R code
 testfit - survfit(Surv(pcifu,pci)~rev,data=subproc)
 testfit$surv - 1 - testfit$surv
 testfail - plot(testfit, mark.time=FALSE,col=1:2,
main='Failure Rate')
#End of R code

I arbitarily replaced testfit$surv by computing 1 minus the original
survival rate. So far so good. However, when I plot the manipulated
testfit, there is a vertical line plotted at x=0, y=0:1. I checked
testfit$time and testfit$surv, nothing weird there. I am very
confused where
the vertical line at starting point of time 0 came from. How can
I get rid
of it?

Would you pleae help me with this? Thanks a lot!

Jiang


Also see the survplot.* functions in the Design package and their
fun argument, e.g., fun=function(y)1-y

Frank

   [[alternative HTML version deleted]]

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



-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine

Department of Biostatistics   Vanderbilt University





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

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


[R] Estimating mean and standard deviation of lognormal distribution between two points

2008-11-06 Thread Jeremy Beaulieu
This is more of a statistical question.  Let's say I have two numbers.  One
is a lower bound and the other is a point estimate to the right of the lower
bound.  Now, let's say I want to be able to estimate the mean and standard
deviation of a lognormal distribution, where 95% of the density falls within
the range of the lower bound and the point estimate.  Concomitantly, can an
exponential distribution be described in the same fashion?

Any help would be greatly appreciated.

JB

[[alternative HTML version deleted]]

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


[R] Looking for suggestions on how to debug pvm/snow proc's

2008-11-06 Thread Peter Waltman
Hi All -

I'm running a faily long script that uses rpvm  snowFT to spawn off
multiple processes with the 'clusterApplyFT' function.

Specifically, what happens is that the head node generates a number of seed
clusters that are then spawned off to the pvm cluster (in this case, nodes
on a 4 dual-core machine) using clusterApplyFT to apply a function to each
seed cluster that optimizes each seed cluster and returns the new, optimized
clusters.

In some cases, however, clusterApplyFT will return try-error's for some of
the clusters.  Since it's a try-error, I know there's no way to get a
traceback (I've tried using clusterApplyFT to call traceback with no luck),
but even when I switch to snow instead of snowFT, I still can't figure out a
way to get a traceback for the failed clusters.

Any suggestions?

Thanks!

Peter

[[alternative HTML version deleted]]

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


Re: [R] PCA

2008-11-06 Thread Pedro Mardones
try prcomp instead of princomp

On Thu, Nov 6, 2008 at 3:20 PM, Lucke, Joseph F
[EMAIL PROTECTED] wrote:
 Neola
 I'm a bit rusty on this, but I believe you can conduct on singular-value 
 decomposition on the 436 by 518 matrix.  The squares of your singular values 
 (max of 436, 518-436 will be zero) will be your eigenvalues, the same as in 
 the PC analysis.  The post-eigenvectors will be your components.  As I have 
 said, my knowledge is not completely trustworthy at this point, but SVD would 
 be worth looking into.
 Joe

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Noela Sánchez
 Sent: Thursday, November 06, 2008 1:10 PM
 To: stephen sefick
 Cc: r-help@r-project.org
 Subject: Re: [R] PCA

 My matrix have 436 registers and 518 variables. I need to do a PCA analyst.

 Usually I use princomp command to perform PCA analyst, but this time i can't 
 because of my variables are more than my registers.

 2008/11/6 stephen sefick [EMAIL PROTECTED]

 would you please provide a dummy example that explains your problem.
 Then maybe I can help you.
 thanks

 Stephen

 On Thu, Nov 6, 2008 at 1:42 PM, Noela Sánchez [EMAIL PROTECTED] wrote:
  I need perform PCA analyst with a matrix with more variables than units.
 
  The princomp command don't match with this matrix.
 
  Anybody knows a good command to do it?
 
  --
  Noela
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/p
 osting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K.
 Mullis




 --
 Noela
 Grupo de Recursos Marinos y Pesquerías
 Universidad de A Coruña

[[alternative HTML version deleted]]

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

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


[R] replacing values in a vector

2008-11-06 Thread Iain Gallagher
Hello list.

I have a vector of values:

eg

 head(diff_mirs_list)
[1] hsa-miR-26b hsa-miR-26b hsa-miR-23a hsa-miR-27b hsa-miR-29a
[6] hsa-miR-29b

and I would like to conditionally replace each value in this vector with a 
number defined in a dataframe:

 fc
 Probe ave.fc
1   hsa-let-7a   1.28
2  hsa-miR-100   1.47
3  hsa-miR-125a-5p   1.31
4   hsa-miR-140-3p   1.28
5  hsa-miR-143   1.98
6  hsa-miR-193a-3p   1.37
7 hsa-miR-193b   1.48
8  hsa-miR-195   1.16
9  hsa-miR-214   1.22
10 hsa-miR-23a   1.21
11 hsa-miR-26b   1.13
12 hsa-miR-27b   1.37
13 hsa-miR-29a   1.24
14 hsa-miR-29b   1.69
15 hsa-miR-30b   1.16
16 hsa-miR-424   1.42
17  hsa-miR-768-3p   1.48
18  hsa-miR-886-3p   1.43
19 hsa-miR-933   1.23

ie every hsa-let-7a in the diff_mirs_list is replaced by 1.28, hsa-miR-100 by 
1.47 etc etc

I have tried to make a loop to use gsub eg

 for (i in 1:nrow(fc)){
+ test-gsub(fc[i,1], fc[i,2], diff_mirs_list)
}

but this obviously passes the unchanged vector to gsub each time and so I get 
back my 'test' vector with only hsa-miR-933 changed. Could someone help me out 
with this please. 

Thanks

Iain

 sessionInfo()
R version 2.8.0 (2008-10-20) 
i486-pc-linux-gnu 

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

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

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


  1   2   >