[R] proportional curves

2007-10-30 Thread raymond chiruka
hie
  
  I know this might not be the right forum but can anyone tell me what  
parameters i can possibly use to generate proportional  survival  curves using 
rweibull(n,shape,scale).
  if I plot the curves and they do not cross does it neccesarily mean that they 
are proprotional.
  thanks
  
  
 __



[[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 segmented package

2007-10-30 Thread vito muggeo
Dear Maura,
For package-specific questions, it is probably advisable to contact 
privately the author..

BTW:
  However I cannot understand if a break-point per independent variable
  (regressor) is handled when there are many independent variables in the
  model, or if segmented can handle many breakpoints for the same
  independent variable (time in my case) ... ?

Yes, both the statements are true. Virtually segmented is able to handle 
GLMs with any number of (linear) exaplanatory variables + any number of 
`segmented' variables, and multiple breakpoints are allowed for *each* 
`segmented' variable. See the relevant help files.

All the best,

vito


PS: I am sending you some further documentation via off-list

best,
vito


Maura E Monville ha scritto:
 Most of the data sets I'm dealing with exhibit a time trend.
 We would like to get rid of the time trend.
 The plot shows in some cases a monotonic increase of the dependent variable
 with time. This is the easiest case.
 In some other cases the plot shows a time trend where the dependent variable
 changes slope 4-5 times along the observations measurement period.
 
 I've attempted a segmented regression and estimated the break-point
 empirically. This is a tedious error-prone process.
 I just found out that R includes a package, called segmented,  which can
 estimate the break-point discriminating between two regression models.
 I have browsed through the on-line documentation. It is stated multiple
 break-points are supported by segmented.
 However I cannot understand if a break-point per independent variable
 (regressor) is handled when there are many independent variables in the
 model, or if segmented can handle many breakpoints for the same
 independent variable (time in my case) ... ?
 
 I would greatly appreciate some explanations and suggestions on the use of
 segmented.
 
 Thank you very much in advance.
 
 Regards,
 

-- 

Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612

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

2007-10-30 Thread leeznar
Dear R-helper,

I have subject 1, 2, 3 and formulation S, MF, MM.  I
have a problem in calculating AUC.  The AUC (0~t) in
formulation MF and MM were miscalculated, but I don’t
know where my problem is.  Here is my code and output.

test-function( InVVTestindex, 
  separateWindows=TRUE)
 {  
   for( i in 1:length(unique
(InVVTestindex$subject))){
   x-InVVTestindex$time[InVVTestindex$subject==i]
  
y-InVVTestindex$concentration[InVVTestindex$subject==i]
  
v-InVVTestindex$formulation[InVVTestindex$subject==i]
   w-InVVTestindex$pH[InVVTestindex$subject==i]
   #calculate AUC  
   add-function(time,concentration){
   auc-0
   for(i in 2:length(time)) {
  
auc[i]-1/2*(time[i]-time[i-1])*(concentration[i]+concentration[i-1])
   auc[i]-auc[i]+auc[i-1]
   }
   return(list(auc=auc))
   }
   add-add(x,y)
   AUC-add$auc
   #Output   
   cat( Output \n)  
   output-data.frame(w,i,v,x,y,AUC)
  
colnames(output)-list(pH,subject,formulation,time,concentration,AUC(0~t))
   show(output)  
   cat(\n\n)
  }
 }


 Output 
pH subject formulation time concentration 
AUC(0~t)
1  6.8   1   S  0.0  0.00   
0.
2  6.8   1   S  0.5110.26  
27.5650
3  6.8   1   S  1.0116.17  
84.1725
4  6.8   1   S  1.5130.20 
145.7650
5  6.8   1   S  2.0145.77 
214.7575
6  6.8   1   S  3.0123.75 
349.5175
7  6.8   1   S  4.0123.05 
472.9175
8  6.8   1   S  5.0 82.35 
575.6175
9  6.8   1   S  6.0 48.62 
641.1025
10 6.8   1   S  8.0 26.51 
716.2325
11 6.8   1   S 10.0  3.04 
745.7825
12 6.8   1   S 12.0  2.87 
751.6925
13 6.8   1   S 24.0  2.74 
785.3525
14 6.8   1  MF  0.0 0.00  752.4725
15 6.8   1  MF  0.5 91.67 
775.3900
16 6.8   1  MF  1.0216.78 
852.5025
17 6.8   1  MF  1.5179.91 
951.6750
18 6.8   1  MF  2.0187.02
1043.4075
19 6.8   1  MF  3.0176.15
1224.9925
20 6.8   1  MF  4.0171.24
1398.6875
21 6.8   1  MF  5.0157.83
1563.2225
22 6.8   1  MF  6.0149.15
1716.7125
23 6.8   1  MF  8.0142.18
2008.0425
24 6.8   1  MF 10.0107.56
2257.7825
25 6.8   1  MF 12.0 86.37
2451.7125
26 6.8   1  MF 24.0  9.30
3025.7325
27 6.8   1  MM  0.0  0.00
2914.1325
28 6.8   1  MM  0.5114.18
2942.6775
29 6.8   1  MM  1.0160.72
3011.4025
30 6.8   1  MM  1.5152.28
3089.6525
31 6.8   1  MM  2.0125.05
3158.9850
32 6.8   1  MM  3.0118.97
3280.9950
33 6.8   1  MM  4.0123.26
3402.1100
34 6.8   1  MM  5.0143.46
3535.4700
35 6.8   1  MM  6.0137.00
3675.7000
36 6.8   1  MM  8.0 91.48
3904.1800
37 6.8   1  MM 10.0 52.46
4048.1200
38 6.8   1  MM 12.0 15.39
4115.9700
39 6.8   1  MM 24.0  8.00
4256.3100


Best regards,
Hsin-Ya Lee

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] postscript(), used from a pre R-2.6.0 workspace

2007-10-30 Thread John Maindonald
I find that if start R-2.6.0 in a workspace with no .RData file,
load one of my workspaces from R-2.5.1 or earlier into R-2.6.0,
and then before doing anything else type postscript(file=z.ps),
I get::

  ls()
character(0)
  load(url(http://www.maths.anu.edu.au/~johnm/r/test5.RData;))
  postscript(file=z.ps)
Error in postscript(file = z.ps) : Invalid font type
In addition: Warning messages:
1: closing unused connection 3 
(gzcon(http://www.maths.anu.edu.au/~johnm/r/test5.RData) 
)
2: In postscript(file = z.ps) :
   font family not found in PostScript font database
3: In postscript(file = z.ps) :
   font family not found in PostScript font database

Or R may be started in a workspace with such a .RData file,
or with a .RData file from R-2.5.1 or earlier.

This behavior persists even if I take such an image file, load it,
clear the workspace, and save it.  An instance of such a .RData
file has the url:
http://www.maths.anu.edu.au/~johnm//r/test5.RData

It makes no difference whether I load the file into R-2.6.0
on a MacOS X or Windows system, or whether I use the current
R-patched (2007-10-27 r43288).  I do not know whether the
source of the original .RData file matters, or how it may depend
on what I have done in that earlier workspace.

For moving my .RData files across without messing up use of
postscript() [or pdf()],  a workaround is to dump the contents of the
earlier workspace, then start R in a working directory whose
.RData file, if any, has the proper R-2.6.0 pedigree, and source
the dumped file.  I do not want to have to directly run the function
that creates the database each time I start a session.

Has anyone else hit this?

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics  Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plotting question: how to plot SNP location data?

2007-10-30 Thread Lauri.Nikkinen
Hello,

I would like to plot specific SNPs with their exact locations on a
chromosome. Based on my genotyping results I would like to separate
these SNPs in three different categories: 1, 2 and 3 and use different
colours to represent these categories. The script below generates the
sample data. I can plot these with the image function using the
following:

val - 1:3
samp - sample(val, 100, replace=TRUE)
z - matrix(samp, nrow=20, ncol=4, byrow=TRUE)
SNP - 1:20
siblings - 1:4

opar - par(cex=0.7)
image(SNP, siblings, z, col=c(blue, red, black), axes=FALSE,
ann=FALSE)
axis(1, at=1:20, labels=paste(rep(SNP, 20), 1:20), las=2)
axis(2, at=1:4)
mtext(sibling, 2, line=3)
title(main=Specific SNPs in Chr 1)
par(opar)

In addition to having the data for the above colour matrix, I also have
data including the exact locations of the SNPs on a chromosome (snploc).
I would like to plot the SPNs using the colour codes from above (z) and
include the exact locations of each SNP. Is it possible to do that using
the image-function? Below I have tried to solve the problem using the
basic plot function but I cannot include the colors to that plot. How
would that be possible?

colnames(z) - c(sib1,sib2,sib3,sib4)
rownames(z) - paste(rep(SNP, 20), 1:20)
z.t - t(z)

#snploc$location represents the location of the SNP in the chromosome
snploc - data.frame(SNP=paste(rep(SNP, 20), 1:20),
location=c(4.2,5.8,6.9,3,8,7,5,4,3.6,4.3,4.6,6.6,5.2,6,9,9.4,12,16,14,12
.3))
snploc$SNP - factor(snploc$SNP, levels=unique(snploc$SNP))
temp - as.data.frame(sapply(levels(snploc$SNP), function(x){   z.t[,x]
- snploc$location[snploc$SNP == x];
 
z.t[,x]
 
}))


temp1 - as.list(temp)
#Plot the location of the SNP
x11()
for (i in names(temp1)) {
  opar - par(new=TRUE)
  plot(temp1[[i]], 1:4, pch=|, ann=FALSE, col=blue,
xlim=c(0, 20), ylim=c(1,4), yaxp=c(1,4,3))
  par(opar)
  }
mtext(SNP location, 1, line=3)
mtext(sibling, 2, line=3)
opar - par(cex=0.7)
axis(3, at=snploc$location, labels=snploc$SNP, las=3)
par(opar)

Originally my z.t data.frame has dimensios 33*4000 so looping through
this data.frame is tedious.

Thanks, 
Lauri

***
Lauri Nikkinen
Finnish Red Cross Blood Service
www.bloodservice.fi




[[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] postscript(), used from a pre R-2.6.0 workspace

2007-10-30 Thread Peter Dalgaard
John Maindonald wrote:
 I find that if start R-2.6.0 in a workspace with no .RData file,
 load one of my workspaces from R-2.5.1 or earlier into R-2.6.0,
 and then before doing anything else type postscript(file=z.ps),
 I get::

   ls()
 character(0)
   load(url(http://www.maths.anu.edu.au/~johnm/r/test5.RData;))
   postscript(file=z.ps)
 Error in postscript(file = z.ps) : Invalid font type
 In addition: Warning messages:
 1: closing unused connection 3 
 (gzcon(http://www.maths.anu.edu.au/~johnm/r/test5.RData) 
 )
 2: In postscript(file = z.ps) :
font family not found in PostScript font database
 3: In postscript(file = z.ps) :
font family not found in PostScript font database

 Or R may be started in a workspace with such a .RData file,
 or with a .RData file from R-2.5.1 or earlier.

 This behavior persists even if I take such an image file, load it,
 clear the workspace, and save it.  An instance of such a .RData
 file has the url:
 http://www.maths.anu.edu.au/~johnm//r/test5.RData

 It makes no difference whether I load the file into R-2.6.0
 on a MacOS X or Windows system, or whether I use the current
 R-patched (2007-10-27 r43288).  I do not know whether the
 source of the original .RData file matters, or how it may depend
 on what I have done in that earlier workspace.

 For moving my .RData files across without messing up use of
 postscript() [or pdf()],  a workaround is to dump the contents of the
 earlier workspace, then start R in a working directory whose
 .RData file, if any, has the proper R-2.6.0 pedigree, and source
 the dumped file.  I do not want to have to directly run the function
 that creates the database each time I start a session.

 Has anyone else hit this?
   
I get a slightly different scenario:

R

R version 2.6.0 (2007-10-03)

 load(url(http://www.maths.anu.edu.au/~johnm/r/test5.RData;))
 postscript(file=z.ps)
Error in postscript(file = z.ps) : failed to load encoding
In addition: Warning message:
In postscript(file = z.ps) : failed to load encoding file 'macRoman'
 ls(all=T)
 [1] .Last.projection.Last.value .PostScript.Options
 [4] .Provided   .Random.seed.Traceback
 [7] .call   .ess.lvsave .formula
[10] .map.range  .rdired.objects .required
[13] .rpart.parms.2  .rpart.parms.3  .rpart.parms.4
[16] .rpart.parms.5
 rm(.PostScript.Options)
 postscript(file=z.ps)
 


You might try and do likewise

-p

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] Query installing R on Mac OS X Leopard (new release)...

2007-10-30 Thread Prof Brian Ripley

MacOS X users, please note:

-
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

R Special Interest Group on Development for Mac OS X. This list might be 
used also for bug reports or feature requests on the R application for OS 
X.

-

which contains threads on this issue.

It's the best place for help on MacOS-specific problems (although I 
understand many MacOS users will have no idea what other OSes do, surely 
the installer and GUI console are clearly MacOS-specific).



On Tue, 30 Oct 2007, Rob Hodgkinson wrote:


Thanks to Mark, Moshe and David for helpful responses to my query on
Regression.

I am now trying to install R-2.6.0.dmg on my Macbook Pro running OS X 10.5
(ie Leopard) since last weeken, so far without issue.

At the prompt ³Installation Type² (after destination drive is selected) the
4 parts to be checked are all grayed out and so also is the (Install)
button.  I can¹t seem to continue nor work around this ?  I am wondering
whether this is related to Leopard (documentation says OK for Mac OS X
10.4.4 or higher).

Has anyone observed/worked around this problem please, or might suggest a
solution ?

Sorry again if the wrong forum, I saw no R/Install query group.
Thanks.../Rob

[[alternative HTML version deleted]]




--
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.


[R] axis title on two lines

2007-10-30 Thread Marcel Sandow
Hello,I am searching for the possibility to make a two lines axis title. This 
suggestion:ylab=expression(paste(log rate\n[ fluor.,inc. %.% cell^{-1} %.% 
sec^{-1}, ]))results in two lines left not centered and with a large gap.any 
suggestions.ThanksMarcel 

__

Marcel Sandow

Leibniz Institute of Marine Sciences - IFM-Geomar
Experimental Ecology: Foodwebs
Düsternbrooker Weg 20
24105 Kiel
Germany

Fon: +49-431-600-4404
Fax: +49-431-600-1515

Homepage: http://www.ifm-geomar.de
E-mail: [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.


Re: [R] postscript(), used from a pre R-2.6.0 workspace

2007-10-30 Thread Prof Brian Ripley
postscript() is supposed to read and write .PostScript.Options from a 
private environment, so one question is how .PostScript.Options got to be 
in the workspace: I suspect a much older version of R put it there, not 
least because it would seem to be using an encoding (and case) relevant 
to Classic MacOS.

There are a couple of 'inherits=FALSE' missing in postscript.R: one of 
them is stopping font initialization if .PostScript.Options exists on the 
search path.

On Tue, 30 Oct 2007, Peter Dalgaard wrote:

 John Maindonald wrote:
 I find that if start R-2.6.0 in a workspace with no .RData file,
 load one of my workspaces from R-2.5.1 or earlier into R-2.6.0,
 and then before doing anything else type postscript(file=z.ps),
 I get::

  ls()
 character(0)
  load(url(http://www.maths.anu.edu.au/~johnm/r/test5.RData;))
  postscript(file=z.ps)
 Error in postscript(file = z.ps) : Invalid font type
 In addition: Warning messages:
 1: closing unused connection 3 
 (gzcon(http://www.maths.anu.edu.au/~johnm/r/test5.RData)
 )
 2: In postscript(file = z.ps) :
font family not found in PostScript font database
 3: In postscript(file = z.ps) :
font family not found in PostScript font database

 Or R may be started in a workspace with such a .RData file,
 or with a .RData file from R-2.5.1 or earlier.

 This behavior persists even if I take such an image file, load it,
 clear the workspace, and save it.  An instance of such a .RData
 file has the url:
 http://www.maths.anu.edu.au/~johnm//r/test5.RData

 It makes no difference whether I load the file into R-2.6.0
 on a MacOS X or Windows system, or whether I use the current
 R-patched (2007-10-27 r43288).  I do not know whether the
 source of the original .RData file matters, or how it may depend
 on what I have done in that earlier workspace.

 For moving my .RData files across without messing up use of
 postscript() [or pdf()],  a workaround is to dump the contents of the
 earlier workspace, then start R in a working directory whose
 .RData file, if any, has the proper R-2.6.0 pedigree, and source
 the dumped file.  I do not want to have to directly run the function
 that creates the database each time I start a session.

 Has anyone else hit this?

 I get a slightly different scenario:

 R

 R version 2.6.0 (2007-10-03)
 
 load(url(http://www.maths.anu.edu.au/~johnm/r/test5.RData;))
 postscript(file=z.ps)
 Error in postscript(file = z.ps) : failed to load encoding
 In addition: Warning message:
 In postscript(file = z.ps) : failed to load encoding file 'macRoman'
 ls(all=T)
 [1] .Last.projection.Last.value .PostScript.Options
 [4] .Provided   .Random.seed.Traceback
 [7] .call   .ess.lvsave .formula
 [10] .map.range  .rdired.objects .required
 [13] .rpart.parms.2  .rpart.parms.3  .rpart.parms.4
 [16] .rpart.parms.5
 rm(.PostScript.Options)
 postscript(file=z.ps)



 You might try and do likewise

-p



-- 
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.


[R] Sweave line length

2007-10-30 Thread Keith Jones
Hello,

I am trying to add R code to my dissertation and the length of a line 
of text that Sweave generates is longer than the right margin in my 
dissertation.  I have found no way to tell Sweave how to set the line 
length.  I am using an iMac with tiger ver. 10.4.10, and R: ver. 
2.5.1.  Here is the R code that is longer than my right margin:

input to Sweave:
legend(topleft,c(obs, theo,hi,lo),lty = 
c(1,2,3,4),col=c(1,2,6,4,0), cex=1.5,pt.cex=c(3,6), bty='o',inset=.05)

output from Sweave:
  legend(topleft, c(obs, theo, hi, lo), lty = c(1, 2, 3, 
4), col = c(1,
+ 2, 6, 4, 0), cex = 1.5, pt.cex = c(3, 6), bty = o, inset = 0.05)

The line is about eleven (11) characters too long.

Thanks,

Keith Jones

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

2007-10-30 Thread Kevin E. Thorpe
Keith Jones wrote:
 Hello,
 
 I am trying to add R code to my dissertation and the length of a line 
 of text that Sweave generates is longer than the right margin in my 
 dissertation.  I have found no way to tell Sweave how to set the line 
 length.  I am using an iMac with tiger ver. 10.4.10, and R: ver. 
 2.5.1.  Here is the R code that is longer than my right margin:
 
 input to Sweave:
 legend(topleft,c(obs, theo,hi,lo),lty = 
 c(1,2,3,4),col=c(1,2,6,4,0), cex=1.5,pt.cex=c(3,6), bty='o',inset=.05)
 
 output from Sweave:
  legend(topleft, c(obs, theo, hi, lo), lty = c(1, 2, 3, 
 4), col = c(1,
 + 2, 6, 4, 0), cex = 1.5, pt.cex = c(3, 6), bty = o, inset = 0.05)
 
 The line is about eleven (11) characters too long.
 
 Thanks,
 
 Keith Jones
 

I'm not sure if it affects the echoed commands too, but inserting a code
chunk like


options(width=60)
@

(replace 60 with the width you need) controls the width of the R output.


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

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

2007-10-30 Thread Dieter Menne
Gang Chen gangchen at mail.nih.gov writes:

 
 Suppose I have a mixed-effects model where yij is the jth sample for  
 the ith subject:
 
 yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) +   
 beta5(IQ^2) + beta6(age*IQ)  + beta7(age^2*IQ)  +  beta8(age^3 *IQ)  
 +random intercepti + eij
 
 In R how can I get an F test against the null hypothesis of  
 beta6=beta7=beta8=0? In SAS I can run something like contrast  age*IQ  
 1, age^2*IQ 1, age^3 *IQ 1, but is there anything similar in R?

Check packages multcomp and gmodels for contrast tests that work with lme.

Dieter

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


Re: [R] Sweave line length

2007-10-30 Thread Duncan Murdoch
On 10/30/2007 8:55 AM, Kevin E. Thorpe wrote:
 Keith Jones wrote:
 Hello,
 
 I am trying to add R code to my dissertation and the length of a line 
 of text that Sweave generates is longer than the right margin in my 
 dissertation.  I have found no way to tell Sweave how to set the line 
 length.  I am using an iMac with tiger ver. 10.4.10, and R: ver. 
 2.5.1.  Here is the R code that is longer than my right margin:
 
 input to Sweave:
 legend(topleft,c(obs, theo,hi,lo),lty = 
 c(1,2,3,4),col=c(1,2,6,4,0), cex=1.5,pt.cex=c(3,6), bty='o',inset=.05)
 
 output from Sweave:
  legend(topleft, c(obs, theo, hi, lo), lty = c(1, 2, 3, 
 4), col = c(1,
 + 2, 6, 4, 0), cex = 1.5, pt.cex = c(3, 6), bty = o, inset = 0.05)
 
 The line is about eleven (11) characters too long.
 
 Thanks,
 
 Keith Jones
 
 
 I'm not sure if it affects the echoed commands too, but inserting a code
 chunk like
 
 
 options(width=60)
 @
 
 (replace 60 with the width you need) controls the width of the R output.

You can also set keep.source=TRUE as an Sweave option, in which case the 
  formatting of R code will match what you have in your source file.

Duncan Murdoch

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


[R] Some matrix and sandwich questions

2007-10-30 Thread Michael Ash
Dear R-help,

I have a four-part question about regression, matrices, and sandwich package.


1) In the sandwich package, I would like to better understand the
meat() function.
From the bread() documentation, for a simple OLS regression, bread() returns

(1/n * X'X)^(-1)

That is, for a simple regression (per the documentation on bread()):
MyLM - lm(y ~ x)
bread(MyLM)
solve(crossprod(cbind(1, x))) * length(y)
(The last two terms above produce the same output, the matrix described above.)

In terms of the basic data matrix and coefficients, what does meat()
return for a simple OLS regression?  (I don't know the term empirical
estimating functions from the documentation of meat(). Is this the
score vector set equal to zero?)


2) Is there an easy way to convert the right-hand side of a formula
into a matrix,

lm( y ~ x + factor(i) )

Is there an easy way to get a matrix like this:

X = cbind(vector of 1's, x, matrix of 1's and 0's for the dummy
variables based on i)

Obviously one could construct this by hand, but it seems as if the X
used for the last regression would be useful.



3) Is there an easy way, e.g., based on crossprod(), to compute a
weighted cross-product of a matrix with itself or of two matrices:

X'WX

X'WY

where W is a diagonal weighting matrix?
(This would be similar to the matrix accum commands in Stata if that
gives any useful guidance regarding the desired product.)


4) Is there a straightforward way to implement the computation of the
variance covariance matrix for two-step estimation per Murphy and
Topel (1985)?  That aim is the underlying reason for questions
(1)-(3).


Thank you very much for your consideration.

Best,
Michael

-- 
Michael Ash, Associate Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email [EMAIL PROTECTED]
http://people.umass.edu/maash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Some matrix and sandwich questions

2007-10-30 Thread Michael Ash
Dear R-help,

I have a four-part question about regression, matrices, and sandwich package.


1) In the sandwich package, I would like to better understand the
meat() function.
From the bread() documentation, for a simple OLS regression, bread() returns

(1/n * X'X)^(-1)

That is, for a simple regression (per the documentation on bread()):
MyLM - lm(y ~ x)
bread(MyLM)
solve(crossprod(cbind(1, x))) * length(y)
(The last two terms above produce the same output, the matrix described above.)

In terms of the basic data matrix and coefficients, what does meat()
return for a simple OLS regression?  (I don't know the term empirical
estimating functions from the documentation of meat(). Is this the
score vector set equal to zero?)


2) Is there an easy way to convert the right-hand side of a formula
into the X matrix used for the regresssion:

lm( y ~ x + factor(i) )

Is there an easy way to get a matrix like this:

X = cbind(vector of 1's, x, matrix of 1's and 0's for the dummy
variables based on i)

Obviously one could construct this by hand, but it seems as if the X
used for the  regression would be useful.



3) Is there an easy way, e.g., based on crossprod(), to compute a
weighted cross-product of a matrix with itself or of two matrices:

X'WX

X'WY

where W is a diagonal weighting matrix?
(This would be similar to the matrix accum commands in Stata if that
gives any useful guidance regarding the desired entity.)


4) Is there a straightforward way to implement the computation of the
variance covariance matrix for two-step estimation per Murphy and
Topel (1985)?  That aim is the underlying reason for questions
(1)-(3).


Thank you very much for your consideration.

Best,
Michael

--
Michael Ash, Associate Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email [EMAIL PROTECTED]
http://people.umass.edu/maash

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

2007-10-30 Thread Keith Jones
Kevin,


Your suggestion got me on the right track.  The R command: 
option(width=50), sets the text width for R to 50 columns per line. 
When Sweave is run it breaks lines into 50 columns per line.  The 
only exception to this is when there is a command like 
setwd(/Users/keithjones/Documents/DataFiles/TexasTechhd/Dissertation 
II/MathematicaFiles/PointPatternAnalysis/)  it keeps the line in one 
piece.  It will not break a line in between the quotes in a line.  I 
will have to do that myself. 95% of the lines coded is a lot better 
then none.

Thanks,

Keith Jones

Keith Jones wrote:
  Hello,

  I am trying to add R code to my dissertation and the length of a line
  of text that Sweave generates is longer than the right margin in my
  dissertation.  I have found no way to tell Sweave how to set the line
  length.  I am using an iMac with tiger ver. 10.4.10, and R: ver.
  2.5.1.  Here is the R code that is longer than my right margin:

  input to Sweave:
  legend(topleft,c(obs, theo,hi,lo),lty =
  c(1,2,3,4),col=c(1,2,6,4,0), cex=1.5,pt.cex=c(3,6), bty='o',inset=.05)

  output from Sweave:
   legend(topleft, c(obs, theo, hi, lo), lty = c(1, 2, 3,
  4), col = c(1,
  + 2, 6, 4, 0), cex = 1.5, pt.cex = c(3, 6), bty = o, inset = 0.05)

  The line is about eleven (11) characters too long.

  Thanks,

  Keith Jones


I'm not sure if it affects the echoed commands too, but inserting a code
chunk like


options(width=60)
@

(replace 60 with the width you need) controls the width of the R output.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

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

2007-10-30 Thread John Kane
You might want to replace the xlab with mtext? 

aa - 1:10
plot(aa, xlab='')
mtext(label one \n label number two , side=1,
line=3)


--- Marcel Sandow [EMAIL PROTECTED] wrote:

 Hello,I am searching for the possibility to make a
 two lines axis title. This
 suggestion:ylab=expression(paste(log rate\n[
 fluor.,inc. %.% cell^{-1} %.% sec^{-1},
 ]))results in two lines left not centered and with
 a large gap.any suggestions.ThanksMarcel 
 

__
 
 Marcel Sandow
 
 Leibniz Institute of Marine Sciences - IFM-Geomar
 Experimental Ecology: Foodwebs
 Düsternbrooker Weg 20
 24105 Kiel
 Germany
 
 Fon: +49-431-600-4404
 Fax: +49-431-600-1515
 
 Homepage: http://www.ifm-geomar.de
 E-mail: [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.


Re: [R] axis title on two lines

2007-10-30 Thread Marcel Sandow
Thanksmtext is exactly what I am looking for. Using \n inside gave the same 
results as before. But using two independent mtext code lines with defferent 
line settings worked perfectly.- Ursprüngliche Nachricht -Von: John 
Kane Datum: Dienstag, Oktober 30, 2007 2:56 pmBetreff: Re: [R] axis title on 
two linesAn: Marcel Sandow , [EMAIL PROTECTED] You might want to replace the 
xlab with mtext?   aa - 1:10 plot(aa, xlab='') mtext(label one \n label 
number two , side=1, line=3)   --- Marcel Sandow  wrote:   Hello,I am 
searching for the possibility to make a  two lines axis title. This  
suggestion:ylab=expression(paste(log rate\n[  fluor.,inc. %.% cell^{-1} %.% 
sec^{-1},  ]))results in two lines left not centered and with  a large 
gap.any suggestions.ThanksMarcel 
__ 
   Marcel SandowLeibniz Institute of Marine Sciences - IFM-Geomar  
Experimental Ecology: Foodwebs  Düsternbrooker Weg 20  24105 Kiel  
GermanyFon: +49-431-600-4404  Fax: +49-431-600-1515Homepage: 
http://www.ifm-geomar.de  E-mail: [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.   Be 
smarter than spam. See how smart SpamGuard is at giving  junk email the boot 
with the All-new Yahoo! Mail at  http://mrd.mail.yahoo.com/try_beta?.intl=ca 

__

Marcel Sandow

Leibniz Institute of Marine Sciences - IFM-Geomar
Experimental Ecology: Foodwebs
Düsternbrooker Weg 20
24105 Kiel
Germany

Fon: +49-431-600-4404
Fax: +49-431-600-1515

Homepage: http://www.ifm-geomar.de
E-mail: [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] How to switch off accepting the shortcut of column names

2007-10-30 Thread P. Olsson
Dear R-users,

currently I am working with the R version 2.4.1.
I realized it has a feature,  which might be wonderful (as so many things in
R), but in this case might be a bit dangerous as well. It seems that columns
of a data frame can be called just by indicating the first letter of the
name of the column.

For example:
first_item - seq(1,10)
second_item - seq(11,20)
dat - data.frame(first_item, second_item)
names(dat)
# [1] first_item  second_item
dat$f
# [1]  1  2  3  4  5  6  7  8  9 10
dat$s
#  [1] 11 12 13 14 15 16 17 18 19 20

The good thing is, that if there is more than one column starting with the
same letter(s), more than one letter has to be given to call the column.
However, I would appreciate if I could choose an option in my workspace,
whether this type of shortcut is allowed or not.

Is there such an option?

Thanks for any potential hints.

Best wishes,

P. Olsson

[[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] Converting a string

2007-10-30 Thread Gang Chen
Thanks a lot for all who've provided help!

Yes the accusation of obfuscation is well-justified. Sorry I was not  
specific enough in the original post. But I'm lost at this point.  
What I want to do is this:

   contrast(ModelFit, list(Trust=T, Sex=levels(Model$Sex),  
Freq=levels(Model$Freq)), list(Trust=U, Sex=levels(Model$Sex),  
Freq=levels(Model$Freq)), type=average)

However the 2nd and 3rd arguments (the two list's) are pre-defined as  
one string of characters contr

  contr
[1] list(Trust=\T\,Sex=levels(Model$Sex),Freq=levels(Model 
$Freq)),list(Trust=\U\,Sex=levels(Model$Sex),Freq=levels(Model$Freq))

If I define

  args - strsplit(contr, 'list')
   args
[[1]]
[1] 
[2] (Trust=\T\,Sex=levels(Model$Sex),Freq=levels(Model$Freq)),
[3] (Trust=\U\,Sex=levels(Model$Sex),Freq=levels(Model$Freq))

The following still doesn't work as Bert Gunter has pointed out:

  contrast(fit.lme, eval(parse(text=args[[1]][2])), eval(parse 
(text=args[[1]][3])), type=average)
Error in parse(text = args[[1]][2]) : unexpected ',' in (Trust=T,

I also tried to use parse and eval for one inner layer further, but  
it didn't work either. So any better approach to dealing with the pre- 
defined string? Or giving up pre-defining the string?

Thanks,
Gang


On Oct 29, 2007, at 6:31 PM, Bert Gunter wrote:

 ...

 Of course if arg1 and arg2 are expressions (as characters strings)  
 that
 themselves contain commas, then this won't work. So the poster  
 does, indeed,
 seem to have achieved near obfuscation optimality.

 Of course this is yet another case where Lumley's principle (at  
 least I
 think it's his) holds: if you have to use eval(parse(...)) rethink --
 there's a better way.


 Bert Gunter
 Genentech Nonclinical Statistics


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 project.org] On
 Behalf Of Tim Calkins
 Sent: Monday, October 29, 2007 3:16 PM
 To: Gang Chen
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Converting a string

 Hi -

 you can split the string using strsplit().

 if your function uses Argument1 as a string, then you're all set.  If
 that's not the case then you can get() the object.

 myfunc - function(arg1, arg2) {
 + arg1 - get(arg1)
 + arg2 - get(arg2)
 ...
 }

 args - argument1,argument2 # easier with no   after the ,

 myfunc(strsplit(args)[[1]][1],strsplit(args)[[1]][2])


 This seems needlessly complicated: if obfuscation is your goal, you're
 well on your way to success.  Of course, that may be a feature of my
 solution -- obfuscation is often MY goal.

 HTH.

 tim

 On 10/30/07, Gang Chen [EMAIL PROTECTED] wrote:
 Thanks for the help.

 One case is like this: With function MyFunc(Argument1,
 Argument2, ...) I have the first two arguments defined as one
 variable tempstr, a string of characters, like

 tempstr - Argument1, Argument2

 The question is how I can feed tempstr into MyFunc to make it
 executable?

 Gang

 On Oct 29, 2007, at 5:42 PM, jim holtman wrote:

 Can you provide an example of your input and what you expect the
 output to be.  You can always use 'as.numeric'.

 On 10/29/07, Gang Chen [EMAIL PROTECTED] wrote:
 This must be very simple, but I'm stuck. I have a command line in R
 defined as a variable of a string of characters. How can I convert
 the variable so that I can execute it in R?

 Really appreciate any help,
 Gang

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



 -- 
 Tim Calkins
 0406 753 997

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

2007-10-30 Thread Emre Unal
Hi,

How can I analyze the data collected in database formatting (with labels)
rather than splitted by individual columns (almost in excel)?

For example (comma separated data);

Label,Value
Good,10
Bad,12
Good,15
Good,18
Good,12
Bad,15
Bad,10
etc...

ks.test or chisq.test can be done.
Splitting the data into new columns is not applicable cos' I'll use
R-integration in another software.



Thanks for your concern
Emre









-- 
---
Emre ÜNAL

[[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] bitmap patterns in R fill

2007-10-30 Thread Jonathan Lees

Is there a way in R to specify a bitmap pattern
and have it fill a region or polygon?
This feature is available in many MAC programs and
Adobe illustrator,
and I know how to do this
programming in postscript,
But I can't find anything in the documentation
relating how to do this in R.

Thanks,

Jonathan Lees

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

2007-10-30 Thread Thomas Lumley
On Tue, 30 Oct 2007, raymond chiruka wrote:

 hie

  I know this might not be the right forum but can anyone tell me what 
 parameters i can possibly use to generate proportional survival curves 
 using rweibull(n,shape,scale).

For the Weibull family, curves with different scale and the same shape 
have proportional hazards

  if I plot the curves and they do not cross does it neccesarily mean 
 that they are proprotional.

No.

-thomas

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

2007-10-30 Thread Antje
Hello,

unfortunately, I don't know a better subject. I would like to be very flexible 
in how to process my data.
Assume the following dataset:

par1 - seq(0,1,length.out = 100)
par2 - seq(1,100)
fac1 - factor(rep(c(group1, group2), each = 50))
fac2 - factor(rep(c(group3, group4, group5, group6), each = 25))

df - data.frame(par1, par2, fac1, fac2)

Now, I would like to calculate e.g. the sum for par1 grouping by fac1 and 
the mean and sd for par2 grouping by fac1.

I would like to determine this method as a string.

In the end, I would like to have something like this:

fac1.analysis:

   par1.sumpar2.mean par2.sd
group1xxx   xxx xxx
group2xxx   xxx xxx

fac2.analysis:

...

Does anybody have any idea how to realize it?

Antje

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

2007-10-30 Thread Luke Spadavecchia
Hi there,

I'm having trouble working out how to change the colors of polygon  
shading lines. If I plot a polygon with

polygon(poly,density=30,borders=gray(0.5))

I get gray borders but black shading lines; I have tried adding  
col=gray(0.5), bg=gray(0.5) and fg=gray(0.5), but no luck.
How can I change the colors of the shading? The help file doesn't  
seem to detail this, so any suggestions would be greatly appreciated.

Many thanks

Luke Spadavecchia

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

2007-10-30 Thread Prof Brian Ripley
On Tue, 30 Oct 2007, Luke Spadavecchia wrote:

 Hi there,

 I'm having trouble working out how to change the colors of polygon
 shading lines. If I plot a polygon with

 polygon(poly,density=30,borders=gray(0.5))

 I get gray borders but black shading lines; I have tried adding
 col=gray(0.5), bg=gray(0.5) and fg=gray(0.5), but no luck.

Really?  col should work, and does for me.

What will not work is 'borders' : it is 'border'.  A working example
based on the help page is

plot(c(1,9), 1:2, type=n)
polygon(1:9, c(2,1,2,1,NA,2,1,2,1), density=5, col=blue, border=gray(0.5))


 How can I change the colors of the shading? The help file doesn't
 seem to detail this, so any suggestions would be greatly appreciated.

 Many thanks

 Luke Spadavecchia

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

As it says, working code is expected.


-- 
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.


[R] Where can I find package segmented ?

2007-10-30 Thread Maura E Monville
I tried to install segmented from three different repositories but I keep
getting the following message on R window: ... Please, advice where to find
this package.

Thank you in advance.
Maura

 utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
Warning: package 'segmented' is in use and will not be installed
 utils:::menuInstallPkgs()
Warning: package 'segmented' is in use and will not be installed
 setRepositories()
 utils:::menuInstallPkgs()
Error in install.packages(NULL, .libPaths()[1], dependencies = NA, type =
type) :
no packages were specified
 chooseCRANmirror()
 utils:::menuInstallPkgs()
Warning: package 'segmented' is in use and will not be installed



-- 
Maura E.M

[[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] Some matrix and sandwich questions

2007-10-30 Thread Christian Ritz
Dear Michael,

as to questions 1) and 2):

The following article by A. Zeileis provides more details on the 
package 'sandwich':

http://www.jstatsoft.org/v16/i09/

(see also the references).


Use 'model.matrix' to construct a design matrix:

x - runif(10,0,10)
model.matrix(~x)



Christian

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 switch off accepting the shortcut of column names

2007-10-30 Thread Prof Brian Ripley
If you had updated your R before posting (as the posting guide suggested) 
you would have found such an option under ?options.  It was new in R 
2.6.0.

On Tue, 30 Oct 2007, P. Olsson wrote:

 Dear R-users,

 currently I am working with the R version 2.4.1.
 I realized it has a feature,  which might be wonderful (as so many things in
 R), but in this case might be a bit dangerous as well. It seems that columns
 of a data frame can be called just by indicating the first letter of the
 name of the column.

Well, this applies to lists not just data frame, and to partial matching 
not just the first letter.

If you want only exact matches I suggest you use other operators, e.g.
dat[[f]] will warn in 2.6.x and fail in R-devel.


 For example:
 first_item - seq(1,10)
 second_item - seq(11,20)
 dat - data.frame(first_item, second_item)
 names(dat)
 # [1] first_item  second_item
 dat$f
 # [1]  1  2  3  4  5  6  7  8  9 10
 dat$s
 #  [1] 11 12 13 14 15 16 17 18 19 20

 The good thing is, that if there is more than one column starting with the
 same letter(s), more than one letter has to be given to call the column.
 However, I would appreciate if I could choose an option in my workspace,
 whether this type of shortcut is allowed or not.

 Is there such an option?

 Thanks for any potential hints.

 Best wishes,

 P. Olsson

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

Please do.

-- 
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] Where can I find package segmented ?

2007-10-30 Thread Prof Brian Ripley
This is an FAQ: rw-FAQ 4.8.


On Tue, 30 Oct 2007, Maura E Monville wrote:

 I tried to install segmented from three different repositories but I keep
 getting the following message on R window: ... Please, advice where to find
 this package.

 Thank you in advance.
 Maura

 utils:::menuInstallPkgs()
 --- Please select a CRAN mirror for use in this session ---
 Warning: package 'segmented' is in use and will not be installed
 utils:::menuInstallPkgs()
 Warning: package 'segmented' is in use and will not be installed
 setRepositories()
 utils:::menuInstallPkgs()
 Error in install.packages(NULL, .libPaths()[1], dependencies = NA, type =
 type) :
no packages were specified
 chooseCRANmirror()
 utils:::menuInstallPkgs()
 Warning: package 'segmented' is in use and will not be installed





-- 
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] flexible processing

2007-10-30 Thread Henrique Dallazuanna
Hi,

No is the more elegant way


analysis -

lapply(c(fac1, fac2), function(x){

cbind.data.frame(par1.sum= do.call(rbind,lapply(lapply(split(df,
eval(parse(text=x))), [[, 1), sum)),

par2.mean=do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))),
[[, 2), mean)),

par2.sd= do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))), [[,
2), mean)))

})


On 30/10/2007, Antje [EMAIL PROTECTED] wrote:

 Hello,

 unfortunately, I don't know a better subject. I would like to be very
 flexible
 in how to process my data.
 Assume the following dataset:

 par1 - seq(0,1,length.out = 100)
 par2 - seq(1,100)
 fac1 - factor(rep(c(group1, group2), each = 50))
 fac2 - factor(rep(c(group3, group4, group5, group6), each = 25))

 df - data.frame(par1, par2, fac1, fac2)

 Now, I would like to calculate e.g. the sum for par1 grouping by fac1
 and
 the mean and sd for par2 grouping by fac1.

 I would like to determine this method as a string.

 In the end, I would like to have something like this:

 fac1.analysis:

   par1.sumpar2.mean par2.sd
 group1xxx   xxx xxx
 group2xxx   xxx xxx

 fac2.analysis:

 ...

 Does anybody have any idea how to realize it?

 Antje

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

2007-10-30 Thread Henrique Dallazuanna
analysis -

lapply(c(fac1, fac2), function(x){

cbind.data.frame(par1.sum= do.call(rbind,lapply(lapply(split(df,
eval(parse(text=x))), [[, 1), sum)),

par2.mean=do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))),
[[, 2), mean)),

par2.sd= do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))), [[,
2), sd)))

})


On 30/10/2007, Henrique Dallazuanna [EMAIL PROTECTED] wrote:

 Hi,

 No is the more elegant way


 analysis -

 lapply(c(fac1, fac2), function(x){

 cbind.data.frame(par1.sum= do.call(rbind,lapply(lapply(split(df,
 eval(parse(text=x))), [[, 1), sum)),

 par2.mean=do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))),
 [[, 2), mean)),

 par2.sd= do.call(rbind,lapply(lapply(split(df, eval(parse(text=x))),
 [[, 2), mean)))

 })


  On 30/10/2007, Antje [EMAIL PROTECTED] wrote:
 
  Hello,
 
  unfortunately, I don't know a better subject. I would like to be very
  flexible
  in how to process my data.
  Assume the following dataset:
 
  par1 - seq(0,1,length.out = 100)
  par2 - seq(1,100)
  fac1 - factor(rep(c(group1, group2), each = 50))
  fac2 - factor(rep(c(group3, group4, group5, group6), each =
  25))
 
  df - data.frame(par1, par2, fac1, fac2)
 
  Now, I would like to calculate e.g. the sum for par1 grouping by
  fac1 and
  the mean and sd for par2 grouping by fac1.
 
  I would like to determine this method as a string.
 
  In the end, I would like to have something like this:
 
  fac1.analysis:
 
par1.sumpar2.mean par2.sd
  group1xxx   xxx xxx
  group2xxx   xxx xxx
 
  fac2.analysis:
 
  ...
 
  Does anybody have any idea how to realize it?
 
  Antje
 
  __
  R-help@r-project.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.
 



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




-- 
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.


[R] calculate spatial distance

2007-10-30 Thread robert . ptacnik
Hi,
I have a set of locations defined by longitude and latitude (in degrees),
and want to calculate the spatial (or geographic) distance among all
locations.
I did not find such a function in the spatial-related packages. (I *cannot*
use 'dist', as I have geographic, not cartesian coordinates).
thanks!
Robert


 Robert Ptacnik
 Norwegian Institute for Water Research (NIVA)
Gaustadalléen 21
NO-0349 Oslo
mobile +47 982 277 81
FON NIVA +47 22 18 51 00
FAX  +47 22 18 52 00



--
NIVAs hovedkontor har flyttet til nye lokaler i CIENS - Forskningssenter
for miljø og samfunn; Gaustadalléen 21, 0349 Oslo. Meld deg på vårt
nyhetsbrev på www.niva.no
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] time difference error

2007-10-30 Thread Jojje Andersson
Hello!
I posted this question earlier but it seems that something went wrong, so I 
post it again.
I have a problem making a new variabel in a dataframe that consists of a time 
difference. It seems that the new variable gets into the dataframe but I cant 
look at it anymoore. Here is what happens.  tdiff- difftime(Kontrolltid, 
Starttid, units=auto)
 tdiff
 
Time differences in mins 
[1] 168  NA  NA 165 175 140 191 195 130 160 135 165 330 178 141  NA 119  90  70
[20]  99 115  70  65  90  90  65  90  75  85  93  52  75  60  90 105  70  65  60
[39]  85 110  65  60  98  62  71  61  41  80  67  83  72  73
attr(,tzone)[1]   givnona- data.frame(givnona, tdiff) names(givnona) 
[1] Vanna   Datum   StarttidKontrolltid Zo.Höger   
[6] Zo.Vänster  Mm.HögerMm.Vänster  tot.zo  tot.mm 
[11] tdiff   
 fix(givnona)
Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) : 
can only handle vector and factor elements   tdiff -structure(c(168, NA, NA, 
165, 175, 140, 191, 195, 130, 160, 135,
 165, 330, 178, 141, NA, 119, 90, 70, 99, 115, 70, 65, 90, 90, 65, 90, 75,
 85, 93, 52, 75, 60, 90, 105, 70, 65, 60, 85, 110, 65, 60, 98, 62, 71, 61, 41,
 80, 67, 83, 72, 73),
 tzone = , units = mins, class = difftime)  Any solution?cheers/Jojje
_


[[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] flexible processing

2007-10-30 Thread Gabor Grothendieck
Check out summaryBy in the doBy package:

 library(doBy)
 summaryBy(. ~ fac1, data = df, FUN = c(sum, mean, sd))[c(1,2,5,7)]
fac1 par1.sum par2.mean  par2.sd
1 group1 12.37374  25.5 14.57738
2 group2 37.62626  75.5 14.57738
 summaryBy(. ~ fac2, data = df, FUN = c(sum, mean, sd))[c(1,2,5,7)]
fac2  par1.sum par2.mean par2.sd
1 group3  3.03030313  7.3598
2 group4  9.34343438  7.3598
3 group5 15.65656663  7.3598
4 group6 21.96969788  7.3598

If you don't mind a few extra columns you can omit the [c(...)] part.

On Oct 30, 2007 10:18 AM, Antje [EMAIL PROTECTED] wrote:
 Hello,

 unfortunately, I don't know a better subject. I would like to be very flexible
 in how to process my data.
 Assume the following dataset:

 par1 - seq(0,1,length.out = 100)
 par2 - seq(1,100)
 fac1 - factor(rep(c(group1, group2), each = 50))
 fac2 - factor(rep(c(group3, group4, group5, group6), each = 25))

 df - data.frame(par1, par2, fac1, fac2)

 Now, I would like to calculate e.g. the sum for par1 grouping by fac1 and
 the mean and sd for par2 grouping by fac1.

 I would like to determine this method as a string.

 In the end, I would like to have something like this:

 fac1.analysis:

   par1.sumpar2.mean par2.sd
 group1xxx   xxx xxx
 group2xxx   xxx xxx

 fac2.analysis:

 ...

 Does anybody have any idea how to realize it?

 Antje

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] kernlab/ ksvm: class.weights prob.model in binary classification

2007-10-30 Thread Dominik Gallus
Hello list,

I am faced with a two-class classification problem with highly asymetric
class sizes (class one: 99%, class two: 1%). 
I'd like to obtain a class probability model, also introducing available
information on the class prior.

Calling kernlab/ksvm with the line 


ksvm_model1-ksvm(as.matrix(slides), as.factor(Class), class.weights= c(0
=99, 1 =1), prob.model=T)

or 

ksvm_model1-ksvm(as.matrix(slides), as.factor(Class), class.weights=wts,
prob.model=T)

with the named vector wts
 0  1 
99  1 

I get the following output:


Using automatic sigma estimation (sigest) for RBF or laplace kernel 
Error in inherits(x, factor) : only 0's may be mixed with negative
subscripts
In addition: Warning message:
Variable(s) `' constant. Cannot scale data. in: .local(x, ...) 


My data is a balanced set of 2500 examples, most of the 65 features are
binary with some real numbers in between.

I am using kernlab in version 0.9-5. 

Best regards, 
Dominik Gallus

--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Some matrix and sandwich questions

2007-10-30 Thread Michael Ash
On 10/30/07, Christian Ritz [EMAIL PROTECTED] wrote:

 Use 'model.matrix' to construct a design matrix:

 x - runif(10,0,10)
 model.matrix(~x)

Thanks!  That's super helpful.

 The following article by A. Zeileis provides more details on the
 package 'sandwich':
 http://www.jstatsoft.org/v16/i09/
 (see also the references).

This is also very helpful, although I still have questions about
terminology (because I am unfamiliar with the phrase empirical
estimating function).  Is the term empirical estimating function
equivalent to the expectation of the score set equal to zero where
score is the vector of first derivatives of the (log) likelihood
function?

I think that the paper is written at a higher level of abstraction
about estimators than I am used to.  I'd be grateful if someone could
briefly help me understand the Zeileis paper using either MLE, or even
OLS, *examples*.

Thanks very much.

Best,
Michael



-- 
Michael Ash, Associate Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email [EMAIL PROTECTED]
http://people.umass.edu/maash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Splitting up the micEcon package?

2007-10-30 Thread Arne Henningsen
Dear R Users:

The functions of our micEcon package [1,2] can be subdivided into three 
categories:
- microeconomic demand and firm models
- sample selection models (mainly selection())
- routines for (likelihood) maximisation (e.g. maxLik(), maxNR(), maxBHHH())
   (mainly used for ML estimation of sample selection models)

Although sample selection models are often used in microeconomic analyses, 
they are also used in several other disciplines. Therefore, we are unsure 
whether it is better to keep these different functionalities in the micEcon 
package or to move the sample selection models and the routines for 
(likelihood) maximisation into one or two new package(s) (increasing the long 
list of R packages even further).
What is the recommendation of the R community?

Thank you,
Ott  Arne

Note: We have asked this question already on R-devel five days ago [3], 
but we did not receive an answer yet.

References:
[1] http://cran.r-project.org/src/contrib/Descriptions/micEcon.html
[2] http://www.micecon.org/
[3] http://tolstoy.newcastle.edu.au/R/e3/devel/07/10/0222.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/


pgpzNvMq9FrkT.pgp
Description: PGP signature
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 switch off accepting the shortcut of column names

2007-10-30 Thread Julian Burgos
You cannot call a column on a dataframe using the first letter (or first 
few letters) if the letters match more than one name.  Extraction 
methods for data frames allow partially matching row names, but if the 
result is undefined you get NULL in return.

  Try this.

 first_item - seq(1,10)
 second_item - seq(11,20)
 dat - data.frame(first_item, second_item)
 dat$s
  [1] 11 12 13 14 15 16 17 18 19 20

 #Now add an extra column with matching name
 ssecond_item - seq(21,30)
 dat - data.frame(dat,ssecond_item)
 dat$s
NULL

Julian



P. Olsson wrote:
 Dear R-users,
 
 currently I am working with the R version 2.4.1.
 I realized it has a feature,  which might be wonderful (as so many things in
 R), but in this case might be a bit dangerous as well. It seems that columns
 of a data frame can be called just by indicating the first letter of the
 name of the column.
 
 For example:
 first_item - seq(1,10)
 second_item - seq(11,20)
 dat - data.frame(first_item, second_item)
 names(dat)
 # [1] first_item  second_item
 dat$f
 # [1]  1  2  3  4  5  6  7  8  9 10
 dat$s
 #  [1] 11 12 13 14 15 16 17 18 19 20
 
 The good thing is, that if there is more than one column starting with the
 same letter(s), more than one letter has to be given to call the column.
 However, I would appreciate if I could choose an option in my workspace,
 whether this type of shortcut is allowed or not.
 
 Is there such an option?
 
 Thanks for any potential hints.
 
 Best wishes,
 
 P. Olsson
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] data format

2007-10-30 Thread jim holtman
Here is how to read it in.  Then you can run your analysis:

 x - read.csv(textConnection(Label,Value
+ Good,10
+ Bad,12
+ Good,15
+ Good,18
+ Good,12
+ Bad,15
+ Bad,10))
 x
  Label Value
1  Good10
2   Bad12
3  Good15
4  Good18
5  Good12
6   Bad15
7   Bad10


On 10/30/07, Emre Unal [EMAIL PROTECTED] wrote:
 Hi,

 How can I analyze the data collected in database formatting (with labels)
 rather than splitted by individual columns (almost in excel)?

 For example (comma separated data);

 Label,Value
 Good,10
 Bad,12
 Good,15
 Good,18
 Good,12
 Bad,15
 Bad,10
 etc...

 ks.test or chisq.test can be done.
 Splitting the data into new columns is not applicable cos' I'll use
 R-integration in another software.



 Thanks for your concern
 Emre









 --
 ---
 Emre ÜNAL

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




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

What is the problem 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] Where can I find package segmented ?

2007-10-30 Thread John Kane
I think you already have it installed and loaded.

Try search() and see if it appears.

--- Maura E Monville [EMAIL PROTECTED] wrote:

 I tried to install segmented from three different
 repositories but I keep
 getting the following message on R window: ...
 Please, advice where to find
 this package.
 
 Thank you in advance.
 Maura
 
  utils:::menuInstallPkgs()
 --- Please select a CRAN mirror for use in this
 session ---
 Warning: package 'segmented' is in use and will not
 be installed
  utils:::menuInstallPkgs()
 Warning: package 'segmented' is in use and will not
 be installed
  setRepositories()
  utils:::menuInstallPkgs()
 Error in install.packages(NULL, .libPaths()[1],
 dependencies = NA, type =
 type) :
 no packages were specified
  chooseCRANmirror()
  utils:::menuInstallPkgs()
 Warning: package 'segmented' is in use and will not
 be installed
 
 
 
 -- 
 Maura E.M
 
   [[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] force interactive

2007-10-30 Thread George Georgalis
I'd like to invoke R using a fifo for input.  The
following unix commands gets me almost completely
there:

mkfifo R.fifo
R --no-save R.fifo R.out

in a separate window, I would enter the command eg
printf capabilities() R.fifo

the expected output goes into R.out; but the process
stops. How to I make R persist so I can send
multiple commands to the fifo?

Also, would this be possible in windows?

// George


-- 
George Georgalis, information system scientist IXOYE

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Some matrix and sandwich questions

2007-10-30 Thread Christian Ritz
Hi again,

in the MLE setting the score function (no expectation taken) is the 
estimating function. So for the OLS situation the basic estimating 
function is: (in the terminology of Zeileis' paper)

psi(x,y,beta) = (y - x^t beta) x^t




Christian

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Some matrix and sandwich questions

2007-10-30 Thread Achim Zeileis
On Tue, 30 Oct 2007, Michael Ash wrote:

 On 10/30/07, Christian Ritz [EMAIL PROTECTED] wrote:
  in the MLE setting the score function (no expectation taken) is the
  estimating function. So for the OLS situation the basic estimating
  function is: (in the terminology of Zeileis' paper)
 
  psi(x,y,beta) = (y - x^t beta) x^t

 Thanks!  That was extremely helpful---maybe it could even be added to
 the documentation of estfun() and meat()

Sorry for coming so late to the thread (and thanks to Christian for
pointing out how sandwich works :-)).

The estimating function is the derivative of the objective function wrt to
the parameter vector. The empirical estimating function is the estimating
function evaluated at the observed data and the estimated parameters. This
is explained in Section 4.2 of the JSS 16(9) paper which is contained in
the package as
  vignette(sandwich-OOP, package = sandwich)

But I'll follow your suggestion and add a bit more detail to the man page
as well.

 (Having the OLS example in the bread() documentation made it much
 easier for me to understand the broader concept.)

There is the analogous example in the examples section of the estfun()
documentation.

If you want to see more details about the OLS case, have a look at
  http://www.jstatsoft.org/v11/i10/
which is also contained in the package as
  vignette(sandwich, package = sandwich)

Best,
Z

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

2007-10-30 Thread Henrique Dallazuanna
Perhaps:

strwidth(expression(bold(text)))


On 30/10/2007, Roland Kaiser [EMAIL PROTECTED] wrote:

 Hi!

 Is there a way to get the string width of the bold typefaces?

 like: strwidth(text, family = serif, font = 2).

 Thanks

 Roland

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Splitting up the micEcon package?

2007-10-30 Thread Robert Duval
Dear Arne and Ott-Simm

It always seemed weird to me mixing demand and firm models with SSel.
models on a single package.

Separating them would seem the logical thing to do.

On the other hand, one more R package :/ , I´m not too big of a fan of
increasing this list ad infinitum.

My take on this is that it would be worth it to split it if you think
you´ll keep expanding the SSel. models under the new package.
Otherwise keep it the way it is.

I still dream of contributing a package that offers a group of SSel.
models under a wide variety of settings, but still haven´t found the
time to do so, nor it seems i´ll have it in the near future. On the
other hand, judging by the low number of replies it seems to me that
the audiece for SSel. in R is still quite limited.

My two cents,
greetings
robert


On 10/30/07, Arne Henningsen [EMAIL PROTECTED] wrote:
 Dear R Users:

 The functions of our micEcon package [1,2] can be subdivided into three
 categories:
 - microeconomic demand and firm models
 - sample selection models (mainly selection())
 - routines for (likelihood) maximisation (e.g. maxLik(), maxNR(), maxBHHH())
   (mainly used for ML estimation of sample selection models)

 Although sample selection models are often used in microeconomic analyses,
 they are also used in several other disciplines. Therefore, we are unsure
 whether it is better to keep these different functionalities in the micEcon
 package or to move the sample selection models and the routines for
 (likelihood) maximisation into one or two new package(s) (increasing the long
 list of R packages even further).
 What is the recommendation of the R community?

 Thank you,
 Ott  Arne

 Note: We have asked this question already on R-devel five days ago [3],
 but we did not receive an answer yet.

 References:
 [1] http://cran.r-project.org/src/contrib/Descriptions/micEcon.html
 [2] http://www.micecon.org/
 [3] http://tolstoy.newcastle.edu.au/R/e3/devel/07/10/0222.html

 --
 Arne Henningsen
 Department of Agricultural Economics
 University of Kiel
 Olshausenstr. 40
 D-24098 Kiel (Germany)
 Tel: +49-431-880 4445
 Fax: +49-431-880 1397
 [EMAIL PROTECTED]
 http://www.uni-kiel.de/agrarpol/ahenningsen/

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

2007-10-30 Thread Julian Burgos
There are many ways.  A simple one is to use split() to divide your 
'Value' column using your 'Label' column as index.  For example,

# Create dataset
mydata=data.frame(Label=c('Good','Bad','Good','Good','Good','Bad','Bad'),
Value=c(10,12,15,18,12,15,10))

# Split the data
mydata=split(mydata$Value,mydata$Label)

# Do a ks test
ks.test(mydata[[1]],mydata[[2]])


Julian




Emre Unal wrote:
 Hi,
 
 How can I analyze the data collected in database formatting (with labels)
 rather than splitted by individual columns (almost in excel)?
 
 For example (comma separated data);
 
 Label,Value
 Good,10
 Bad,12
 Good,15
 Good,18
 Good,12
 Bad,15
 Bad,10
 etc...
 
 ks.test or chisq.test can be done.
 Splitting the data into new columns is not applicable cos' I'll use
 R-integration in another software.
 
 
 
 Thanks for your concern
 Emre
 
 
 
 
 
 
 
 
 
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] strwidth of bold font

2007-10-30 Thread Roland Kaiser
Thanks it does the trick!


 Perhaps:

 strwidth(expression(bold(text)))


 On 30/10/2007, Roland Kaiser [EMAIL PROTECTED] wrote: Hi!

 Is there a way to get the string width of the bold typefaces?

 like: strwidth(text, family = serif, font = 2).

 Thanks

 Roland

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Place a string into the header/footer of a pdf file generated during a plot session

2007-10-30 Thread Tudor Bodea
Dear useRs,

Do you know, by any chance, if it is possible to write a string in the
header/footer of a pdf file created during a plot session? To make sure that I
know what R script generated a certain chart, I would like to add the path to
the working directory into the header/footer of the corresponding pdf file.

Thank you.

Tudor
--
Tudor Dan Bodea
Georgia Institute of Technology
School of Civil and Environmental Engineering
Web: http://www.prism.gatech.edu/~gtg757i

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Place a string into the header/footer of a pdf file generated during a plot session

2007-10-30 Thread Henrique Dallazuanna
Perhaps you can use mtext:

plot(rnorm(100), col=red, pch=16)
mtext(getwd(), side=1, line=3, outer=F, adj=0, cex=0.7)


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

On 30/10/2007, Tudor Bodea [EMAIL PROTECTED] wrote:

 Dear useRs,

 Do you know, by any chance, if it is possible to write a string in the
 header/footer of a pdf file created during a plot session? To make sure
 that I
 know what R script generated a certain chart, I would like to add the path
 to
 the working directory into the header/footer of the corresponding pdf
 file.

 Thank you.

 Tudor
 --
 Tudor Dan Bodea
 Georgia Institute of Technology
 School of Civil and Environmental Engineering
 Web: http://www.prism.gatech.edu/~gtg757i

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


[R] Implementing R through Oracle

2007-10-30 Thread jah

I have been looking for a statistical package that I can implement in our
application and I came across R. We run an n-Tier environment with an Oracle
10g backend. Our design is to keep all business logic in the backend. What I
would like to do is call R from pl/sql. I noticed that ROracle is designed
to connect with and process from a client perspective. I actually would be
running in the database preparing the data and then apply the statistics to
the result set for additional information. Then I would take the results
from R and apply additional processing. Has anyone done this? Thanks.
-- 
View this message in context: 
http://www.nabble.com/Implementing-R-through-Oracle-tf4719929.html#a13493204
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] timezone conversion difficulties with the new US daylight saving time switch over

2007-10-30 Thread Tony Plate
I'm having difficulties with daylight saving times in US time zones.
(Apologies for the long post, but the problem seems subtle and complex,
unless I'm doing something completely wrong, in which case it should
be evident from the first 10 lines below.)

This is what I see, using a (slightly modified) example from ?as.POSIXlt :

  as.POSIXlt((d - Sys.time()), EST5EDT)  # the current time in New York
[1] 2007-10-30 12:38:47 EST
  d
[1] 2007-10-30 11:38:47 Mountain Daylight Time
 

The problem is that Mountain Time is 2 hours behind Eastern Time and
the US is still on Daylight Saving Time - the current time in New York
should be reported as 13:38:47 EDT, not 12:38:47 EST.

This is running on Windows XP 64 bit (SP2), and I see the same behavior
on Windows XP 32 bit and on Windows 2000 Server (SP4).

AFAICS, this problem only occurs this week, and this week is unusual in that
it is the first year that Daylight Saving Time in the US ends on the first
Sunday in November rather than the last Sunday in October (I don't know
whether this is the cause of the problem, but it seems likely).

I see the same problem around the same week last year, but before and after
this week in both years, the conversions are fine:

  # *** problem in 2007
  as.POSIXlt(as.POSIXct(2007-10-30 11:38:47), EST5EDT)
[1] 2007-10-30 12:38:47 EST
  # before the problem week 2007
  as.POSIXlt(as.POSIXct(2007-10-20 11:38:47), EST5EDT)
[1] 2007-10-20 13:38:47 EDT
  # after the problem week 2007
  as.POSIXlt(as.POSIXct(2007-11-05 11:38:47), EST5EDT)
[1] 2007-11-05 13:38:47 EST
  # *** problem in 2006
  as.POSIXlt(as.POSIXct(2006-10-30 11:38:47), EST5EDT)
[1] 2006-10-30 12:38:47 EST
  # before the problem week 2006
  as.POSIXlt(as.POSIXct(2006-10-27 11:38:47), EST5EDT)
[1] 2006-10-27 13:38:47 EDT
  # after the problem week 2006
  as.POSIXlt(as.POSIXct(2006-11-07 11:38:47), EST5EDT)
[1] 2006-11-07 13:38:47 EST
 

My computer is set to the Mountain Daylight timezone, and is set to 
automatically
adjust for Daylight Saving Time changes.

  sessionInfo()
R version 2.6.0 Patched (2007-10-11 r43143)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
  Sys.timezone()
[1] Mountain Daylight Time
 

If I explicitly set env var TZ, the conversion problems go away,
but the time reported by Sys.time() is inappropriately not in daylight
saving time:

  Sys.time()
[1] 2007-10-30 13:14:38 Mountain Daylight Time
  Sys.setenv(TZ=MST7MDT)
  Sys.time()
[1] 2007-10-30 12:14:51 MST
 

If I set my system timezone to Eastern Daylight Time, and
restart R, I also get problematic behavior (as.POSIXlt
inappropriately adjusting a time by an hour on the day
after Daylight saving time ends):

  Sys.timezone()
[1] Eastern Daylight Time
  as.POSIXlt((d - Sys.time()), EST5EDT)
[1] 2007-10-30 12:57:40 EST
  d
[1] 2007-10-30 13:57:40 Eastern Daylight Time
 
  # *** problem week 2007
  as.POSIXlt(as.POSIXct(2007-10-30 11:38:47), EST5EDT)
[1] 2007-10-30 10:38:47 EST
  # before the problem week 2007
  as.POSIXlt(as.POSIXct(2007-10-20 11:38:47), EST5EDT)
[1] 2007-10-20 11:38:47 EDT
  # after the problem week 2007
  as.POSIXlt(as.POSIXct(2007-11-05 11:38:47), EST5EDT)
[1] 2007-11-05 11:38:47 EST
  # *** problem week 2006 - the day is after the switch, but
  # the time gets adjusted by one hour
  as.POSIXlt(as.POSIXct(2006-10-30 11:38:47), EST5EDT)
[1] 2006-10-30 10:38:47 EST
  # before the problem week 2006
  as.POSIXlt(as.POSIXct(2006-10-27 11:38:47), EST5EDT)
[1] 2006-10-27 11:38:47 EDT
  # after the problem week 2006
  as.POSIXlt(as.POSIXct(2006-11-10 11:38:47), EST5EDT)
[1] 2006-11-10 11:38:47 EST
 

The problem in 2006 goes away if I set TZ=EST5EDT:
  Sys.setenv(TZ = EST5EDT)
  Sys.timezone()
[1] EST
  as.POSIXlt(as.POSIXct(2006-10-30 11:38:47), EST5EDT)
[1] 2006-10-30 11:38:47 EST
 


Questions:
(1) should I be using a different way to convert times between time
 zones?
(2) is there a problem in how R is interacting with the system time
 conversion facilities?
(3) if the answer to (2) is yes, does anyone have any good hints for
 where to start looking for a solution? It looks to me like
 unclass(as.POSIXlt(as.POSIXct(2007-10-30 11:38:47), EST5EDT))$isdst
 is inappropriately zero.  I tried following the code in
 src/main/datetime.c:do_asPOSIXlt, and it looks like this isdst value
 comes from a call to localtime() from localtime0() ...

thanks in advance for any help,

Tony Plate

PS. I do not see the same problem in an old version of R (2.2.1)
running under Ubuntu Linux:

  Sys.timezone()
[1] 
  as.POSIXlt((d - Sys.time()), EST5EDT)
[1] 2007-10-29 14:56:49 EDT
  d
[1] 2007-10-29 12:56:49 MDT
 
  # ok in 2007
  as.POSIXlt(as.POSIXct(2007-10-30 11:38:47), EST5EDT)
[1] 2007-10-30 13:38:47 EDT
  # before the problem week 2007
  

Re: [R] calculate spatial distance

2007-10-30 Thread Sarah Goslee
I don't know of such a function, but you have several options:

1. Assume that Euclidean distance is good enough - probably
reasonable over a limited geographic region (and commonly done).
2. Use your GIS software to do the calculations since it already
understands projections and distances on a sphere.
3. Write a function to do this yourself and make it available to
other researchers who need this capability. Assuming that
great circle distances on a perfect sphere are good enough, it
isn't that hard to do.

Eh, I talked myself into it (runs, but otherwise untested):

geogdist - function(lat1, lon1, lat2, lon2)
{
# takes latitude and longitue for points 1 and 2
# returns great circle distances in km
# south and west are negative

rad - function(x) { (x/360) * 2 * pi }
deg - function(x) { (x/(2 * pi)) * 360 }

gd - (sin(rad(lat1)) * sin(rad(lat2))) + (cos(rad(lat1)) *
cos(rad(lat2)) * cos(rad(abs(lon2-lon1

gd - deg(acos(gd))

111.23 * gd

}



On Oct 30, 2007 11:49 AM,  [EMAIL PROTECTED] wrote:
 Hi,
 I have a set of locations defined by longitude and latitude (in degrees),
 and want to calculate the spatial (or geographic) distance among all
 locations.
 I did not find such a function in the spatial-related packages. (I *cannot*
 use 'dist', as I have geographic, not cartesian coordinates).
 thanks!
 Robert



-- 
Sarah Goslee
http://www.functionaldiversity.org

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

2007-10-30 Thread Charles C. Berry


RSiteSearch(longitude distance)


pops up a bunch of results that seem pertinent. e.g.

R: Distance Between Geographic Coordinates (score: 4)

R: Distance Along Great Circle Arc (score: 2)

??


On Tue, 30 Oct 2007, Sarah Goslee wrote:

 I don't know of such a function, but you have several options:

 1. Assume that Euclidean distance is good enough - probably
 reasonable over a limited geographic region (and commonly done).
 2. Use your GIS software to do the calculations since it already
 understands projections and distances on a sphere.
 3. Write a function to do this yourself and make it available to
 other researchers who need this capability. Assuming that
 great circle distances on a perfect sphere are good enough, it
 isn't that hard to do.

 Eh, I talked myself into it (runs, but otherwise untested):

 geogdist - function(lat1, lon1, lat2, lon2)
 {
 # takes latitude and longitue for points 1 and 2
 # returns great circle distances in km
 # south and west are negative

 rad - function(x) { (x/360) * 2 * pi }
 deg - function(x) { (x/(2 * pi)) * 360 }

 gd - (sin(rad(lat1)) * sin(rad(lat2))) + (cos(rad(lat1)) *
 cos(rad(lat2)) * cos(rad(abs(lon2-lon1

 gd - deg(acos(gd))

 111.23 * gd

 }



 On Oct 30, 2007 11:49 AM,  [EMAIL PROTECTED] wrote:
 Hi,
 I have a set of locations defined by longitude and latitude (in degrees),
 and want to calculate the spatial (or geographic) distance among all
 locations.
 I did not find such a function in the spatial-related packages. (I *cannot*
 use 'dist', as I have geographic, not cartesian coordinates).
 thanks!
 Robert



 -- 
 Sarah Goslee
 http://www.functionaldiversity.org

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


[R] Reading a file with read.csv: two character rows not interpreted as I hope

2007-10-30 Thread Bryan Hanson
Hi Folks... Œbeen playing with this for a while, with no luck, so I¹m hoping
someone knows it off the top of their head...  Difficult to find this nuance
in the archives, as so many msgs deal with read.csv!

I¹m trying to read a data file with the following structure (a little piece
of the actual data, they are actually csv just didn¹t paste with the
commas):

 wavelength SampleA SampleB SampleC SampleD
 color green black black green
 class Class 1 Class 2 Class 2 Class 1
 403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
 409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
 415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
 420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
 426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
 432 1.42E-01 1.50E-01 1.62E-01 1.48E-01

Columns after the first one are sample names.  2nd row is the list of colors
to use in later plotting.  3rd row is the class for later manova.  The rest
of it is x data in the first column with y1, y2...following for plotting.

I can read the file w/o the color or class rows with read.csv just fine,
makes a nice data frame with proper data types.  The problem comes when
parsing the 2nd and 3rd rows.  Here¹s the code:

data = read.csv(filename, header=TRUE) # read in data
color = data[1,]; color = data[-1] # capture color info  throw out 1st
value
class = data[2,]; class = class[-1] # capture category info  throw out 1st
value

cleaned.data = data[-1,] # remove color  category info for matrix
operations
cleaned.data = data[-1,]
freq = data[,1] # capture frequency info

What happens is that freq is parsed as factors, and the color and class are
parsed as a data frames of factors.
I need color and class to be characters which I can pass to functions in the
typical way one uses colors and levels.
I need the freq  the cleaned.data info as numeric for plotting.

I don¹t feel I¹m far off from things working, but that¹s where you all come
in!  Seems like an argument of as.something is needed, but the ones I¹ve
tried don¹t work.  Would it help to put color and class above the x,y data
in the file, then clean it off?

Btw, I¹m on a Mac using R 2.6.0.

Thanks in advance, Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry




[[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] R installation on SuSE 10.3

2007-10-30 Thread Maura E Monville
I have downloaded the source code for Linux.
the ./configure procedure can find gcc but cannot find f77 or f2c
I have looked for the above compiler with Test and installed all what
pertains to Fortran. Still not even the man pages for f77 anf fc2 work .

Where is f77 and f2c with linux 10.3 ??

Thank you do much
-- 
Maura E.M

[[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] calculate spatial distance

2007-10-30 Thread Gabor Grothendieck
Check out rdist.earth in the fields package.

On Oct 30, 2007 11:49 AM,  [EMAIL PROTECTED] wrote:
 Hi,
 I have a set of locations defined by longitude and latitude (in degrees),
 and want to calculate the spatial (or geographic) distance among all
 locations.
 I did not find such a function in the spatial-related packages. (I *cannot*
 use 'dist', as I have geographic, not cartesian coordinates).
 thanks!
 Robert


  Robert Ptacnik
  Norwegian Institute for Water Research (NIVA)
 Gaustadalléen 21
 NO-0349 Oslo
 mobile +47 982 277 81
 FON NIVA +47 22 18 51 00
 FAX  +47 22 18 52 00



 --
 NIVAs hovedkontor har flyttet til nye lokaler i CIENS - Forskningssenter
 for miljø og samfunn; Gaustadalléen 21, 0349 Oslo. Meld deg på vårt
 nyhetsbrev på www.niva.no
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] data.frame, ggplot vs matplot

2007-10-30 Thread baptiste Auguié
Hello,


I've been trying to use ggplot, but I cannot seem to get my data in  
the correct form. I usually have a vector x, and a matrix y and I  
would usually use matplot(x,y) to plot the columns of y against x.

Now, if i understand correctly, I should cast x and y into a  
data.frame and do something like ggplot(x,y,data=data). I think I'm  
missing something here: do I really need to reshape y into a single  
vector, replicate x accordingly, and put both vectors in a data frame?

I've tried it, but the reshape function is still very obscure to me.  
Any help appreciated!

Small example:

x-seq(from=1,by=1,length=10)
y-sin(x)%*%t(x)
columns-c(1:10)

matplot(x,y)

legend(topleft, (x,y),  columns)

# the version below is not working

require(ggplot2)

data.frame(cbind(x,y))-dataS
wide - reshape(dataS, direction=wide,timevar=c(1:length(columns)))
dataL-reshape(wide,direction=long) # this clearly doesn't work as  
I would have thought
qplot(x, y, data = dataL)

Best regards,

baptiste

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] high RAM on Linux or Solaris platform

2007-10-30 Thread Thomas Lumley
On Tue, 30 Oct 2007, David Bickel wrote:

 To help me make choices regarding a platform for running high-memory R
 processes in parallel, I would appreciate any responses to these
 questions:

 1. Does the amount of RAM available to an R session depend on the
 processor (Intel vs. Sun) or on the OS (various Linux distributions vs.
 Solaris)?

Yes.

It depends on whether R uses 64-bit or 32-bit pointers. For 64-bit R you need a 
64-bit processor, an operating system that will run 64-bit programs, and a 
compiler that will produce them.

I'm not sure what the current Intel offerings are, but you can compile and run 
64-bit on AMD Opteron (Linux) and Sun (Solaris) systems.

 2. Does R have any built-in limitations of RAM available to a session?
 For example, could it make use of 16 GB in one session given the right
 processor/OS platform?

R does have built-in limitations even in a 64-bit system, but they are large. 
It is certainly possible to use more than 16Gb of memory.

The main limit is that the length of a vector is stored in a C int, and so is 
no more than 2^31-1, or about two billion. A numeric vector of that length 
would take up 16Gb on its own.

 3. Is there anything else I should consider before choosing a processor
 and OS?

I don't think there is anything else R-specific.


-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 installation on SuSE 10.3

2007-10-30 Thread Kevin E. Thorpe
Maura E Monville wrote:
 I have downloaded the source code for Linux.
 the ./configure procedure can find gcc but cannot find f77 or f2c
 I have looked for the above compiler with Test and installed all what
 pertains to Fortran. Still not even the man pages for f77 anf fc2 work .
 
 Where is f77 and f2c with linux 10.3 ??
 
 Thank you do much

In SuSE 10.2 I found it in the gcc-fortran package.  I don't recall if
it is required, but there is also a gcc41-fortran.  It may well be the
same in SuSE 10.3.


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Homework help: Is this how CI using t dist are constructed?

2007-10-30 Thread Zembower, Kevin
I'm trying to replicate some of the examples from my textbook in R (my
text uses Minitab). In this problem, I'm trying to construct a 95%
confidence interval for these distance measurements [1]:

 # Case Study 7.4.1, p. 483
 x - scan()
1:  62 52 68 23 34 45 27 42 83 56 40
12: 
Read 11 items
 alpha-.95
 mean(x) + qt(c((1-alpha)/2, 1-((1-alpha)/2)), df=length(x)-1) * sd(x)
/ sqrt(length(x))
[1] 36.21420 60.51307


Are confidence intervals with the t distribution constructed using this
type of equation, or am I overlooking a more concise, 'canned' approach
that's already been programmed? Any suggestions on simplifying this?

Thanks for all your advice and help.

-Kevin

[1] An Introduction to Mathematical Statistics and its Applications,
fourth ed., Larsen and Marx.

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 installation on SuSE 10.3

2007-10-30 Thread Detlef Steuer
Hi,

On Tue, 30 Oct 2007 14:44:17 -0500
Maura E Monville [EMAIL PROTECTED] wrote:

 I have downloaded the source code for Linux.
 the ./configure procedure can find gcc but cannot find f77 or f2c
 I have looked for the above compiler with Test and installed all what
 pertains to Fortran. Still not even the man pages for f77 anf fc2 work .
 
 Where is f77 and f2c with linux 10.3 ??

In 10.3 they provide gcc-fortran (or f77). Just search for fortran in
yast2.

If you want to use a precompiled binary you can find one there:

http://download.opensuse.org/repositories/home:dsteuer/openSUSE_10.3

or just type r-base in the search box on

http://software.opensuse.org/search

Hope that helps
Detlef


 
 Thank you do much
 -- 
 Maura E.M
 
   [[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.


-- 
Keinen Gedanken zweimal denken, außer er ist schön. Unbekannte Quelle

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

2007-10-30 Thread valentina bonetti
Hi,

I am looking for a package to estimate regime switching models (states
following a markov chain).
I found packages for Hidden Markov Models but I am looking for something a
little different: In the HMM the conditional distribution of the
observations (give the state) is a known distribution (normal or others),
while the package I need should allow to set a conditional distribution
(given the state) which can be still modelled (for example with
mean-reversion or jump diffusion...).

I think the theory under this estimation technique is in James D. Hamilton,
A New Approach to the Economic Analysis of Nonstationary Time Series and the
Business Cycle (1989)

Thanks very much for any help!

Valentina Bonetti

Master student at Bocconi University, Milan

[[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] Fwd: data format

2007-10-30 Thread Emre Unal
Excuse me for less detailed e-mail I've sent before, I guess there's a
misunderstanding here.
My problem is to use the data in the order I've typed below without
splitting it. Is it possible? I really don't know. Some statistics packages
do it.

Original Data is;

Good,Bad
10,12
15,15
18,10
12



But I have the data in the following form,
Label,Value
Good,10
Bad,12
Good,15
Good,18
Good,12
Bad,15
Bad,10


And I want to analyze the data without splitting it. I guessed whether
there's a quick/simple solution to my problem. Array functions do solve this
problem in general.  Now I'm reading the help files about How to deal with
arrays in R environment?.

Thx a lot for your concern
Emre





-- Forwarded message --
From: Emre Unal [EMAIL PROTECTED]
Date: Oct 30, 2007 4:39 PM
Subject: data format
To: r-help@r-project.org

Hi,

How can I analyze the data collected in database formatting (with labels)
rather than splitted by individual columns (almost in excel)?

For example (comma separated data);

Label,Value
Good,10
Bad,12
Good,15
Good,18
Good,12
Bad,15
Bad,10
etc...

ks.test or chisq.test can be done.
Splitting the data into new columns is not applicable cos' I'll use
R-integration in another software.



Thanks for your concern
Emre









-- 
---
Emre ÜNAL



-- 
---
Emre ÜNAL
http://www.geocities.com/dusemre
http://dusemre.blogspot.com
ICQ: 5712269

[[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] NAIVE BAYES with 10-fold cross validation

2007-10-30 Thread Julia Kröpfl
hi there!!

i am trying to implement the code of the e1071 package for naive bayes, but it 
doens't really work, any ideas??
i am very glad about any help!!
i need a naive bayes with 10-fold cross validation:

code:
library(e1071)

model - naiveBayes(code ~ ., mydata)

tune.control - tune.control(random = FALSE, nrepeat = 1, repeat.aggregate = 
min,
sampling = c(cross), sampling.aggregate = mean,
cross = 10, best.model = TRUE, performances = TRUE)

pred - predict(model, mydata[,-12], type=class)
tune(naiveBayes, code~., mydata, predict.fun=pred, tune.control)


thx for your help!
cheers, julia
--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Homework help: Is this how CI using t dist are constructed?

2007-10-30 Thread Achim Zeileis
On Tue, 30 Oct 2007, Zembower, Kevin wrote:

 I'm trying to replicate some of the examples from my textbook in R (my
 text uses Minitab). In this problem, I'm trying to construct a 95%
 confidence interval for these distance measurements [1]:

  # Case Study 7.4.1, p. 483
  x - scan()
 1:  62 52 68 23 34 45 27 42 83 56 40
 12:
 Read 11 items
  alpha-.95
  mean(x) + qt(c((1-alpha)/2, 1-((1-alpha)/2)), df=length(x)-1) * sd(x)
 / sqrt(length(x))
 [1] 36.21420 60.51307
 

 Are confidence intervals with the t distribution constructed using this
 type of equation, or am I overlooking a more concise, 'canned' approach
 that's already been programmed? Any suggestions on simplifying this?

R offers a confint() generic with methods for various types of models.
If you consider estimation of the mean as a simple linear model (with only
an intercept) you can do
  fm - lm(x ~ 1)
  fm
to estimate the mean and then
  confint(fm)
to get the confidence interval (by default at 0.95 level).

hth,
Z

 Thanks for all your advice and help.

 -Kevin

 [1] An Introduction to Mathematical Statistics and its Applications,
 fourth ed., Larsen and Marx.

 Kevin Zembower
 Internet Services Group manager
 Center for Communication Programs
 Bloomberg School of Public Health
 Johns Hopkins University
 111 Market Place, Suite 310
 Baltimore, Maryland  21202
 410-659-6139

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Homework help: Is this how CI using t dist are constructed?

2007-10-30 Thread Peter Dalgaard
Zembower, Kevin wrote:
 I'm trying to replicate some of the examples from my textbook in R (my
 text uses Minitab). In this problem, I'm trying to construct a 95%
 confidence interval for these distance measurements [1]:

   
 # Case Study 7.4.1, p. 483
 x - scan()
 
 1:  62 52 68 23 34 45 27 42 83 56 40
 12: 
 Read 11 items
   
 alpha-.95
 mean(x) + qt(c((1-alpha)/2, 1-((1-alpha)/2)), df=length(x)-1) * sd(x)
 
 / sqrt(length(x))
 [1] 36.21420 60.51307
   

 Are confidence intervals with the t distribution constructed using this
 type of equation, or am I overlooking a more concise, 'canned' approach
 that's already been programmed? Any suggestions on simplifying this?

 Thanks for all your advice and help.
   
You mean like t.test(x)?

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] high RAM on Linux or Solaris platform

2007-10-30 Thread Prof Brian Ripley
On Tue, 30 Oct 2007, Thomas Lumley wrote:

 On Tue, 30 Oct 2007, David Bickel wrote:

 To help me make choices regarding a platform for running high-memory R
 processes in parallel, I would appreciate any responses to these
 questions:

 1. Does the amount of RAM available to an R session depend on the
 processor (Intel vs. Sun) or on the OS (various Linux distributions vs.
 Solaris)?

 Yes.

 It depends on whether R uses 64-bit or 32-bit pointers. For 64-bit R you 
 need a 64-bit processor, an operating system that will run 64-bit 
 programs, and a compiler that will produce them.

 I'm not sure what the current Intel offerings are, but you can compile 
 and run 64-bit on AMD Opteron (Linux) and Sun (Solaris) systems.

That is both Sparc Solaris and x86_64 Solaris (although for the latter you 
seem to need to use the SunStudio compilers).

As far as I know all current desktop Intel processors run x86_64, and 
Xeons seem to have a price-performance edge at the moment. We have several 
boxes with dual quad-core Xeons and lots of RAM.  (Not all for use with R, 
some Linux, some Windows.)  Core 2 Duos do, and are commonplace in quite 
low-end systems.


 2. Does R have any built-in limitations of RAM available to a session?
 For example, could it make use of 16 GB in one session given the right
 processor/OS platform?

 R does have built-in limitations even in a 64-bit system, but they are 
 large. It is certainly possible to use more than 16Gb of memory.

 The main limit is that the length of a vector is stored in a C int, and 
 so is no more than 2^31-1, or about two billion. A numeric vector of 
 that length would take up 16Gb on its own.

?Memory-limits documents them.

 3. Is there anything else I should consider before choosing a processor
 and OS?

 I don't think there is anything else R-specific.

-- 
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] NAIVE BAYES with 10-fold cross validation

2007-10-30 Thread Kuhn, Max
 am trying to implement the code of the e1071 package for naive bayes, 
 but it doens't really work, any ideas??
 am very glad about any help!!
 need a naive bayes with 10-fold cross validation:

The caret package will do this. Use

 fit - train(
   x, y, method = nb, 
   trControl = trainControl(method = cv, number = 10))

(there is no formula interface yet).

It will use the naïve Bayes implementation in klaR. Unless you specify 
otherwise, it will train naïve Bayes models with and without using kernel 
density estimation (but you can change that). 

The object fit$finalModel will contain the model fit that is cv optimal.

For example:

  fit - train(
 +iris[,-5], iris$Species, nb, 
 +trControl = trainControl(method = cv, number = 10))
 Iter 1  Values: TRUE 
 Loading required package: MASS
 Loading required package: class
 Iter 2  Values: FALSE 
  
  fit
 
 Call:
 train.default(x = iris[, -5], y = iris$Species, method = nb, 
 trControl = trainControl(method = cv, number = 10))
 
 150 samples
 4 predictors
 
 summary of cross-validation (10 fold) sample sizes:
 135, 135, 135, 135, 135, 135, ... 
 
 cv resampled training results across tuning parameters:
 
   usekernel  Accuracy  Kappa  Accuracy SD  Kappa SD  Optimal
   FALSE  0.953 0.93   0.0706   0.106
   TRUE   0.96  0.94   0.0562   0.0843*  
 
 Accuracy was used to select the optimal model
 

Max


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julia Kröpfl
Sent: Tuesday, October 30, 2007 4:46 PM
To: r-help@r-project.org
Subject: [R] NAIVE BAYES with 10-fold cross validation

hi there!!

i am trying to implement the code of the e1071 package for naive bayes, but it 
doens't really work, any ideas??
i am very glad about any help!!
i need a naive bayes with 10-fold cross validation:

code:
library(e1071)

model - naiveBayes(code ~ ., mydata)

tune.control - tune.control(random = FALSE, nrepeat = 1, repeat.aggregate = 
min,
sampling = c(cross), sampling.aggregate = mean,
cross = 10, best.model = TRUE, performances = TRUE)

pred - predict(model, mydata[,-12], type=class)
tune(naiveBayes, code~., mydata, predict.fun=pred, tune.control)


thx for your help!
cheers, julia
--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Homework help: Is this how CI using t dist are constructed?

2007-10-30 Thread Zembower, Kevin
Yes, exactly. In fact, I had already discovered this, too. I don't know why I 
didn't think of it before asking this question.

Thanks for your patience with me.

-Kevin

-Original Message-
From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 30, 2007 4:54 PM
To: Zembower, Kevin
Cc: r-help@r-project.org
Subject: Re: [R] Homework help: Is this how CI using t dist are constructed?

Zembower, Kevin wrote:
 I'm trying to replicate some of the examples from my textbook in R (my
 text uses Minitab). In this problem, I'm trying to construct a 95%
 confidence interval for these distance measurements [1]:
snip
   
You mean like t.test(x)?

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] Homework help: Is this how CI using t dist are constructed?

2007-10-30 Thread Rolf Turner

On 31/10/2007, at 9:52 AM, Achim Zeileis wrote:

 On Tue, 30 Oct 2007, Zembower, Kevin wrote:

 I'm trying to replicate some of the examples from my textbook in R  
 (my
 text uses Minitab). In this problem, I'm trying to construct a 95%
 confidence interval for these distance measurements [1]:

 # Case Study 7.4.1, p. 483
 x - scan()
 1:  62 52 68 23 34 45 27 42 83 56 40
 12:
 Read 11 items
 alpha-.95
 mean(x) + qt(c((1-alpha)/2, 1-((1-alpha)/2)), df=length(x)-1) * sd 
 (x)
 / sqrt(length(x))
 [1] 36.21420 60.51307


 Are confidence intervals with the t distribution constructed using  
 this
 type of equation, or am I overlooking a more concise, 'canned'  
 approach
 that's already been programmed? Any suggestions on simplifying this?

 R offers a confint() generic with methods for various types of models.
 If you consider estimation of the mean as a simple linear model  
 (with only
 an intercept) you can do
   fm - lm(x ~ 1)
   fm
 to estimate the mean and then
   confint(fm)
 to get the confidence interval (by default at 0.95 level).

This is using a sledgehammer to crack a peanut.

The use of t.test() as suggested by Peter Dalgaard is much more
appropriate.

cheers,

Rolf Turner

##
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.


Re: [R] How to test combined effects?

2007-10-30 Thread Gang Chen
Dieter,

Thank you very much for the help!

I tried both glht() in multcomp and estimable() in gmodels, but  
couldn't get them work as shown below. Basically I have trouble  
specifying those continuous variables. Any suggestions?

Also it seems both glht() and estimable() would give multiple t  
tests. Is there a way to obtain sort of partial F test?


  ModelFit-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData,  
random=~1|ID)
  anova(ModelFit)

mDF denDF  F-value p-value
(Intercept) 1   257 54393.04  .0001
IQ  1   215 3.02  0.0839
age 1   25746.06  .0001
I(age^2)1   257 8.80  0.0033
I(age^3)1   25721.30  .0001
IQ:age  1   257 1.18  0.2776
IQ:I(age^2) 1   257 0.50  0.4798
IQ:I(age^3) 1   257 0.23  0.6284

  library(multcomp)
  glht(ModelFit, linfct = c(IQ:age = 0, IQ:I(age^2) = 0, IQ:I 
(age^3) = 0))
Error in coefs(ex[[3]]) :
   cannot interpret expression 'I''age^2' as linear function

  library(gmodels)
  estimable(ModelFit, rbind('IQ:age'=0, 'IQ:I(age^2) = 0', 'IQ:I 
(age^3) = 0'))
Error in FUN(newX[, i], ...) :
   `param' has no names and does not match number of coefficients of  
model. Unable to construct coefficient vector

Thanks,
Gang


On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote:


 Gang Chen gangchen at mail.nih.gov writes:



 Suppose I have a mixed-effects model where yij is the jth sample for
 the ith subject:

 yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) +
 beta5(IQ^2) + beta6(age*IQ)  + beta7(age^2*IQ)  +  beta8(age^3 *IQ)
 +random intercepti + eij

 In R how can I get an F test against the null hypothesis of
 beta6=beta7=beta8=0? In SAS I can run something like contrast  age*IQ
 1, age^2*IQ 1, age^3 *IQ 1, but is there anything similar in R?


 Check packages multcomp and gmodels for contrast tests that work  
 with lme.

 Dieter


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


[R] R 2.6.0 crashes when opening some .R files

2007-10-30 Thread andersrm
Why would R 2.6.0 crash when opening .R files created with an older version of
R, but apparently not when opening .R files created with the current version? 
Even cutting and pasting text from older .R files does not prevent this from
happening.

Richard Anderson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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.frame, ggplot vs matplot

2007-10-30 Thread Ben Bolker



baptiste Auguié-2 wrote:
 
 Hello,
 
 
 I've been trying to use ggplot, but I cannot seem to get my data in  
 the correct form. I usually have a vector x, and a matrix y and I  
 would usually use matplot(x,y) to plot the columns of y against x.
 
 Now, if i understand correctly, I should cast x and y into a  
 data.frame and do something like ggplot(x,y,data=data). I think I'm  
 missing something here: do I really need to reshape y into a single  
 vector, replicate x accordingly, and put both vectors in a data frame?
 
 I've tried it, but the reshape function is still very obscure to me.  
 Any help appreciated!
 
 Small example:
 
 x-seq(from=1,by=1,length=10)
 y-sin(x)%*%t(x)
 columns-c(1:10)
 
 matplot(x,y)
 
 legend(topleft, (x,y),  columns)
 
 


dataL = melt(dataS,id=x)

qplot(x,value,data=dataL)
qplot(x,value,data=dataL,colour=variable)

  cheers
   Ben Bolker
-- 
View this message in context: 
http://www.nabble.com/data.frame%2C-ggplot-vs-matplot-tf4721042.html#a13498585
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] data types changing

2007-10-30 Thread dmmtchll
List,
I am attempting to take a row of data from one matrix to another if it 
satisfies a certain condition.  When R puts the data in the new matrix it is 
changing the characters to integers and giving them values which aren't very 
helpful to my analysis.  I would use as.character, but I need to keep the 
double values as is.  Is there a way to copy the entry exactly as is to the new 
matrix, without having to use a separate statement for each entry.  I've 
included some code below.  In my example all but row 5 are factors and should 
be kept as characters, and column 7 has 2 levels, 1 or 2.  Column 5, the 
response is a double.  Thanks for the help.


l = nrow(data)
n = 1
k = 1
data1trip = as.data.frame(rbind(1:7))
data2trip = as.data.frame(rbind(1:7))
colnames(data1trip) =...#my column names for data1trip
colnames(data2trip) =...#data2trip
for(i in 1:l){
if (data[i,7]==1){
data1trip[k,] = data[i,]; k=k+1 }
else {
data2trip[n,] = data[i,]; n = n+1}
}


is the only other way to do what i want

for(i in 1:l){
if (data[i,7]==1){
data1trip[k,1] = as.char(data[i,1]
data1trip[k,2] = as.char(data[i,2]
data1trip[k,3] = data[i,]
...


else {
and the same for those which have a 2 value in data[i,7]?
}

This second way seems a bit sloppy and i wanted to check if there existed a 
more professional way to do it.

Thanks again,
Dave Mitchell

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Difficulty Compiling RSQLite on Solaris x86 Using Studio 12 Compilers

2007-10-30 Thread Aric Gregson
Apologies if this is not the best list on which to ask for help. I have
compiled R 2.6.0 using Sun Studio 12 compilers. I can install most CRAN
and bioconductor packages that I need, with the exception of RSQLite.
Unfortunately this is critical for other packages that I need. I have
tried to compile it using R CMD INSTALL to generate a config.log file.
I don't know how to fix the reported error. I have tried commenting
out most of the test language in the configure file, but then there are
other complaints. 

I used Studio 12 to build 2.5.1 and it worked perfectly. The only issue
with the 2.6.0 build is that 'make test' fails and this did not happen
with 2.5.1. However, it appears to run fine.

Any ideas of how I can get RSQLite to compile? Or is there another list
to which I should address my question.

thanks,

aric

Here is an except from the config.log:

/usr/bin/uname -p = i386
/bin/uname -X = System = SunOS
Node = solenv
Release = 5.11
KernelID = snv_69
Machine = i86pc

## --- ##
## Core tests. ##
## --- ##

configure:1313: checking for gcc
configure:1339: result: dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
/opt/studio12/SUNWspro/bin/cc -m64
configure:1583: checking for C compiler version
configure:1586: dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
/opt/studio12/SUNWspro/bin/cc -m64 --version /dev/null 5
./configure: line 1587: dmake:: command not found
configure:1589: $? = 127
configure:1591: dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
/opt/studio12/SUNWspro/bin/cc -m64 -v /dev/null 5
./configure: line 1592: dmake:: command not found
configure:1594: $? = 127
configure:1596: dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
/opt/studio12/SUNWspro/bin/cc -m64 -V /dev/null 5
./configure: line 1597: dmake:: command not found
configure:1599: $? = 127
configure:1622: checking for C compiler default output file name
configure:1625: dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
/opt/studio12/SUNWspro/bin/cc -m64 dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
-xO5 -xc99 -xlibmieee -xlibmil -nofstore   conftest.c  5
./configure: line 1626: dmake:: command not found
configure:1628: $? = 127
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME 
| #define PACKAGE_TARNAME 
| #define PACKAGE_VERSION 
| #define PACKAGE_STRING 
| #define PACKAGE_BUGREPORT 
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:1667: error: C compiler cannot create executables
See `config.log' for more details.

## - ##
## Output variables. ##
## - ##

-xO5 -xc99 -xlibmieee -xlibmil -nofstore'
/opt/studio12/SUNWspro/bin/cc -m64'
/opt/studio12/SUNWspro/bin/cc -m64'
CC='dmake: defaulting to parallel mode.
CFLAGS='dmake: defaulting to parallel mode.
CPP=''
CPPFLAGS=''
DEFS=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EXEEXT=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LTLIBOBJS=''
OBJEXT=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
PKG_CPPFLAGS=''
PKG_LIBS=''
SHELL='/bin/bash'
See the man page dmake(1) for more information on setting up
the .dmakerc file.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
See the man page dmake(1) for more information on setting up
the .dmakerc file.
ac_ct_CC='dmake: defaulting to parallel mode.
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${prefix}/share'
exec_prefix='NONE'
host_alias=''
includedir='${prefix}/include'
infodir='${prefix}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localstatedir='${prefix}/var'
mandir='${prefix}/man'
oldincludedir='/usr/include'
prefix='NONE'
program_transform_name='s,x,x,'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## --- ##
## confdefs.h. ##
## --- ##

#define PACKAGE_BUGREPORT 
#define PACKAGE_NAME 
#define PACKAGE_STRING 
#define PACKAGE_TARNAME 
#define PACKAGE_VERSION 

configure: exit 77


--
IMPORTANT WARNING:  This email (and any attachments) is ...{{dropped:8}}

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


Re: [R] Reading a file with read.csv: two character rows not interpreted as I hope

2007-10-30 Thread jim holtman
Here is one way.  You will probably use 'file' instead of textConnection

 x.in - textConnection('wavelength SampleA SampleB SampleC SampleD
+  color green black black green
+  class Class 1 Class 2 Class 2 Class 1
+  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
+  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
+  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
+  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
+  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
+  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01')

 c.names - scan(x.in, what='', nlines=1)  # read column names
Read 5 items
 c.options - read.table(x.in, as.is=TRUE, nrows=2) # get lines 2-3
 c.data - read.table(x.in)  # rest of the data
 colnames(c.data) - c.names
 close(x.in)
 c.options  # here are lines 2-3
 V1  V2  V3  V4  V5
1 color   green   black   black   green
2 class Class 1 Class 2 Class 2 Class 1
 c.data  # your data
  wavelength SampleA SampleB SampleC SampleD
1403   0.194   0.214   0.211   0.183
2409   0.192   0.189   0.200   0.182
3415   0.170   0.199   0.194   0.186
4420   0.159   0.191   0.216   0.174
5426   0.150   0.166   0.172   0.158
6432   0.142   0.150   0.162   0.148


On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
 Hi Folks... Œbeen playing with this for a while, with no luck, so I¹m hoping
 someone knows it off the top of their head...  Difficult to find this nuance
 in the archives, as so many msgs deal with read.csv!

 I¹m trying to read a data file with the following structure (a little piece
 of the actual data, they are actually csv just didn¹t paste with the
 commas):

  wavelength SampleA SampleB SampleC SampleD
  color green black black green
  class Class 1 Class 2 Class 2 Class 1
  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01

 Columns after the first one are sample names.  2nd row is the list of colors
 to use in later plotting.  3rd row is the class for later manova.  The rest
 of it is x data in the first column with y1, y2...following for plotting.

 I can read the file w/o the color or class rows with read.csv just fine,
 makes a nice data frame with proper data types.  The problem comes when
 parsing the 2nd and 3rd rows.  Here¹s the code:

 data = read.csv(filename, header=TRUE) # read in data
 color = data[1,]; color = data[-1] # capture color info  throw out 1st
 value
 class = data[2,]; class = class[-1] # capture category info  throw out 1st
 value

 cleaned.data = data[-1,] # remove color  category info for matrix
 operations
 cleaned.data = data[-1,]
 freq = data[,1] # capture frequency info

 What happens is that freq is parsed as factors, and the color and class are
 parsed as a data frames of factors.
 I need color and class to be characters which I can pass to functions in the
 typical way one uses colors and levels.
 I need the freq  the cleaned.data info as numeric for plotting.

 I don¹t feel I¹m far off from things working, but that¹s where you all come
 in!  Seems like an argument of as.something is needed, but the ones I¹ve
 tried don¹t work.  Would it help to put color and class above the x,y data
 in the file, then clean it off?

 Btw, I¹m on a Mac using R 2.6.0.

 Thanks in advance, Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry




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




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

What is the problem 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] R installation on Linux/SuSE10.3

2007-10-30 Thread Maura E Monville
I am installing in /usr/local/bin where I have to be root even if I
changed the access right to some sub directories by chmod.
The installation completed fine  (all stages: /config, make, make
install). But no icon was created on my desktop. It works just typing
in on the command line. It has no GUI.
How come ?  The README file does not even touch such problem.
In spite of hating Windows I have to confess that R is much more
friendly on Windows.

Is there any way to make R run more smoothly on Linux/SuSE as well ??

Thank you in advance.

Regards,
Maura

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

2007-10-30 Thread James
Hi,

I am trying to create a perspective plot with Time on the x-axis,  
Underlying Price on the y-axis, and Option Price on the z-axis.  But  
I don't like the way my x-axis is setup.  Right now, Time is this  
sequence.

Time = seq(from = 1/52, to = 1, by=1/52)

That results in the x-axis going from 0 at the back, to 1 near the  
foreground corner.(If that makes any sense)  I want to do the exact  
opposite.  When I try this sequence:

Time = seq(from = 1, to = 1/52, by=-1/52)

I get this error message:

Error in persp.default(x = Time, y = S, z = Price, xlab = Time,  
ylab = S,  :
increasing 'x' and 'y' values expected

So it seems that I can't use a descending sequence for my perspective  
plot.  Is that true?  Is there a way to work around this?

persp(x=Time, y=S, z=Price, xlab=Time, ylab=S, zlab=TypeFlag, ...)

Essentially, what I'm trying to create is something that looks like  
this.

http://www.insightful.com/products/finmetrics/opSensitivity1_lg.gif

You can see how Time on the x-axis diminishes as it moves to the  
foreground corner.

Thanks in advance.

James

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

2007-10-30 Thread Dirk Eddelbuettel

On 30 October 2007 at 20:17, James wrote:
| I am trying to create a perspective plot with Time on the x-axis,  
| Underlying Price on the y-axis, and Option Price on the z-axis.  But  

Can't help with persp, but see 
http://dirk.eddelbuettel.com/code/rquantlib-rgl.html 
for some animated gifs using Rgl and the RQuantLib pricers.

Dirk

-- 
Three out of two people have difficulties with fractions.

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


Re: [R] Reading a file with read.csv: two character rows not interpreted as I hope

2007-10-30 Thread Bryan Hanson
Jim, thanks for the suggestion.  There is still something subtle 
non-intuitive going on here.  I adapted your code with minor changes as
follows (I had to add the sep argument) but get different behavior:

c.names - scan(file.csv, what='', nlines=1, sep=,)  # read column names
c.options - read.table(file.csv, as.is=TRUE, nrows=2, sep=,) # get
lines 2-3
c.data - read.table(file.csv, sep=,)  # rest of the data
colnames(file.csv) - c.names

Your code works perfectly (you knew that!).  My adaptation runs, but
c.options contains the first two lines, not lines 2  3, and c.data contains
the contents of the entire file as *factors* (data type of c.names 
c.options is correct - character). How strange!

Also, and this is an observation rather than a question: in your code, you
call scan and get the first line as characters, then you do read.table which
gets lines 2  3 presumably because the first line, from read.table's
perspective is a hidden label (?), then the second time you use read.table
the hidden first line is ignored, as are the two lines with character data.
I really don't understand these behaviors, which is probably why I'm having
trouble parsing the file!

Thanks, Bryan 

On 10/30/07 8:40 PM, jim holtman [EMAIL PROTECTED] wrote:

 Here is one way.  You will probably use 'file' instead of textConnection
 
 x.in - textConnection('wavelength SampleA SampleB SampleC SampleD
 +  color green black black green
 +  class Class 1 Class 2 Class 2 Class 1
 +  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
 +  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
 +  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
 +  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
 +  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
 +  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01')
 
 c.names - scan(x.in, what='', nlines=1)  # read column names
 Read 5 items
 c.options - read.table(x.in, as.is=TRUE, nrows=2) # get lines 2-3
 c.data - read.table(x.in)  # rest of the data
 colnames(c.data) - c.names
 close(x.in)
 c.options  # here are lines 2-3
  V1  V2  V3  V4  V5
 1 color   green   black   black   green
 2 class Class 1 Class 2 Class 2 Class 1
 c.data  # your data
   wavelength SampleA SampleB SampleC SampleD
 1403   0.194   0.214   0.211   0.183
 2409   0.192   0.189   0.200   0.182
 3415   0.170   0.199   0.194   0.186
 4420   0.159   0.191   0.216   0.174
 5426   0.150   0.166   0.172   0.158
 6432   0.142   0.150   0.162   0.148
 
 
 On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
 Hi Folks... Œbeen playing with this for a while, with no luck, so I¹m hoping
 someone knows it off the top of their head...  Difficult to find this nuance
 in the archives, as so many msgs deal with read.csv!
 
 I¹m trying to read a data file with the following structure (a little piece
 of the actual data, they are actually csv just didn¹t paste with the
 commas):
 
  wavelength SampleA SampleB SampleC SampleD
  color green black black green
  class Class 1 Class 2 Class 2 Class 1
  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01
 
 Columns after the first one are sample names.  2nd row is the list of colors
 to use in later plotting.  3rd row is the class for later manova.  The rest
 of it is x data in the first column with y1, y2...following for plotting.
 
 I can read the file w/o the color or class rows with read.csv just fine,
 makes a nice data frame with proper data types.  The problem comes when
 parsing the 2nd and 3rd rows.  Here¹s the code:
 
 data = read.csv(filename, header=TRUE) # read in data
 color = data[1,]; color = data[-1] # capture color info  throw out 1st
 value
 class = data[2,]; class = class[-1] # capture category info  throw out 1st
 value
 
 cleaned.data = data[-1,] # remove color  category info for matrix
 operations
 cleaned.data = data[-1,]
 freq = data[,1] # capture frequency info
 
 What happens is that freq is parsed as factors, and the color and class are
 parsed as a data frames of factors.
 I need color and class to be characters which I can pass to functions in the
 typical way one uses colors and levels.
 I need the freq  the cleaned.data info as numeric for plotting.
 
 I don¹t feel I¹m far off from things working, but that¹s where you all come
 in!  Seems like an argument of as.something is needed, but the ones I¹ve
 tried don¹t work.  Would it help to put color and class above the x,y data
 in the file, then clean it off?
 
 Btw, I¹m on a Mac using R 2.6.0.
 
 Thanks in advance, Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 
 
 
 
[[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 

[R] survey weights in sample with replacement

2007-10-30 Thread Azam, Mehtabul
 Hi,
   I am trying to draw a random sample from an household survey with sample 
weight. Is there any function in R or Splus which allows this. 
 
Regards,
 
***
Mehtabul Azam
Department of Economics
Southern Methodist University
Dallas TX 75275-0496 
Tel: (214) 214 938 3906
Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
Web: http://people.smu.edu/mazam

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

2007-10-30 Thread James Reilly

On 31/10/07 4:03 PM, Azam, Mehtabul wrote:
I am trying to draw a random sample from an household survey with 
 sample weight. Is there any function in R or Splus which allows this. 

I'm not sure if this what you're after, but R's pps package lets you 
sample with probability proportional to size.

Hope this helps,
James
-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

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

2007-10-30 Thread Duncan Murdoch
On 30/10/2007 10:42 PM, Dirk Eddelbuettel wrote:
 On 30 October 2007 at 20:17, James wrote:
 | I am trying to create a perspective plot with Time on the x-axis,  
 | Underlying Price on the y-axis, and Option Price on the z-axis.  But  
 
 Can't help with persp, but see 
   http://dirk.eddelbuettel.com/code/rquantlib-rgl.html 
 for some animated gifs using Rgl and the RQuantLib pricers.

Animations are easier in the latest release:  see spin3d to set a spin 
rate, par3dinterp to interpolate between views, movie3d to take regular 
snapshots, or play3d to just play them.

Duncan

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


Re: [R] Reading a file with read.csv: two character rows not interpreted as I hope

2007-10-30 Thread jim holtman
Try:

inFile - file(file.csv, r)

Then use inFile where you have file.csv.  You are reopening the file
on each call; this keeps the file open.

On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
 Jim, thanks for the suggestion.  There is still something subtle 
 non-intuitive going on here.  I adapted your code with minor changes as
 follows (I had to add the sep argument) but get different behavior:

 c.names - scan(file.csv, what='', nlines=1, sep=,)  # read column names
 c.options - read.table(file.csv, as.is=TRUE, nrows=2, sep=,) # get
 lines 2-3
 c.data - read.table(file.csv, sep=,)  # rest of the data
 colnames(file.csv) - c.names

 Your code works perfectly (you knew that!).  My adaptation runs, but
 c.options contains the first two lines, not lines 2  3, and c.data contains
 the contents of the entire file as *factors* (data type of c.names 
 c.options is correct - character). How strange!

 Also, and this is an observation rather than a question: in your code, you
 call scan and get the first line as characters, then you do read.table which
 gets lines 2  3 presumably because the first line, from read.table's
 perspective is a hidden label (?), then the second time you use read.table
 the hidden first line is ignored, as are the two lines with character data.
 I really don't understand these behaviors, which is probably why I'm having
 trouble parsing the file!

 Thanks, Bryan

 On 10/30/07 8:40 PM, jim holtman [EMAIL PROTECTED] wrote:

  Here is one way.  You will probably use 'file' instead of textConnection
 
  x.in - textConnection('wavelength SampleA SampleB SampleC SampleD
  +  color green black black green
  +  class Class 1 Class 2 Class 2 Class 1
  +  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
  +  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
  +  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
  +  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
  +  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
  +  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01')
 
  c.names - scan(x.in, what='', nlines=1)  # read column names
  Read 5 items
  c.options - read.table(x.in, as.is=TRUE, nrows=2) # get lines 2-3
  c.data - read.table(x.in)  # rest of the data
  colnames(c.data) - c.names
  close(x.in)
  c.options  # here are lines 2-3
   V1  V2  V3  V4  V5
  1 color   green   black   black   green
  2 class Class 1 Class 2 Class 2 Class 1
  c.data  # your data
wavelength SampleA SampleB SampleC SampleD
  1403   0.194   0.214   0.211   0.183
  2409   0.192   0.189   0.200   0.182
  3415   0.170   0.199   0.194   0.186
  4420   0.159   0.191   0.216   0.174
  5426   0.150   0.166   0.172   0.158
  6432   0.142   0.150   0.162   0.148
 
 
  On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
  Hi Folks... Œbeen playing with this for a while, with no luck, so I¹m 
  hoping
  someone knows it off the top of their head...  Difficult to find this 
  nuance
  in the archives, as so many msgs deal with read.csv!
 
  I¹m trying to read a data file with the following structure (a little piece
  of the actual data, they are actually csv just didn¹t paste with the
  commas):
 
   wavelength SampleA SampleB SampleC SampleD
   color green black black green
   class Class 1 Class 2 Class 2 Class 1
   403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
   409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
   415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
   420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
   426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
   432 1.42E-01 1.50E-01 1.62E-01 1.48E-01
 
  Columns after the first one are sample names.  2nd row is the list of 
  colors
  to use in later plotting.  3rd row is the class for later manova.  The rest
  of it is x data in the first column with y1, y2...following for plotting.
 
  I can read the file w/o the color or class rows with read.csv just fine,
  makes a nice data frame with proper data types.  The problem comes when
  parsing the 2nd and 3rd rows.  Here¹s the code:
 
  data = read.csv(filename, header=TRUE) # read in data
  color = data[1,]; color = data[-1] # capture color info  throw out 1st
  value
  class = data[2,]; class = class[-1] # capture category info  throw out 1st
  value
 
  cleaned.data = data[-1,] # remove color  category info for matrix
  operations
  cleaned.data = data[-1,]
  freq = data[,1] # capture frequency info
 
  What happens is that freq is parsed as factors, and the color and class are
  parsed as a data frames of factors.
  I need color and class to be characters which I can pass to functions in 
  the
  typical way one uses colors and levels.
  I need the freq  the cleaned.data info as numeric for plotting.
 
  I don¹t feel I¹m far off from things working, but that¹s where you all come
  in!  Seems like an argument of as.something is needed, but the ones I¹ve
  tried don¹t work.  Would it help to put color and class above the x,y data
  in the file, then clean it off?
 
  Btw, I¹m on a Mac using R 2.6.0.
 
  Thanks in advance, Bryan
  

Re: [R] Reading a file with read.csv: two character rows not interpreted as I hope

2007-10-30 Thread jim holtman
Also, your statement should be:

colnames(c.data) - c.names

On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
 Jim, thanks for the suggestion.  There is still something subtle 
 non-intuitive going on here.  I adapted your code with minor changes as
 follows (I had to add the sep argument) but get different behavior:

 c.names - scan(file.csv, what='', nlines=1, sep=,)  # read column names
 c.options - read.table(file.csv, as.is=TRUE, nrows=2, sep=,) # get
 lines 2-3
 c.data - read.table(file.csv, sep=,)  # rest of the data
 colnames(file.csv) - c.names

 Your code works perfectly (you knew that!).  My adaptation runs, but
 c.options contains the first two lines, not lines 2  3, and c.data contains
 the contents of the entire file as *factors* (data type of c.names 
 c.options is correct - character). How strange!

 Also, and this is an observation rather than a question: in your code, you
 call scan and get the first line as characters, then you do read.table which
 gets lines 2  3 presumably because the first line, from read.table's
 perspective is a hidden label (?), then the second time you use read.table
 the hidden first line is ignored, as are the two lines with character data.
 I really don't understand these behaviors, which is probably why I'm having
 trouble parsing the file!

 Thanks, Bryan

 On 10/30/07 8:40 PM, jim holtman [EMAIL PROTECTED] wrote:

  Here is one way.  You will probably use 'file' instead of textConnection
 
  x.in - textConnection('wavelength SampleA SampleB SampleC SampleD
  +  color green black black green
  +  class Class 1 Class 2 Class 2 Class 1
  +  403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
  +  409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
  +  415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
  +  420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
  +  426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
  +  432 1.42E-01 1.50E-01 1.62E-01 1.48E-01')
 
  c.names - scan(x.in, what='', nlines=1)  # read column names
  Read 5 items
  c.options - read.table(x.in, as.is=TRUE, nrows=2) # get lines 2-3
  c.data - read.table(x.in)  # rest of the data
  colnames(c.data) - c.names
  close(x.in)
  c.options  # here are lines 2-3
   V1  V2  V3  V4  V5
  1 color   green   black   black   green
  2 class Class 1 Class 2 Class 2 Class 1
  c.data  # your data
wavelength SampleA SampleB SampleC SampleD
  1403   0.194   0.214   0.211   0.183
  2409   0.192   0.189   0.200   0.182
  3415   0.170   0.199   0.194   0.186
  4420   0.159   0.191   0.216   0.174
  5426   0.150   0.166   0.172   0.158
  6432   0.142   0.150   0.162   0.148
 
 
  On 10/30/07, Bryan Hanson [EMAIL PROTECTED] wrote:
  Hi Folks... Œbeen playing with this for a while, with no luck, so I¹m 
  hoping
  someone knows it off the top of their head...  Difficult to find this 
  nuance
  in the archives, as so many msgs deal with read.csv!
 
  I¹m trying to read a data file with the following structure (a little piece
  of the actual data, they are actually csv just didn¹t paste with the
  commas):
 
   wavelength SampleA SampleB SampleC SampleD
   color green black black green
   class Class 1 Class 2 Class 2 Class 1
   403 1.94E-01 2.14E-01 2.11E-01 1.83E-01
   409 1.92E-01 1.89E-01 2.00E-01 1.82E-01
   415 1.70E-01 1.99E-01 1.94E-01 1.86E-01
   420 1.59E-01 1.91E-01 2.16E-01 1.74E-01
   426 1.50E-01 1.66E-01 1.72E-01 1.58E-01
   432 1.42E-01 1.50E-01 1.62E-01 1.48E-01
 
  Columns after the first one are sample names.  2nd row is the list of 
  colors
  to use in later plotting.  3rd row is the class for later manova.  The rest
  of it is x data in the first column with y1, y2...following for plotting.
 
  I can read the file w/o the color or class rows with read.csv just fine,
  makes a nice data frame with proper data types.  The problem comes when
  parsing the 2nd and 3rd rows.  Here¹s the code:
 
  data = read.csv(filename, header=TRUE) # read in data
  color = data[1,]; color = data[-1] # capture color info  throw out 1st
  value
  class = data[2,]; class = class[-1] # capture category info  throw out 1st
  value
 
  cleaned.data = data[-1,] # remove color  category info for matrix
  operations
  cleaned.data = data[-1,]
  freq = data[,1] # capture frequency info
 
  What happens is that freq is parsed as factors, and the color and class are
  parsed as a data frames of factors.
  I need color and class to be characters which I can pass to functions in 
  the
  typical way one uses colors and levels.
  I need the freq  the cleaned.data info as numeric for plotting.
 
  I don¹t feel I¹m far off from things working, but that¹s where you all come
  in!  Seems like an argument of as.something is needed, but the ones I¹ve
  tried don¹t work.  Would it help to put color and class above the x,y data
  in the file, then clean it off?
 
  Btw, I¹m on a Mac using R 2.6.0.
 
  Thanks in advance, Bryan
  *
  Bryan Hanson
  Professor of Chemistry  Biochemistry
 
 
 
 
 

[R] DBI Package

2007-10-30 Thread Germán Carrillo
Hello everyone!

Congratulations by this gorgeous software.

My name is Germán Carrillo, I'm writting from Colombia. I don't have much
experience with R, reason why I use the R-GUI (version 2.5.1) on Windows.

I have some problems with DBI package, I want to connect to PostgreSQL
database but I don't know the way to do it.

I was reading the DBI manual and I tried write in my R Console the next
command:

pg - dbDriver(PostgreSQL)

But R says:
 Error en do.call(as.character(drvName), list(...)) :
no se pudo encontrar la función PostgreSQL

I don't know what's happen, I would like to receive some help about this
topic, I was looking for in the internet but there's few documentation about
this package.


Thanks in advance.

Best regards.

Pdt: Sorry by my english, I'm learning... :)


-- 
---
  |\__
(:__)(
  |/

Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/

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