Re: [R] Install local package

2009-06-11 Thread Ronggui Huang
## Check the package
 R CMD check path.of.package
## Build the package
 R CMD build pathof.package
## INSTALL the package
 R CMD INSTALL path.of.package

You can use _R --help _  (from within terminal) to get more information.

Ronggui

2009/6/11 Jorge Cornejo cornejo...@gmail.com:
 Hi, I'm working on a package that I would someday put in CRAN. Now I
 want to test it on my computer. I already check and compile the files
 but I don't know how to install the package located on my hard drive.
 I'm running R under linux. Can anyone tell my how to do it?

 Thanks in advance.

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




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
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 order an data.table by values of an column?

2009-06-11 Thread Allan Engelhardt

See help(order) and help([.data.frame).


df - 
data.frame(Categ=c(468,351,0,234,117),Perc=c(31.52,27.52,0.77,22.55,15.99))

df[order(df$Categ),]
#   Categ  Perc
# 3 0  0.77
# 5   117 15.99
# 4   234 22.55
# 2   351 27.52
# 1   468 31.52


Lesandro wrote:

Hello!

Can you help me? How to order an data.table by values of an column?

Per example:

Table no initial

Categ Perc
468  31.52
351  27.52
0  0.77
234  22.55
117  15.99

table final

Categ Perc
0  0.77
117  15.99
234  22.55
351  27.52
468  31.52

Lesandro



  Veja quais são os assuntos do momento no Yahoo! +Buscados

[[alternative HTML version deleted]]

  



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



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


[R] install local package

2009-06-11 Thread Jorge Cornejo
Hi, I'm working on a package that I would someday put in CRAN. Now I
want to test it on my computer. I already check and compile the files
but I don't know how to install the package located on my hard drive.
I'm running R under linux. Can anyone tell my how to do it?

Thanks in advance.

__
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-pkgs] package installation fails (RandomFields)

2009-06-11 Thread Drew Hoysak
I have been unable to install the package RandomFields. I am using R 
2.9.0-4 on Ubuntu 9.04.


To install, I use the command:
sudo R CMD INSTALL RandomFields_1.3.37.tar.gz


The output follows below. Any help Would be appreciated.

D. Hoysak
Brandon University


* Installing to library ‘/usr/local/lib/R/site-library’
* Installing *source* package ‘RandomFields’ ...
** libs
g++ -I/usr/share/R/include -g -fpic -g -O2 -c D.H.cc -o D.H.o
In file included from D.H.cc:27:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c Hyperfcts.cc -o Hyperfcts.o
In file included from Hyperfcts.cc:27:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
Hyperfcts.cc: In function ‘int checkNinit_co(covinfo_type*, int*, int, 
SimulationType, bool)’:
Hyperfcts.cc:145: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:145: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:145: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:145: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:145: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc: In function ‘int checkNinit_Stein(covinfo_type*, int*, 
int, SimulationType, bool)’:
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’
Hyperfcts.cc:261: warning: deprecated conversion from string constant to 
‘char*’

g++ -I/usr/share/R/include -g -fpic -g -O2 -c MPP.cc -o MPP.o
In file included from MPP.cc:32:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c MPPFcts.cc -o MPPFcts.o
In file included from MPPFcts.cc:48:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c RFCovFcts.cc -o RFCovFcts.o
In file included from RFCovFcts.cc:47:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c RFcircembed.cc -o 
RFcircembed.o

In file included from RFcircembed.cc:33:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
RFcircembed.cc: In function ‘void SetParamCircEmbed(int*, int*, double*, 
double*, int*, int*, double*, int*, int*, double*, int*)’:
RFcircembed.cc:114: warning: deprecated conversion from string constant 
to ‘char*’
RFcircembed.cc: In function ‘void SetParamLocal(int*, int*, double*, 
double*, int*, double*, int*, double*, int*)’:
RFcircembed.cc:124: warning: deprecated conversion from string constant 
to ‘char*’

g++ -I/usr/share/R/include -g -fpic -g -O2 -c RFdirect.cc -o RFdirect.o
In file included from RFdirect.cc:28:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c RFempvario.cc -o RFempvario.o
In file included from RFempvario.cc:28:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
g++ -I/usr/share/R/include -g -fpic -g -O2 -c RFgetNset.cc -o RFgetNset.o
In file included from RFgetNset.cc:36:
RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
RFgetNset.cc: In function ‘SEXPREC* TooLarge(int*, int)’:
RFgetNset.cc:1081: warning: deprecated conversion from string constant 
to ‘char*’
RFgetNset.cc:1081: warning: deprecated conversion from string constant 
to ‘char*’
RFgetNset.cc: In function ‘SEXPREC* GetModelInfo(covinfo_type*, int, 
int, long int)’:
RFgetNset.cc:1106: warning: deprecated conversion from string 

Re: [R] [R-pkgs] package installation fails (RandomFields)

2009-06-11 Thread Martin Maechler
[[ NOTE:  This accidentally was approved to go to  R-packages,
  it should never have gone there, and I have deleted it
  from the archives.
   Please *only* reply to R-help (and the OP)! 
]]

 DH == Drew Hoysak hoy...@wcgwave.ca
 on Wed, 10 Jun 2009 14:40:32 -0500 writes:

DH I have been unable to install the package RandomFields. I am using R 
DH 2.9.0-4 on Ubuntu 9.04.

How exactly did you install R?   Just as ubuntu package?  
{probably, given the somewhat particular version number}

DH To install, I use the command:

DH sudo R CMD INSTALL RandomFields_1.3.37.tar.gz


DH The output follows below. Any help Would be appreciated.

DH D. Hoysak
DH Brandon University


DH * Installing to library ‘/usr/local/lib/R/site-library’
DH * Installing *source* package ‘RandomFields’ ...
DH ** libs
DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c D.H.cc -o D.H.o
DH In file included from D.H.cc:27:
DH RFsimu.h:38: warning: ‘typedef’ was ignored in this declaration
DH RFsimu.h:261: warning: ‘typedef’ was ignored in this declaration
DH RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration

[..]
[..]

DH RFsimu.h:309: warning: ‘typedef’ was ignored in this declaration
DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c win_linux_aux.cc -o 
DH win_linux_aux.o
DH g++ -shared -o RandomFields.so D.H.o Hyperfcts.o MPP.o MPPFcts.o 
DH RFCovFcts.o RFcircembed.o RFdirect.o RFempvario.o RFgetNset.o 
DH RFhyperplan.o RFinitNerror.o RFnugget.o RFother.o RFsimu.o RFspectral.o 
DH RFtbm.o Xempvario.o addownfctns.o auxiliary.o avltr.o extremes.o 
DH modelling.o win_linux_aux.o -llapack -L/usr/lib/R/lib -lR
DH /usr/bin/ld: cannot find -llapack
^

This looks like a setup problem of the R installation you have;
I'd guess that you would also see problems installing other R
packages that rely on LAPACK.



DH collect2: ld returned 1 exit status
DH make: *** [RandomFields.so] Error 1
DH ERROR: compilation failed for package ‘RandomFields’
DH * Removing ‘/usr/local/lib/R/site-library/RandomFields’

__
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] Variogram fitted by Cauchy

2009-06-11 Thread damien landais
Hi
I'm using R(2.9.0)  and gstat package under Windows  to  plot sample variograms.
When I want to fit them, I don't have the possibility to choose Cauchy 
functions. Under Mathematica for example, we have it and it seems to be the 
best one to fit the variograms I have
I tested the others functions, they can fit but I would,if possible, use the 
Cauchy one. If anybody knows something about it, I would know, even with 
another package

To show what I want to do, here is my code

mydata=read.table(97MHz_15cm_V3.txt)
colnames(mydata)=c(x,y,z,E,taille)
g=gstat(id=zinc,formula=mydata[,4]~1,locations=~x+y+z,data=mydata)
g.var=variogram(g,cutoff=2500,width=100)

modele=vgm(model=Exp,range=2000)
vario=fit.variogram(g.var,modele)


Thanks!

Cordialement
Damien Landais

__
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] Integrate function in R

2009-06-11 Thread Paul Hiemstra

?integrate, it is in the documentation

Bhargab Chattopadhyay wrote:

Hi!

Can anyone please let me know what numerical integration procedure does the 
integrate function in package stats follow?
Thank you in advance

Shant



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



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Splicing factors without losing levels

2009-06-11 Thread Peter Dalgaard

Titus von der Malsburg wrote:

On Tue, Jun 09, 2009 at 11:23:36AM +0200, ONKELINX, Thierry wrote:

For factors, you better convert them first back to character strings.

  splice - function(x, y) {
x - levels(x)[x]
y - levels(y)[y]
factor(as.vector(rbind(x, y)))
  } 


Thank you very much, Thierry!

I failed to mention something important in my last mail: x and y have
the same levels.  (I assume that the integer to level name mapping of
a factor defines its class and that it only makes sense to combine
factors of the same class.)

Say

 x - factor(c(2,2,4,4), levels=1:4, labels=c(a,b,c,d))

then

 x
[1] b b d d
Levels: a b c d

 as.integer(x)
[1] 2 2 4 4

but

 splice(x,x)
[1] b b b b d d d d
Levels: b d

 as.integer(splice(x,x))
[1] 1 1 1 1 2 2 2 2

I'd like to have a splice function that retains the level to label
mapping.  One candidate for a solution is:

splice - function(x,y) {
  xy - as.vector(rbind(x, y))
  if (is.factor(x)  is.factor(y))
xy - factor(xy, levels=1:length(levels(x)), labels=levels(x))
  xy
}

However, this relies on assumtions about the implementation of
factors that are neither mentioned nor guaranteed in the man page:
Levels are underlyingly integers starting from one and going to
length(levels).  levels(x) gives me the labels of these integers in an
order corresponding to 1:length(levels(x)).

Without these assumptions I see no way to recover the integer to level
name mapping for levels that are defined in a factor but do not occur.

I'd be happy if somebody could clarify this issue!


Hm, well,... Some people have been quite insistent that factors should 
be though of as isomorphic to vectors over small subsets of character 
strings and not as isomorphic to small integers with labels. I tend  to 
disagree as it creates more complications than it solves.


Anyways, I would do it like this (generalizing 8 and the seq() bits is 
left as an exercise)


 x - factor(c(2,2,4,4), levels=1:4, labels=c(a,b,c,d))
 xx - factor(rep(NA,8),levels=levels(x))
 xx[seq(1,8,2)]-x
 xx[seq(2,8,2)]-x
 xx
[1] b b b b d d d d
Levels: a b c d
 as.integer(xx)
[1] 2 2 2 2 4 4 4 4




  Titus

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



--
   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
~~ - (p.dalga...@biostat.ku.dk)  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.


[R] ctc package

2009-06-11 Thread Penner, Johannes
Dear R-helpers,

I would like to export hierarchical clusters

e.g. fit - hclust(d, method=ward) in the newick format

write(hc2Newick(fit),file='hclust.newick')

Searching for a possibility I found this solution in the package ctc
(http://www.bioconductor.org/packages/bioc/html/ctc.html). However,
neither from this site nor via CRAN it is possible to install the
package.

Is there any other possibility? Is the package included in any other
package?

Thanks a lot in advance.

With kind regards
Johannes

--
Project Coordinator BIOTA West Amphibians

Museum of Natural History
Dep. of Research (Herpetology)
Invalidenstrasse 43
D-10115 Berlin
Tel: +49 (0)30 2093 8708
Fax: +49 (0)30 2093 8565

http://www.biota-africa.org
http://community-ecology.biozentrum.uni-wuerzburg.de

__
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] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

Hi All, 

Have spent the last couple of days learning R and shell scripting to do
batch plotting jobs. I have had success getting R to complete a filled
contour plot and output to a file (.jpg or .tiff etc). However, when I try
to do the same thing with the simple plot command the script seems to
execute correctly yet there is no output. Below is my R code: 

file - Sys.getenv(input_file) 
tiff(paste( file, tiff, sep=.)) 
z - read.table(file) 
plot(z, type=l, xlim=range(0.6,2), col = red, plot.title = title(main =
file, xlab = Wavelength (um), ylab = Intensity (arb.)) 
q() 

The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and can
clearly write tiff's as it managed it with the filled contours. 

Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 

Cheers, 

Kenny

-- 
View this message in context: 
http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23977785.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Issues getting R to write image files

2009-06-11 Thread Mario Valle

Has tried to close the image file at the end?
Do:
dev.off()

Hope it helps
   mario
Kenny Larsen wrote:
Hi All, 


Have spent the last couple of days learning R and shell scripting to do
batch plotting jobs. I have had success getting R to complete a filled
contour plot and output to a file (.jpg or .tiff etc). However, when I try
to do the same thing with the simple plot command the script seems to
execute correctly yet there is no output. Below is my R code: 

file - Sys.getenv(input_file) 
tiff(paste( file, tiff, sep=.)) 
z - read.table(file) 
plot(z, type=l, xlim=range(0.6,2), col = red, plot.title = title(main =
file, xlab = Wavelength (um), ylab = Intensity (arb.)) 
q() 


The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and can
clearly write tiff's as it managed it with the filled contours. 


Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 

Cheers, 


Kenny

  



--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

__
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] Predict GARCH

2009-06-11 Thread marlene marchena
So christofer proved (carry on the same procedure infinite times) that the
forecast of the variance converge to the long run variance when a+b1

   E(Sigma[t+2]^2) = w/(1-a-b) + [(a+b)^t]* Sigma[t+1]^2

Therefore when you predict n.ahead = 20 it must to converge to the long run
variance. It can be fast depending on the data.

Regards,

Marlene.



2009/6/10 bogaso.christofer bogaso.christo...@gmail.com

 Suppose the GARCH(1,1) equation is :

 Sigma[t]^2 = w + a* Sigma[t-1]^2 + b*r[t-1]^2

 One step ahead forecast :
 Sigma[t+1]^2 = w + a* Sigma[t]^2 + b*r[t]^2  All informations are available
 here

 Two step ahead forecast :
 Sigma[t+2]^2 = w + a* Sigma[t+1]^2 + b*r[t+1]^2
 Here r[t+1] is not known at time t therefore is a r.v. Replacing this
 with
 it's expected value as r[t+1]^2  = E[r[t+1]^2]  = sigma[t+1]^2, assuming
 E[r[t+1]] = 0

 Therefore Sigma[t+2]^2 = w + a* Sigma[t+1]^2 + b*r[t+1]^2
   = w + a* Sigma[t+1]^2 + b* Sigma[t+1]^2
   = w + (a+b)* Sigma[t+1]^2

 Carry on same procedure for next period forecast.
 Hope this helps.


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Daniel Mail
 Sent: 10 June 2009 18:55
 To: r-help@r-project.org
 Subject: [R] Predict GARCH







 hello,


 i was trying to predict values for a garch, so i did:

 predict(fitgarch,n.ahead = 20)

 but this doesn't work. Someone can tell me how to get the 20 values ahead
 of
 a garch model.


 thanks in advance


 _
 O Windows Live ajuda-o a manter-se em contacto com todos os seus amigos,
 num
 ss local.

 http://www.microsoft.com/portugal/windows/windowslive/products/social-networ
 k-connector.aspxhttp://www.microsoft.com/portugal/windows/windowslive/products/social-networ%0Ak-connector.aspx
[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Issues getting R to write image files

2009-06-11 Thread Tobias Verbeke

Hi Kenny,


Have spent the last couple of days learning R and shell scripting to do
batch plotting jobs. I have had success getting R to complete a filled
contour plot and output to a file (.jpg or .tiff etc). However, when I try
to do the same thing with the simple plot command the script seems to
execute correctly yet there is no output. Below is my R code: 

file - Sys.getenv(input_file) 
tiff(paste( file, tiff, sep=.)) 
z - read.table(file) 
plot(z, type=l, xlim=range(0.6,2), col = red, plot.title = title(main =
file, xlab = Wavelength (um), ylab = Intensity (arb.)) 


dev.off()

q() 


You need to close the tiff graphics device you opened
using dev.off() before quitting.

HTH,
Tobias

__
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 on drawing stars and radars in R (update)

2009-06-11 Thread Caroline Gideon-Adeniyi
Hi

I don't know if you can help. I am a 2nd year Bsc Cosmetic Science student and 
in R I need some help in drawing stars.

The problem that I have is I want to recreate a radar diagram similar to the 
one in excel.

I have put in these commands in a script window:

 stars(shampoo1[, 1:6], locations = c(0,0), radius = TRUE,
  key.loc=c(0,0),
  main = Ranked Results for the Sensory Evaluation of the Shampoo ,
  frame.plot = TRUE,
  key.labels = c(Foam Texture, Skin Feel, Rinsability, Wet Combability, 
Wet Feel, Odour),
  lty = 2,
)

This gives me a black and white radar which is fine.

Now according to the reference manual to colour the stars i need to add:

col.stars = rainbow (30)

Which colours in each star segment. The problem I have with this is that the 
segments are filled with colour and the segments overlap each other and each 
segment is not visible.

So I desperately need the command that only colours the outline of the segments 
or stars instead of  filling it.

This is the example given in the reference manual:

stars(mtcars[, 1:7], locations = c(0,0), radius = FALSE,
key.loc=c(0,0), main=Motor Trend Cars, lty = 2)


Can u help?

Thank  You

Caroline

__
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] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

Thanks all, I added the dev.off() and although it didn't solve it it no doubt
tidies things up on closing. I have got it working now, it is something in
the plot() line, as removing all teh options solves it. I will work
through adding them in one by one!

Kenny


Mario Valle wrote:
 
 Has tried to close the image file at the end?
 Do:
 dev.off()
 
 Hope it helps
 mario
 Kenny Larsen wrote:
 Hi All, 

 Have spent the last couple of days learning R and shell scripting to do
 batch plotting jobs. I have had success getting R to complete a filled
 contour plot and output to a file (.jpg or .tiff etc). However, when I
 try
 to do the same thing with the simple plot command the script seems to
 execute correctly yet there is no output. Below is my R code: 

 file - Sys.getenv(input_file) 
 tiff(paste( file, tiff, sep=.)) 
 z - read.table(file) 
 plot(z, type=l, xlim=range(0.6,2), col = red, plot.title = title(main
 =
 file, xlab = Wavelength (um), ylab = Intensity (arb.)) 
 q() 

 The data file is simply 2 columns of real numbers. The system it is
 running
 on is a linux box from the command line, but does have the Xlibrarys and
 can
 clearly write tiff's as it managed it with the filled contours. 

 Bear in mind I only started with both linux and R a couple of days ago,
 so
 be gentle if it is something silly! 

 Cheers, 

 Kenny

   
 
 
 -- 
 Ing. Mario Valle
 Data Analysis and Visualization Group|
 http://www.cscs.ch/~mvalle
 Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91)
 610.82.60
 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91)
 610.82.82
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23978106.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] ctc package

2009-06-11 Thread Allan Engelhardt
The web page recommends installing using biocLite() so that is probably 
what you should do, but see also help(setRepositories) which seems to 
allow you to pick up (a version of) the package using the normal 
install.packages() method if you are somehow adverse to follow the 
recommended practise.


Allan.

Penner, Johannes wrote:

[...]

Searching for a possibility I found this solution in the package ctc
(http://www.bioconductor.org/packages/bioc/html/ctc.html). However,
neither from this site nor via CRAN it is possible to install the
package.

Is there any other possibility? Is the package included in any other
package?

[...]



__
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] Issues getting R to write image files

2009-06-11 Thread Ted Harding
On 11-Jun-09 09:24:42, Tobias Verbeke wrote:
 Hi Kenny,
 
 Have spent the last couple of days learning R and shell scripting to
 do
 batch plotting jobs. I have had success getting R to complete a filled
 contour plot and output to a file (.jpg or .tiff etc). However, when I
 try
 to do the same thing with the simple plot command the script seems to
 execute correctly yet there is no output. Below is my R code: 
 
 file - Sys.getenv(input_file) 
 tiff(paste( file, tiff, sep=.))
 z - read.table(file) 
 plot(z, type=l, xlim=range(0.6,2), col = red, plot.title =
 title(main =
 file, xlab = Wavelength (um), ylab = Intensity (arb.)) 
 
 dev.off()
 
 q() 
 
 You need to close the tiff graphics device you opened
 using dev.off() before quitting.
 
 HTH,
 Tobias

I thought of that too -- since the graphics device needs to be
closed before writing out to the file is completed and the file
is closed.

However, it occurred to me that possibly q() would also have that
effect, since it closes down R which should have the effect of
closing devices, flushing buffers, and closing files (though I do
not see this documented under ?q).

So I experimented.

1. New R session.
2. Assign values to some variables.
3. Open a tiff() device, plot them, and quit R (no dev.off):

  tiff(file=temp.tif)
  plot (X,P,  type=l)
  lines(X,I.b, col=blue )
  lines(X,I.m, col=green)
  lines(X,I.bm^2,  col=red)
  q()

4. End of R session, and temp.tif (which did not exist at the start)
contains a good TIFF file with exactly what I expected to see. This
confirmed my suspicions.

So it sould seem that dev.off() is not the answer.

Probably something is wrong along the line of reading in the data,
or in specifying what to plot. But I can't see anything obvious in
the code, so it may depend on what sort of structure z is, for instance.

Ted.



E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 11-Jun-09   Time: 10:43:51
-- XFMail --

__
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] Help on drawing stars and radars in R (update)

2009-06-11 Thread Barry Rowlingson
On Thu, Jun 11, 2009 at 10:01 AM, Caroline
Gideon-Adeniyic.gideon-adeni...@fashion.arts.ac.uk wrote:
 Hi

 I don't know if you can help. I am a 2nd year Bsc Cosmetic Science student 
 and in R I need some help in drawing stars.

 The problem that I have is I want to recreate a radar diagram similar to the 
 one in excel.

 I have put in these commands in a script window:

  stars(shampoo1[, 1:6], locations = c(0,0), radius = TRUE,
  key.loc=c(0,0),
  main = Ranked Results for the Sensory Evaluation of the Shampoo ,
  frame.plot = TRUE,
  key.labels = c(Foam Texture, Skin Feel, Rinsability, Wet 
 Combability, Wet Feel, Odour),
  lty = 2,
 )

 This gives me a black and white radar which is fine.

 Now according to the reference manual to colour the stars i need to add:

 col.stars = rainbow (30)

 Which colours in each star segment. The problem I have with this is that the 
 segments are filled with colour and the segments overlap each other and each 
 segment is not visible.

 So I desperately need the command that only colours the outline of the 
 segments or stars instead of  filling it.

 This is the example given in the reference manual:

 stars(mtcars[, 1:7], locations = c(0,0), radius = FALSE,
 key.loc=c(0,0), main=Motor Trend Cars, lty = 2)


 Can u help?

 The stars are drawn using R's polygon function, and that has two
colours - the fill colour and the border colour. It seems that the
stars function only lets you set the fill colour and not the border
colour which is what you want.

 It is possible to modify the stars function to also set the border
colour, but that can be a bit beyond beginners skills. I reckon
someone on this list will come up with a modified stars() function
before the end of the day that does it. It might be me, if it wasn't
for the fact I have other things I should be doing!

 All that needs doing is to add a col.border argument to stars, and
then make sure border= is used when stars calls polygon. I've half
done it already.

 Is this the first use of R in cosmetic science? Maybe next time I see
a shampoo advert on TV and they do the 'here comes the science' bit,
we'll see a plot made in R...

 Barry

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


Re: [R] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

Hi all,

Silly missing ) at the end of the plot command! is working now, just need
to remove the V1 and V2 that appear under my axis labels!

Cheers for all your help guys, much appreciated.

Kenny



Ted.Harding-2 wrote:
 
 On 11-Jun-09 09:24:42, Tobias Verbeke wrote:
 Hi Kenny,
 
 Have spent the last couple of days learning R and shell scripting to
 do
 batch plotting jobs. I have had success getting R to complete a filled
 contour plot and output to a file (.jpg or .tiff etc). However, when I
 try
 to do the same thing with the simple plot command the script seems to
 execute correctly yet there is no output. Below is my R code: 
 
 file - Sys.getenv(input_file) 
 tiff(paste( file, tiff, sep=.))
 z - read.table(file) 
 plot(z, type=l, xlim=range(0.6,2), col = red, plot.title =
 title(main =
 file, xlab = Wavelength (um), ylab = Intensity (arb.)) 
 
 dev.off()
 
 q() 
 
 You need to close the tiff graphics device you opened
 using dev.off() before quitting.
 
 HTH,
 Tobias
 
 I thought of that too -- since the graphics device needs to be
 closed before writing out to the file is completed and the file
 is closed.
 
 However, it occurred to me that possibly q() would also have that
 effect, since it closes down R which should have the effect of
 closing devices, flushing buffers, and closing files (though I do
 not see this documented under ?q).
 
 So I experimented.
 
 1. New R session.
 2. Assign values to some variables.
 3. Open a tiff() device, plot them, and quit R (no dev.off):
 
   tiff(file=temp.tif)
   plot (X,P,  type=l)
   lines(X,I.b, col=blue )
   lines(X,I.m, col=green)
   lines(X,I.bm^2,  col=red)
   q()
 
 4. End of R session, and temp.tif (which did not exist at the start)
 contains a good TIFF file with exactly what I expected to see. This
 confirmed my suspicions.
 
 So it sould seem that dev.off() is not the answer.
 
 Probably something is wrong along the line of reading in the data,
 or in specifying what to plot. But I can't see anything obvious in
 the code, so it may depend on what sort of structure z is, for instance.
 
 Ted.
 
 
 
 E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Jun-09   Time: 10:43:51
 -- XFMail --
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23978518.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R Courses in Toronto

2009-06-11 Thread Leo Guelman
Dear R users,

Does anybody know if there any good R courses within the Toronto area?

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-pkgs] package installation fails (RandomFields)

2009-06-11 Thread Dirk Eddelbuettel

Drew,

Wrong list -- please use r-help. Re-directing from r-packages.

On 10 June 2009 at 14:40, Drew Hoysak wrote:
| I have been unable to install the package RandomFields. I am using R 
| 2.9.0-4 on Ubuntu 9.04.
| 
| To install, I use the command:
| sudo R CMD INSTALL RandomFields_1.3.37.tar.gz
| 
| 
| The output follows below. Any help Would be appreciated.
| 
| D. Hoysak
| Brandon University
| 
| 
| * Installing to library ‘/usr/local/lib/R/site-library’
| * Installing *source* package ‘RandomFields’ ...
| ** libs
| g++ -I/usr/share/R/include -g -fpic -g -O2 -c D.H.cc -o D.H.o

[...]

| g++ -shared -o RandomFields.so D.H.o Hyperfcts.o MPP.o MPPFcts.o 
| RFCovFcts.o RFcircembed.o RFdirect.o RFempvario.o RFgetNset.o 
| RFhyperplan.o RFinitNerror.o RFnugget.o RFother.o RFsimu.o RFspectral.o 
| RFtbm.o Xempvario.o addownfctns.o auxiliary.o avltr.o extremes.o 
| modelling.o win_linux_aux.o -llapack -L/usr/lib/R/lib -lR
| /usr/bin/ld: cannot find -llapack
  ^

Did you install r-base-dev, which then pulls in libblas-dev and liblapack-dev
(or their libatlas-* equivalents) as well as a bunch of other -dev packages?

If no do 'sudo apt-get install r-base-dev' and try again.

Dirk

| collect2: ld returned 1 exit status
| make: *** [RandomFields.so] Error 1
| ERROR: compilation failed for package ‘RandomFields’
| * Removing ‘/usr/local/lib/R/site-library/RandomFields’
| 
| ___
| R-packages mailing list
| r-packa...@r-project.org
| https://stat.ethz.ch/mailman/listinfo/r-packages
| 
| __
| 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.

-- 
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] Issues getting R to write image files

2009-06-11 Thread Prof Brian Ripley
q() does call the internal version of graphics.off() which closes all 
open graphics devices.


On Thu, 11 Jun 2009, Mario Valle wrote:


Has tried to close the image file at the end?
Do:
dev.off()

Hope it helps
  mario
Kenny Larsen wrote:
Hi All, 
Have spent the last couple of days learning R and shell scripting to do

batch plotting jobs. I have had success getting R to complete a filled
contour plot and output to a file (.jpg or .tiff etc). However, when I try
to do the same thing with the simple plot command the script seems to
execute correctly yet there is no output. Below is my R code: 
file - Sys.getenv(input_file) tiff(paste( file, tiff, sep=.)) z - 
read.table(file) plot(z, type=l, xlim=range(0.6,2), col = red, 
plot.title = title(main =
file, xlab = Wavelength (um), ylab = Intensity (arb.)) q() 
The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and 
can
clearly write tiff's as it managed it with the filled contours. 
Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 
Cheers, 
Kenny






--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] R Courses in Toronto

2009-06-11 Thread John Fox
Dear Leo,

The York University Statistical Consulting Service often teaches
R-related courses. For past examples, see
http://www.yorku.ca/isr/scs/links.html and
http://www.yorku.ca/isr/spida2009/index.html.

I hope this helps,
 John

On Thu, 11 Jun 2009 06:15:44 -0400
 Leo Guelman leo.guel...@gmail.com wrote:
 Dear R users,
 
 Does anybody know if there any good R courses within the Toronto
 area?
 
 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.


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
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] Error in 1:p : NA/NaN argument when running model comparisons

2009-06-11 Thread Lindsay Banin
Hi there,

I am trying to compare nonlinear least squares regression with AIC and anova. 
The simplest model is one nonlinear curve, and in the more complex model I have 
a categorical variable (producing parameter estimates for four curves).
Both models run fine, but when I try to produce an AIC value for the second 
model I get the error:

 AIC(pow.nls1)
[1] 114408.3
 AIC(pow.nls2)
Error in 1:p : NA/NaN argument

And similarly, when I try to compare the models with ANOVA, I get:

anova(pow.nls1, pow.nls2)
Error in if (df[i]  0) { : missing value where TRUE/FALSE needed

It seemed as if this could be a problem with the dataset, but I have checked 
thoroughly and there are no missing values etc.
What do these error messages actually indicate?

Many thanks in advance!
Lindsay

__
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] triangular plot

2009-06-11 Thread Penner, Johannes
Sorry for probably again an easy question but I can not find the
solution...

Using the ade4 package I am drawing a triangular graph:

triangle.plot(data2, label = row.names(data2), clab=0.6,
show.position=FALSE, box=FALSE)

Which is what I want. Unfortunately the labels have a frame and a white
background. I would like to have them without frame and colour, similar
to what you get with type=text.

I tried various things (box, boxes, label.color and settings of par via
fg or bg=transparent) without luck. Any help is highly appreciated.

Thanks a lot in advance

With kind regards
Johannes

--
Project Coordinator BIOTA West Amphibians

Museum of Natural History
Dep. of Research (Herpetology)
Invalidenstrasse 43
D-10115 Berlin
Tel: +49 (0)30 2093 8708
Fax: +49 (0)30 2093 8565

http://www.biota-africa.org
http://community-ecology.biozentrum.uni-wuerzburg.de

__
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] ctc package

2009-06-11 Thread Penner, Johannes
Dear Allan,

Thank you very much! Sometimes the forest is difficult to see when you
are looking at the trees only... as we would say...

With kind regards
Johannes

__
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] ctc package

2009-06-11 Thread Martin Morgan
Hi Johannes --

Penner, Johannes wrote:
 Dear R-helpers,
 
 I would like to export hierarchical clusters
 
 e.g. fit - hclust(d, method=ward) in the newick format
 
 write(hc2Newick(fit),file='hclust.newick')
 
 Searching for a possibility I found this solution in the package ctc
 (http://www.bioconductor.org/packages/bioc/html/ctc.html). However,
 neither from this site nor via CRAN it is possible to install the
 package.

Not sure what you mean -- did you try

 source(http://bioconductor.org/biocLite.R;)
 biocLite(ctc)

as suggested on the page you mention? If this does not work, then please
provide a transcript showing the error condition; it also helps to
provide the output of the command sessionInfo()

Martin


 
 Is there any other possibility? Is the package included in any other
 package?
 
 Thanks a lot in advance.
 
 With kind regards
 Johannes
 
 --
 Project Coordinator BIOTA West Amphibians
 
 Museum of Natural History
 Dep. of Research (Herpetology)
 Invalidenstrasse 43
 D-10115 Berlin
 Tel: +49 (0)30 2093 8708
 Fax: +49 (0)30 2093 8565
 
 http://www.biota-africa.org
 http://community-ecology.biozentrum.uni-wuerzburg.de
 
 __
 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] triangular plot

2009-06-11 Thread David Winsemius


On Jun 11, 2009, at 8:56 AM, Penner, Johannes wrote:


Sorry for probably again an easy question but I can not find the
solution...

Using the ade4 package I am drawing a triangular graph:

triangle.plot(data2, label = row.names(data2), clab=0.6,
show.position=FALSE, box=FALSE)

Which is what I want. Unfortunately the labels have a frame and a  
white
background. I would like to have them without frame and colour,  
similar

to what you get with type=text.

I tried various things (box, boxes, label.color and settings of par  
via

fg or bg=transparent) without luck. Any help is highly appreciated.

Thanks a lot in advance


triangle.plot does not have optional parameters to be passed to  
accessory functions. Furthermore, it calls scatterutil.eti for the  
plotting of boxes which has hard-coded white background in the boxes.  
As far as I can tell triangle.plot does not pass a color argument for  
the borders of the boxes.


scatterutil.eti
function (x, y, label, clabel, boxes = TRUE, coul = rep(1, length(x)),
horizontal = TRUE)
snipped code
if (boxes) {
rect(x1 - xh/2, y1 - yh/2, x1 + xh/2, y1 + yh/2,
col = white, border = coul[i])
snipped code

scatterutil.eti2
function (x, y, label, clabel, boxes = TRUE, coul = rep(1, length(x)),
horizontal = TRUE)
snipped code
if (boxes) {
rect(x1 - xh/2, y1 - yh/2, x1 + xh/2, y1 + yh/2,
col = transparent, border = coul[i])
snipped code

I made up a triangle.plot2 and a scatterutil.eti2 with  
col=transparent and provision for passing color parameters to the  
borders of the boxes and a got part of the way toward what you are  
asking requesting. There is a remaining glitch when I use the first  
example in the triangle.plot help page. A minority of items still get  
boxes even though they are transparent. Probably has to do with the  
default assignment of coul[i] to border. That could certainly be  
altered as well.


I could not tell exactly what you mean by have them without frame and  
colour either because of your use of the indefinite English pronoun  
or the use of Aristotelean logic. They (the boxes anyway) currently  
have no color. Did you want color added to something? At any rate  
you can do the same sort of function hacking as I did. There are no  
methods or other complicating issues in your way. All the source is  
at the surface.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] problem with the legend when having two plots

2009-06-11 Thread kayj

I am trying to plot survival curves and here is the code

plot(survfit(Surv(days,status)~group, data=g3),
lty=1:2, mark.time=F,
 ylab=Probability,
 xlab=Suvival Time in Month)
legend(10, 0.2,legend=c(Control,RIT), lty=c(2,1),
title=Hormonal Therapy, bty=n)

I will get two survival plots with the Control on the top of the RIT


but if I switch to legend=c(“RIT”,”Control”), I will have the same plots but
now the top on is named as RIT and the bottom as Control!

It does not seem that R can tell which graph corresponds to what, am I
missing something.

Thanks for the help

-- 
View this message in context: 
http://www.nabble.com/problem-with-the-legend-when-having-two-plots-tp23981238p23981238.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] GRASS raster data processing

2009-06-11 Thread Maayt

Hi,

I just imported two raster maps into R using the SPGRASS6 package, one
containing elevation data and the other containing an erosion index:

Kar_inc -readRAST6(Incis_Kar, plugin=FALSE)
Kar_dem - readRAST6(DEM_Kar, plugin=FALSE)

I just wanted to make a xy plot of erosion parameter vs elevation. How does
this work? I don't get how to handle SpatialGridDataFrames...
Thanks a lot
Maarten
-- 
View this message in context: 
http://www.nabble.com/GRASS-raster-data-processing-tp23981740p23981740.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] S4 Package with definition of method 'names'

2009-06-11 Thread Thomas Roth (geb. Kaliwe)

Dear List,

Is it possible to build a package with 'names' method for a S4-Class?

The following  works if directly pasted into R:
(a simple test class with 1 attribute that is returned by invoking 'names')


#class definition
setClass(test, representation = representation(name = character),
 prototype = prototype(name = thisIsMyName))

#definition of names for class test

setMethod(names, test, function(x)
{
 x...@name
}
)

#definition of names- for class test
setReplaceMethod(names, test, function(x, value)
{
x...@name - value
x
}
)


test = new(test)
names(test)  #returns thisIsMyName



However 'R CMD check ' for building a package fails with

Error in setMethod(f, signature, NULL, where = where) :
 the method for function names and signature = is sealed and cannot 
be re-defined
Calls: Anonymous ... sys.source - eval - eval - removeMethod - 
setMethod

Execution halted
make[2]: *** [lazyload] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-DAP] Error 2



This is somewhat confusing since it works nicely if pasted into R.

Any Ideas

Thank you for your time

Thomas Roth

__
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-pkgs] package installation fails (RandomFields)

2009-06-11 Thread William Dunlap
The offending lines don't look right to me:

 38 typedef struct key_type;
261 typedef struct mpp_storage;
309 typedef struct cov_fct;

Shouldn't they be 'typedef struct struct_name typedefed_name'?
Later in the file there are proper typedef's for these things.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Maechler
 Sent: Thursday, June 11, 2009 12:42 AM
 To: Drew Hoysak
 Cc: r-help@r-project.org
 Subject: Re: [R] [R-pkgs] package installation fails (RandomFields)
 
 [[ NOTE:  This accidentally was approved to go to  R-packages,
 it should never have gone there, and I have deleted it
 from the archives.
Please *only* reply to R-help (and the OP)! 
 ]]
 
  DH == Drew Hoysak hoy...@wcgwave.ca
  on Wed, 10 Jun 2009 14:40:32 -0500 writes:
 
 DH I have been unable to install the package 
 RandomFields. I am using R 
 DH 2.9.0-4 on Ubuntu 9.04.
 
 How exactly did you install R?   Just as ubuntu package?  
 {probably, given the somewhat particular version number}
 
 DH To install, I use the command:
 
 DH sudo R CMD INSTALL RandomFields_1.3.37.tar.gz
 
 
 DH The output follows below. Any help Would be appreciated.
 
 DH D. Hoysak
 DH Brandon University
 
 
 DH * Installing to library '/usr/local/lib/R/site-library'
 DH * Installing *source* package 'RandomFields' ...
 DH ** libs
 DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c D.H.cc -o D.H.o
 DH In file included from D.H.cc:27:
 DH RFsimu.h:38: warning: 'typedef' was ignored in this 
 declaration
 DH RFsimu.h:261: warning: 'typedef' was ignored in this 
 declaration
 DH RFsimu.h:309: warning: 'typedef' was ignored in this 
 declaration
 
 [..]
 [..]
 
 DH RFsimu.h:309: warning: 'typedef' was ignored in this 
 declaration
 DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c 
 win_linux_aux.cc -o 
 DH win_linux_aux.o
 DH g++ -shared -o RandomFields.so D.H.o Hyperfcts.o 
 MPP.o MPPFcts.o 
 DH RFCovFcts.o RFcircembed.o RFdirect.o RFempvario.o RFgetNset.o 
 DH RFhyperplan.o RFinitNerror.o RFnugget.o RFother.o 
 RFsimu.o RFspectral.o 
 DH RFtbm.o Xempvario.o addownfctns.o auxiliary.o avltr.o 
 extremes.o 
 DH modelling.o win_linux_aux.o -llapack -L/usr/lib/R/lib -lR
 DH /usr/bin/ld: cannot find -llapack
   ^
 
 This looks like a setup problem of the R installation you have;
 I'd guess that you would also see problems installing other R
 packages that rely on LAPACK.
 
 
 
 DH collect2: ld returned 1 exit status
 DH make: *** [RandomFields.so] Error 1
 DH ERROR: compilation failed for package 'RandomFields'
 DH * Removing '/usr/local/lib/R/site-library/RandomFields'
 
 __
 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] problem with the legend when having two plots

2009-06-11 Thread David Winsemius


On Jun 11, 2009, at 9:23 AM, kayj wrote:



I am trying to plot survival curves and here is the code

plot(survfit(Surv(days,status)~group, data=g3),
lty=1:2, mark.time=F,
ylab=Probability,
xlab=Suvival Time in Month)
legend(10, 0.2,legend=c(Control,RIT), lty=c(2,1),
title=Hormonal Therapy, bty=n)

I will get two survival plots with the Control on the top of the RIT


but if I switch to legend=c(“RIT”,”Control”), I will have the same  
plots but

now the top on is named as RIT and the bottom as Control!

It does not seem that R can tell which graph corresponds to what, am I
missing something.


I think it more that R and the legend function does not do semantic  
checking of plotting activities that preceded it and cannot read  
minds.  You seem to be attributing cognitive capacity to R. Tempting  
for the magical thinking inclined (as we all are to various degrees),  
but not helpful in understanding what a computer does at this stage in  
silicon evolution.


The survfit.object had names for the strata already and you simply  
overwrote that name in the legend. It does not have the facility to  
check to see if the names you supplied reversed any of the internal  
names. You are supposed to know in what order your curves are labeled,  
and if you do not, it is a simple matter to use str() on the survfit  
object. Your approach (reversing both label and line-type should have  
changed only the order that the legend entries appeared  ...  which  
would seem to be useful ability available to you, the wetware operator.




Thanks for the help

--


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Cluster analysis, defining center seeds or number of clusters

2009-06-11 Thread amvds
I use kmeans to classify spectral events in high and low 1/3 octave bands:

#Do cluster analysis
CyclA-data.frame(LlowA,LhghA)
CntrA-matrix(c(0.9,0.8,0.8,0.75,0.65,0.65), nrow = 3, ncol=2, byrow=TRUE)
ClstA-kmeans(CyclA,centers=CntrA,nstart=50,algorithm=MacQueen)

This works well when the actual data shows 1,2 or 3 groups that are not
too close in a cross plot. The MacQueen algorithm will give one or more
empty groups which is what I want.

However, there are cases when the groups are closer together, less compact
or diffuse which leads to the situation where visually only 2 groups are
apparent but the algorithm returns 3 splitting one group in two.

I looked at the package 'cluster' specifically at clara (cannot use pam as
I have 1 observations). But clara always returns as many groups as you
aks for.

Is there a way to help find a seed for the intial cluster centers?
Equivalently, is there a way to find a priori the number of groups?

I know this is not an easy problem. I have looked at principal components
(princomp, prcomp) because there is a connection with cluster analysis. It
is not obvious to me how to program that connection though.

http://en.wikipedia.org/wiki/Principal_Component_Analysis
http://ranger.uta.edu/~chqding/papers/Zha-Kmeans.pdf
http://ranger.uta.edu/~chqding/papers/KmeansPCA1.pdf

Thanks in advance,
Alex van der Spek

__
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] GRASS raster data processing

2009-06-11 Thread Nikos Alexandris

Maayt:
 I just imported two raster maps into R using the SPGRASS6 package, one
 containing elevation data and the other containing an erosion index:

 Kar_inc -readRAST6(Incis_Kar, plugin=FALSE)
 Kar_dem - readRAST6(DEM_Kar, plugin=FALSE)
 
 I just wanted to make a xy plot of erosion parameter vs elevation. How does
 this work? I don't get how to handle SpatialGridDataFrames...


Maarten,

you can check some web-pages with respect to GRASS  R [1][2]. This is a
question for grass-stats actually [3].

A quick answer: check the structure of the newly created object and you
will find that the numbers are to be found in (e.g. for Incis_Kar )
kar_...@data$incis_kar.

So use @data and the $ to access a slot.
Kind regards, Nikos
---

[1] http://grass.osgeo.org/wiki/R
[2] http://grass.ibiblio.org/statsgrass/index.php#grassR
[3] http://grass.osgeo.org/statsgrass/index.php

__
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] Install local package

2009-06-11 Thread Uwe Ligges



Ronggui Huang wrote:

## Check the package

R CMD check path.of.package

## Build the package

R CMD build pathof.package

## INSTALL the package

R CMD INSTALL path.of.package



It is recommended to build the tar.gz first and then isntall and check 
from the tarball rather than from the source directory.


Uwe Ligges



You can use _R --help _  (from within terminal) to get more information.

Ronggui

2009/6/11 Jorge Cornejo cornejo...@gmail.com:

Hi, I'm working on a package that I would someday put in CRAN. Now I
want to test it on my computer. I already check and compile the files
but I don't know how to install the package located on my hard drive.
I'm running R under linux. Can anyone tell my how to do it?

Thanks in advance.

__
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] [R-pkgs] package installation fails (RandomFields)

2009-06-11 Thread Uwe Ligges



William Dunlap wrote:

The offending lines don't look right to me:

 38 typedef struct key_type;
261 typedef struct mpp_storage;
309 typedef struct cov_fct;

Shouldn't they be 'typedef struct struct_name typedefed_name'?
Later in the file there are proper typedef's for these things.



In that case, can you please report it to the RandomFields maintainer?

Thank you very much,
Uwe Ligges



Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  


-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of Martin Maechler

Sent: Thursday, June 11, 2009 12:42 AM
To: Drew Hoysak
Cc: r-help@r-project.org
Subject: Re: [R] [R-pkgs] package installation fails (RandomFields)

[[ NOTE:  This accidentally was approved to go to  R-packages,
  it should never have gone there, and I have deleted it
  from the archives.
   Please *only* reply to R-help (and the OP)! 
]]



DH == Drew Hoysak hoy...@wcgwave.ca
on Wed, 10 Jun 2009 14:40:32 -0500 writes:
DH I have been unable to install the package 
RandomFields. I am using R 
DH 2.9.0-4 on Ubuntu 9.04.


How exactly did you install R?   Just as ubuntu package?  
{probably, given the somewhat particular version number}


DH To install, I use the command:

DH sudo R CMD INSTALL RandomFields_1.3.37.tar.gz


DH The output follows below. Any help Would be appreciated.

DH D. Hoysak
DH Brandon University


DH * Installing to library '/usr/local/lib/R/site-library'
DH * Installing *source* package 'RandomFields' ...
DH ** libs
DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c D.H.cc -o D.H.o
DH In file included from D.H.cc:27:
DH RFsimu.h:38: warning: 'typedef' was ignored in this 
declaration
DH RFsimu.h:261: warning: 'typedef' was ignored in this 
declaration
DH RFsimu.h:309: warning: 'typedef' was ignored in this 
declaration


[..]
[..]

DH RFsimu.h:309: warning: 'typedef' was ignored in this 
declaration
DH g++ -I/usr/share/R/include -g -fpic -g -O2 -c 
win_linux_aux.cc -o 
DH win_linux_aux.o
DH g++ -shared -o RandomFields.so D.H.o Hyperfcts.o 
MPP.o MPPFcts.o 
DH RFCovFcts.o RFcircembed.o RFdirect.o RFempvario.o RFgetNset.o 
DH RFhyperplan.o RFinitNerror.o RFnugget.o RFother.o 
RFsimu.o RFspectral.o 
DH RFtbm.o Xempvario.o addownfctns.o auxiliary.o avltr.o 
extremes.o 
DH modelling.o win_linux_aux.o -llapack -L/usr/lib/R/lib -lR

DH /usr/bin/ld: cannot find -llapack
^

This looks like a setup problem of the R installation you have;
I'd guess that you would also see problems installing other R
packages that rely on LAPACK.



DH collect2: ld returned 1 exit status
DH make: *** [RandomFields.so] Error 1
DH ERROR: compilation failed for package 'RandomFields'
DH * Removing '/usr/local/lib/R/site-library/RandomFields'

__
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-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] Error in 1:p : NA/NaN argument when running model comparisons

2009-06-11 Thread Uwe Ligges



Lindsay Banin wrote:

Hi there,

I am trying to compare nonlinear least squares regression with AIC and anova. 
The simplest model is one nonlinear curve, and in the more complex model I have 
a categorical variable (producing parameter estimates for four curves).
Both models run fine, but when I try to produce an AIC value for the second 
model I get the error:


AIC(pow.nls1)

[1] 114408.3

AIC(pow.nls2)

Error in 1:p : NA/NaN argument



Well, without model specification and data it is impossible for us to 
know why exactly the AIC cannot be calculated.


Uwe Ligges







And similarly, when I try to compare the models with ANOVA, I get:

anova(pow.nls1, pow.nls2)
Error in if (df[i]  0) { : missing value where TRUE/FALSE needed

It seemed as if this could be a problem with the dataset, but I have checked 
thoroughly and there are no missing values etc.
What do these error messages actually indicate?

Many thanks in advance!
Lindsay

__
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] Help on drawing stars and radars in R (update)

2009-06-11 Thread Uwe Ligges



Barry Rowlingson wrote:

On Thu, Jun 11, 2009 at 10:01 AM, Caroline
Gideon-Adeniyic.gideon-adeni...@fashion.arts.ac.uk wrote:

Hi

I don't know if you can help. I am a 2nd year Bsc Cosmetic Science student and 
in R I need some help in drawing stars.

The problem that I have is I want to recreate a radar diagram similar to the 
one in excel.

I have put in these commands in a script window:

 stars(shampoo1[, 1:6], locations = c(0,0), radius = TRUE,
 key.loc=c(0,0),
 main = Ranked Results for the Sensory Evaluation of the Shampoo ,
 frame.plot = TRUE,
 key.labels = c(Foam Texture, Skin Feel, Rinsability, Wet Combability, Wet 
Feel, Odour),
 lty = 2,
)

This gives me a black and white radar which is fine.

Now according to the reference manual to colour the stars i need to add:

col.stars = rainbow (30)

Which colours in each star segment. The problem I have with this is that the 
segments are filled with colour and the segments overlap each other and each 
segment is not visible.

So I desperately need the command that only colours the outline of the segments 
or stars instead of  filling it.

This is the example given in the reference manual:

stars(mtcars[, 1:7], locations = c(0,0), radius = FALSE,
key.loc=c(0,0), main=Motor Trend Cars, lty = 2)


Can u help?


 The stars are drawn using R's polygon function, and that has two
colours - the fill colour and the border colour. It seems that the
stars function only lets you set the fill colour and not the border
colour which is what you want.

 It is possible to modify the stars function to also set the border
colour, but that can be a bit beyond beginners skills. I reckon
someone on this list will come up with a modified stars() function
before the end of the day that does it. It might be me, if it wasn't
for the fact I have other things I should be doing!



OK, if Caroline requests more help here, we are probably both willing to 
add change the two lines of code.




 All that needs doing is to add a col.border argument to stars, and
then make sure border= is used when stars calls polygon. I've half
done it already.

 Is this the first use of R in cosmetic science? 


At least I heard of studies like clinical trials by cosmetic companies 
to proof that some lotions/shampoos really increase some features of 
your skin/hair, Barry.
Well, perhaps I am buying the wrong shampoo and should look at the 
statistics here since the amount of my hair has been reduced 
significantly over the last couple of years.
This does not mean I want to encourage people to send shampoo 
commercials to R-help or my mail address.


Best,
Uwe




 Maybe next time I see

a shampoo advert on TV and they do the 'here comes the science' bit,
we'll see a plot made in R...

 Barry

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


__
R-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] [Ann] RMate, a bundle for TextMate and E-Texteditor

2009-06-11 Thread Hans-Peter Suter
I have uploaded RMate to Github. From the readme:

RMate is a [TextMate](http://macromates.com/) bundle for
[R](http://www.r-project.org/about.html). It is based on the [R/R
Console/Rdaemon](http://svn.textmate.org/trunk/Bundles) bundles and is
focused on:

- easy to use, clear interface/menu
- support for Windows ([E-Texteditor](http://www.e-texteditor.com/))
- editing code, R/Rd snippets and getting help/info
- connect to the standard R frontends (R.app and RGui)

Install via git:pre
INSTDIR=~/Library/Application Support/TextMate/Bundles
cd $INSTDIR
git clone git://github.com/swissr/rmate.tmbundle.git rmate.tmbundle
osascript -e 'tell app TextMate to reload bundles'
/pre

or by hand:pre
- download
  - the [master](http://github.com/swissr/rmate.tmbundle/zipball/master)
(i.e. most recent) version or
  - choose the (latest) tagged version
[here](http://github.com/swissr/rmate.tmbundle/downloads)
- unzip and rename to 'rmate.tmbundle' (i.e. remove swissr- and -hash)
- double click to import into TextMate'
/pre


Cheers,
Hans-Peter

__
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] Syntax question: assigning sparse matrix elements

2009-06-11 Thread Dan Ruderman

Hopefully this is straightfoward.

I have an matrix which is mostly zeroes.  I want to assign it
some non-zero elements whose rows, columns, and values I know.

As a simple example, say I create a 3x2 matrix of zeros:
 m - matrix(rep(0,6),nrow=3)

Now say I want to make the [1,1] and [3,2] elements of this
matrix be non-zer, so I create two vectors, one for rows and one for cols:
 rows - c(1,3)
 cols - c(1,2)

And I have two values to be put in these locations:
 vals - c(-1,1)

What I'd like to do is something like:
 m[rows,cols] - vals

But what I get instead is:

 m
 [,1] [,2]
[1,]   -1   -1
[2,]00
[3,]11


What I hoped to see is:

 m
 [,1] [,2]
[1,]   -10
[2,]00
[3,]01


If anyone can offer some advice I'd be most thankful.

Regards
Dan

__
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] Cluster analysis, defining center seeds or number of clusters

2009-06-11 Thread Christian Hennig

Dear Alex,

actually fixing the number of clusters in kmeans end then ending up with a 
smaller number because of empty clusters is not a standard method of 
estimating the number of clusters. I may happen (as apparently in some of 
your examples), but it is generally rather unusual. In most cases, kmeans, 
as well as clara, pam and other clustering methods, only give you the 
number of clusters you ask for. Even with some reasonable separation 
between clusters kmeans cannot generally be expected to come up with empty 
clusters if the number is initially chosen too high or too many 
initially centers are specified.


The help page for pam.object in library cluster shows you a method to 
estimate the optimal number of clusters based on pam.
However, this problem strongly depends on what cluster concept you have in 
mind and what you want to use your clusters for. There are alternative 
indexes that could be optimised to find the best number of clusters. Some 
of them are implemented in the function cluster.stats in package fpc.
I strongly advise reading some literature about this to understand the 
problem better; the help page of cluster.stats gives a few references.


The BIC gives you an estimate of the number of cluster together with 
Gaussian mixtures, see package mclust.


If you can specify things like maximum within-cluster distances, you may 
get something from using cutree together with a hierarchical clustering 
method in hclust, for example complete linkage.


dbscan and fixmahal in package fpc are further alternatives, requiring
one or two tuning constants to come up with an automatical number of
clusters.

Best regards,
Christian

On Thu, 11 Jun 2009, am...@xs4all.nl wrote:


I use kmeans to classify spectral events in high and low 1/3 octave bands:

#Do cluster analysis
CyclA-data.frame(LlowA,LhghA)
CntrA-matrix(c(0.9,0.8,0.8,0.75,0.65,0.65), nrow = 3, ncol=2, byrow=TRUE)
ClstA-kmeans(CyclA,centers=CntrA,nstart=50,algorithm=MacQueen)

This works well when the actual data shows 1,2 or 3 groups that are not
too close in a cross plot. The MacQueen algorithm will give one or more
empty groups which is what I want.

However, there are cases when the groups are closer together, less compact
or diffuse which leads to the situation where visually only 2 groups are
apparent but the algorithm returns 3 splitting one group in two.

I looked at the package 'cluster' specifically at clara (cannot use pam as
I have 1 observations). But clara always returns as many groups as you
aks for.

Is there a way to help find a seed for the intial cluster centers?
Equivalently, is there a way to find a priori the number of groups?

I know this is not an easy problem. I have looked at principal components
(princomp, prcomp) because there is a connection with cluster analysis. It
is not obvious to me how to program that connection though.

http://en.wikipedia.org/wiki/Principal_Component_Analysis
http://ranger.uta.edu/~chqding/papers/Zha-Kmeans.pdf
http://ranger.uta.edu/~chqding/papers/KmeansPCA1.pdf

Thanks in advance,
Alex van der Spek

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



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

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


[R] need help with strsplit function

2009-06-11 Thread njhuang86

Hi, if I have this string: a.b.c.d and I use this function:
unlist(strsplit(a.b.c.d, \\.)), I get this as my output: a, b, c,
and d. Is there a way to just split on the first period so I obtain only
two pieces like: a and b.c.d? Anyways, thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/need-help-with-strsplit-function-tp23983888p23983888.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] deSolve question

2009-06-11 Thread insun nam
Dear All,

I like to simulate a physiologically based pharmacokinetics model using R
but am having a problem with the daspk routine.

The same problem has been implemented in Berkeley madonna and Winbugs so
that I know that it is working. However, with daspk it is not, and the
numbers are everywhere!

Please see the following and let me know if I am missing something...

Thanks a lot in advance,
In-Sun

#---

library(deSolve)

y - c(Agi = 0,Alu = 0, Abr  = 0, Ah = 0, Ali = 0,  Ak = 0,  Am = 0,  Ask =
0,  Aad  = 0,  Apa  = 0, Asp  = 0, Aar  = 0,  Ave  = 0)
times = seq(0, 100, length=100)

pars - c(
dose = 80 * 0.26,
doseduration = 10,
Vmax = 1.44,
Km = 0.96,
s = 1.33,
fp = 0.236,
Kpfgi=0.324,
Kpflu = 1.092,
Kpfbr= 0.155 ,
Kpfh=0.767,
Kpfli = 0.551,
Kpfk=0.537,
Kpfm=0.339,
Kpfsk=0.784,
Kpfad=0.465,
Kpfpa=0.595,
Kpfsp=0.410,
Qar = 51.9,
Qve = 51.9,
Qgi = 12.3,
Qlu = 51.9,
Qbr = 3.2,
Qh = 6.4,
Qli = 16.5,
Qk = 12.8,
Qm = 7.6,
Qsk = 5.0,
Qad = 0.4,
Qpa = 1.0,
Qsp = 1.0,
Var = 7.0,
Vve = 14.1,
Vgi = 12.4,
Vlu = 1.3,
Vbr = 1.3,
Vh = 1.2,
Vli = 12.4,
Vk = 2.2,
Vm = 140.0,
Vsk = 49.0,
Vad = 11.2,
Vpa = 1.0,
Vsp = 1.0
)

Fun_ODE - function(t,y, pars){
with (as.list(c(y, pars)), {
It - dose/doseduration
Car - Aar/Var
Cve - Ave/Vve
Clu - Alu/Vlu
Cli - Ali/Vli
Cbr - Abr/Vbr
Ch - Ah/Vh
Cpa - Apa/Vpa
Csp - Asp/Vsp
Cgi - Agi/Vgi
Ck - Ak/Vk
Cm - Am/Vm
Cad - Aad/Vad
Csk - Ask/Vsk

Kpbbr - s*fp*Kpfbr
Kpbli - s*fp*Kpfli
Kpbh - s*fp*Kpfh
Kpbpa - s*fp*Kpfpa
Kpbsp - s*fp*Kpfsp
Kpbgi - s*fp*Kpfgi
Kpbk - s*fp*Kpfk
Kpbm - s*fp*Kpfm
Kpbad - s*fp*Kpfad
Kpbsk - s*fp*Kpfsk
Kpblu - s*fp*Kpflu

dAar - (Clu/Kpblu - Car)*Qar
dAve - if (t  10) It + Cbr*Qbr/Kpbbr + Ch *Qh/Kpbh + Cli*Qli/Kpbli +
Ck*Qk/Kpbk + Cm*Qm/Kpbm + Csk * Qsk /Kpbsk + Cad*Qad/Kpbad - Cve*Qve

else Cbr*Qbr/Kpbbr + Ch *Qh/Kpbh + Cli*Qli/Kpbli + Ck*Qk/Kpbk +
Cm*Qm/Kpbm + Csk * Qsk /Kpbsk + Cad*Qad/Kpbad - Cve*Qve
dAlu - (Cve-Clu/Kpblu)*Qlu

dAli - ((Qli - Qgi- Qpa-Qsp)*Car + Cgi*Qgi/Kpbgi + Csp*Qsp/Kpbsp +
Cpa*Qpa/Kpbpa - Cli*Qli/Kpbli) - Vmax*Cli/Kpfli/(Km + Cli/Kpfli)
dAbr - (Car - Cbr/Kpbbr)*Qbr
dAh - (Car - Ch/Kpbh)*Qh
dApa - (Car - Cpa/Kpbpa)*Qpa
dAsp - (Car - Csp/Kpbsp)*Qsp
dAgi - (Car - Cgi/Kpbgi)*Qgi
dAk - (Car - Ck/Kpbk)*Qk
dAm - (Car - Cm/Kpbm)*Qm
dAad - (Car - Cad/Kpbad)*Qad
dAsk - (Car - Csk/Kpbsk)*Qsk

return(list(dy = c(dAar, dAve, dAlu, dAli, dAbr, dAh, dApa, dAsp, dAgi, dAk,
dAm, dAad, dAsk),
Car = Car, Cve=Cve, Clu=Clu, Cli=Cli, Cbr=Cbr, Ch=Ch, Cpa=Cpa,
Csp=Csp, Cgi=Cgi, Ck=Ck, Cm=Cm, Cad=Cad, Csk=Csk))
})
}

ODE - as.data.frame(daspk(y = y, times = times, func = Fun_ODE,
parms = pars, atol = 1e-10, rtol = 1e-10))




-- 
Dr In-Sun Nam Knutsson
Research Associate
The Centre for Applied Pharmacokinetic Research (CAPKR)
School of Pharmacy and Pharmaceutical Sciences
University of Manchester
Stopford Building
Oxford Road
Manchester
U.K.
Phone: +44 161 275 2355
Email: in-sunnam.knuts...@manchester.ac.uk

[[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-pkgs] package installation fails (RandomFields) - SOLVED

2009-06-11 Thread Drew Hoysak

Thanks to all who replied so quickly.

Installing liblapack-dev solved the problem and I can now install 
RandomFields.




Drew Hoysak
Brandon University

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


[R] How to force R to print 2 decimal places in column of a data.frame?

2009-06-11 Thread Lesandro

How to force R to print 2 decimal places in column of a data.frame? I tried to 
do so:

x = inp(format(rounf(inp$Tamanho, 2), nsmall = 2),)

where INP is data.frame and Size is the name of column. But has error:

Error in eval.with.vis(expr, envir, enclos) : 
  could not find function inp

Lesandro


  Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

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


Re: [R] need help with strsplit function

2009-06-11 Thread Gabor Grothendieck
Using strapply in gsubfn we can match by contents rather than
delimiter.  Parentheses in the regular expression
surround captured portions.  The first such captured portion is
any string not containing a dot.  We then follow that by matching
a dot and a second captured expression which is anything.
c just concatenates the captured strings into a vector of strings.

 x - a.b.c.d
 library(gsubfn)
Loading required package: proto
 strapply(x, ([^.]*)[.](.*), c)
[[1]]
[1] a b.c.d


On Thu, Jun 11, 2009 at 11:44 AM, njhuang86njhuan...@yahoo.com wrote:

 Hi, if I have this string: a.b.c.d and I use this function:
 unlist(strsplit(a.b.c.d, \\.)), I get this as my output: a, b, c,
 and d. Is there a way to just split on the first period so I obtain only
 two pieces like: a and b.c.d? Anyways, thanks in advance!
 --
 View this message in context: 
 http://www.nabble.com/need-help-with-strsplit-function-tp23983888p23983888.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] need help with strsplit function

2009-06-11 Thread Marc Schwartz


On Jun 11, 2009, at 10:44 AM, njhuang86 wrote:



Hi, if I have this string: a.b.c.d and I use this function:
unlist(strsplit(a.b.c.d, \\.)), I get this as my output: a,  
b, c,
and d. Is there a way to just split on the first period so I  
obtain only

two pieces like: a and b.c.d? Anyways, thanks in advance!



Try this:

 strsplit(sub(\\., *, a.b.c.d), \\*)
[[1]]
[1] a b.c.d


The inner sub() replaces the first '.' with a '*' allowing you to  
split on the unique character. You can modify the replacement  
character as your data may actually require.


HTH,

Marc Schwartz

__
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] Expand a contingency table based on the value in one column

2009-06-11 Thread Mark Na
Hi R-helpers,

I have the following (dummy) dataframe:

 test
  DATE LOCATION  KIND CLASS COUNT
111   CAR A 2
211 TRUCK D 3
311   BUS E 4
412   CAR E 2
512 TRUCK A 7
612   BUS F 1

That I would like to turn into this:

 test2
   DATE LOCATION  KIND CLASS
1 11   CAR A
2 11   CAR A
3 11 TRUCK D
4 11 TRUCK D
5 11 TRUCK D
6 11   BUS E
7 11   BUS E
8 11   BUS E
9 11   BUS E
1012   CAR E
1112   CAR E
1212 TRUCK A
1312 TRUCK A
1412 TRUCK A
1512 TRUCK A
1612 TRUCK A
1712 TRUCK A
1812 TRUCK A
1912   BUS F

So, basically it's a case of expanding (adding rows to) the first dataframe
by the value in the COUNT column.

I have solved this problem with the following code:

test2-with(test, data.frame(DATE=rep(DATE,COUNT),
LOCATION=rep(LOCATION,COUNT), KIND=rep(KIND,COUNT), CLASS=rep(CLASS,COUNT)))

but I'm unsatisfied with that solution because it's verbose and I think
there must a more elegant way. If I had more variables than 4 (which I do in
my real data) it would be a nuisance to repeat each column within the rep
function.

I would prefer to do this with Base R or package(reshape) than relying on
another package.

Any ideas? Thanks!

Mark Na

[[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] saving loess fit

2009-06-11 Thread Lana Schaffer

Hi,

pv.lo - loess(Affy ~ DABG, DA, span=0.2, degree=2, family=symmetric)

I would like to know how to save the output from the loess fit
so that I can read it again into another session of R.  
Can someone help me figure this out?

Lana Schaffer
Biostatistics/Informatics
The Scripps Research Institute
DNA Array Core Facility
La Jolla, CA 92037
(858) 784-2263
(858) 784-2994
schaf...@scripps.edu 

__
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 in Installing

2009-06-11 Thread Alon Ben-Ari
Hello, I have openSUSE 11.1
Trying to install randomForest
as SU  after invoking R   install.packages(randomForest)

and I get this

* Installing *source* package ‘randomForest’ ...
** libs
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
classTree.c -o classTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
regTree.c -o regTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
regrf.c -o regrf.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
rf.c -o rf.o
gfortran   -fpic  -O2 -c rfsub.f -o rfsub.o
make: gfortran: Command not found
make: *** [rfsub.o] Error 127
ERROR: compilation failed for package ‘randomForest’
* Removing ‘/usr/lib/R/library/randomForest’

The downloaded packages are in
‘/tmp/RtmpLEyfgR/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages(randomForest) :
  installation of package 'randomForest' had non-zero exit status



I checked that I have th  fortran library

S | Name  | Summary  | Type
--+---+--+
i | libgfortran41 | The GNU Fortran Compiler Runtime Library | package
i | libgfortran43 | The GNU Fortran Compiler Runtime Library | package

Any ideas how to solve this impass?

Alon Ben-Ari, MD
Dept Of Anesthesiology.
University of Pittsburgh

[[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] Expand a contingency table based on the value in one column

2009-06-11 Thread David Winsemius


On Jun 11, 2009, at 1:13 PM, Mark Na wrote:


Hi R-helpers,

I have the following (dummy) dataframe:


test

 DATE LOCATION  KIND CLASS COUNT
111   CAR A 2
211 TRUCK D 3
311   BUS E 4
412   CAR E 2
512 TRUCK A 7
612   BUS F 1

That I would like to turn into this:


test2

  DATE LOCATION  KIND CLASS
1 11   CAR A
2 11   CAR A
3 11 TRUCK D
4 11 TRUCK D
5 11 TRUCK D
6 11   BUS E
7 11   BUS E
8 11   BUS E
9 11   BUS E
1012   CAR E
1112   CAR E
1212 TRUCK A
1312 TRUCK A
1412 TRUCK A
1512 TRUCK A
1612 TRUCK A
1712 TRUCK A
1812 TRUCK A
1912   BUS F



 test2 - test[rep(1:nrow(test), test$COUNT),]
 rownames(test2) - 1:nrow(test2)
 test2


So, basically it's a case of expanding (adding rows to) the first  
dataframe

by the value in the COUNT column.

I have solved this problem with the following code:

test2-with(test, data.frame(DATE=rep(DATE,COUNT),
LOCATION=rep(LOCATION,COUNT), KIND=rep(KIND,COUNT),  
CLASS=rep(CLASS,COUNT)))


but I'm unsatisfied with that solution because it's verbose and I  
think
there must a more elegant way. If I had more variables than 4 (which  
I do in
my real data) it would be a nuisance to repeat each column within  
the rep

function.

I would prefer to do this with Base R or package(reshape) than  
relying on

another package.

Any ideas? Thanks!

Mark Na

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Syntax question: assigning sparse matrix elements

2009-06-11 Thread Duncan Murdoch

On 6/11/2009 12:34 PM, Dan Ruderman wrote:

Hopefully this is straightfoward.

I have an matrix which is mostly zeroes.  I want to assign it
some non-zero elements whose rows, columns, and values I know.

As a simple example, say I create a 3x2 matrix of zeros:

m - matrix(rep(0,6),nrow=3)


Now say I want to make the [1,1] and [3,2] elements of this
matrix be non-zer, so I create two vectors, one for rows and one for cols:

rows - c(1,3)
cols - c(1,2)


And I have two values to be put in these locations:

vals - c(-1,1)


What I'd like to do is something like:

m[rows,cols] - vals


But what I get instead is:


m

 [,1] [,2]
[1,]   -1   -1
[2,]00
[3,]11


What I hoped to see is:


m

 [,1] [,2]
[1,]   -10
[2,]00
[3,]01


If anyone can offer some advice I'd be most thankful.


If the index to a matrix is a two column matrix, then the first column 
is taken to be a row number, the second a column number.  So you get 
what you want with


m[cbind(rows,cols)] - vals

This is discussed (and other indexing methods too) in the R Language 
Definition manual in the section on indexing matrices and arrays.


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] Restrict AIC comparison to succesful models?

2009-06-11 Thread Manuel Morales
Hello list,

I'm doing a bootstrap analysis where some models occasionally fail to
converge. I'd like to automate the process of restricting AIC to the
models that do converge. A contrived example of what I'd like to do is
below:

resp - c(1,1,2)
pred - c(1,2,3)

m1 - lm(resp~pred)
m2 - lm(resp~poly(pred,2))
m3 - lm(resp~poly(pred,3)) # Fails, obviously

## Some test to see which models were successful
models - test(m1,m2,m3)

## AIC on these models only
AIC(models)

-- 
http://mutualism.williams.edu

__
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] gfortran command not found?

2009-06-11 Thread Alon Ben-Ari
Hello, I have openSUSE 11.1
Trying to install randomForest
as SU  after invoking R   install.packages(randomForest)

and I get this

* Installing *source* package ‘randomForest’ ...
** libs
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
classTree.c -o classTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
regTree.c -o regTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
regrf.c -o regrf.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  -O2 -c
rf.c -o rf.o
gfortran   -fpic  -O2 -c rfsub.f -o rfsub.o
make: gfortran: Command not found
make: *** [rfsub.o] Error 127
ERROR: compilation failed for package ‘randomForest’
* Removing ‘/usr/lib/R/library/randomForest’

The downloaded packages are in
‘/tmp/RtmpLEyfgR/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages(randomForest) :
  installation of package 'randomForest' had non-zero exit status



I checked that I have th  fortran library

S | Name  | Summary  | Type
--+---+--+
i | libgfortran41 | The GNU Fortran Compiler Runtime Library | package
i | libgfortran43 | The GNU Fortran Compiler Runtime Library | package

Any ideas how to solve this impass?

Alon Ben-Ari, MD
Dept Of Anesthesiology.
University of Pittsburgh

[[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] Expand a contingency table based on the value in one column

2009-06-11 Thread Marc Schwartz


On Jun 11, 2009, at 12:13 PM, Mark Na wrote:


Hi R-helpers,

I have the following (dummy) dataframe:


test

 DATE LOCATION  KIND CLASS COUNT
111   CAR A 2
211 TRUCK D 3
311   BUS E 4
412   CAR E 2
512 TRUCK A 7
612   BUS F 1

That I would like to turn into this:


test2

  DATE LOCATION  KIND CLASS
1 11   CAR A
2 11   CAR A
3 11 TRUCK D
4 11 TRUCK D
5 11 TRUCK D
6 11   BUS E
7 11   BUS E
8 11   BUS E
9 11   BUS E
1012   CAR E
1112   CAR E
1212 TRUCK A
1312 TRUCK A
1412 TRUCK A
1512 TRUCK A
1612 TRUCK A
1712 TRUCK A
1812 TRUCK A
1912   BUS F

So, basically it's a case of expanding (adding rows to) the first  
dataframe

by the value in the COUNT column.

I have solved this problem with the following code:

test2-with(test, data.frame(DATE=rep(DATE,COUNT),
LOCATION=rep(LOCATION,COUNT), KIND=rep(KIND,COUNT),  
CLASS=rep(CLASS,COUNT)))


but I'm unsatisfied with that solution because it's verbose and I  
think
there must a more elegant way. If I had more variables than 4 (which  
I do in
my real data) it would be a nuisance to repeat each column within  
the rep

function.

I would prefer to do this with Base R or package(reshape) than  
relying on

another package.

Any ideas? Thanks!

Mark Na



Mark,

A quick and dirty solution:

 test[rep(1:nrow(test), test$COUNT), -ncol(test)]
DATE LOCATION  KIND CLASS
1  11   CAR A
1.111   CAR A
2  11 TRUCK D
2.111 TRUCK D
2.211 TRUCK D
3  11   BUS E
3.111   BUS E
3.211   BUS E
3.311   BUS E
4  12   CAR E
4.112   CAR E
5  12 TRUCK A
5.112 TRUCK A
5.212 TRUCK A
5.312 TRUCK A
5.412 TRUCK A
5.512 TRUCK A
5.612 TRUCK A
6  12   BUS F


For a more general solution to taking a tabulated data frame and  
converting it back to the raw data see my expand.dft() function:


  https://stat.ethz.ch/pipermail/r-help/2009-January/185561.html

For example:

 expand.dft(test, freq = COUNT)
   DATE LOCATION  KIND CLASS
1 11   CAR A
2 11   CAR A
3 11 TRUCK D
4 11 TRUCK D
5 11 TRUCK D
6 11   BUS E
7 11   BUS E
8 11   BUS E
9 11   BUS E
1012   CAR E
1112   CAR E
1212 TRUCK A
1312 TRUCK A
1412 TRUCK A
1512 TRUCK A
1612 TRUCK A
1712 TRUCK A
1812 TRUCK A
1912   BUS F



HTH,

Marc Schwartz

__
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] Installing the Rstem package

2009-06-11 Thread Rajan, Ravi
Hi,

 

I can't find the package for LSA. When I try
http://www.statistik.uni-dortmund.de/~ligges/Rstem_0.3-1.zip
http://www.statistik.uni-dortmund.de/%7Eligges/Rstem_0.3-1.zip 

It says file not found.

Is there an updated link?

 

Ravi


__

This email message is for the sole use of the intended r...{{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] saving loess fit

2009-06-11 Thread Henrik Bengtsson
See save() and load(), but the following might be easier because it
does not mess with your existing object names:

library(R.utils)
saveObject(pv.lo, myLoessFit.Rbin)
pv.lo - loadObject(myLoessFit.Rbin)

foo - loadObject(myLoessFit.Rbin)
print(identical(pv.lo, foo))  # = TRUE

/Henrik


On Thu, Jun 11, 2009 at 10:22 AM, Lana Schafferschaf...@scripps.edu wrote:

 Hi,

 pv.lo - loess(Affy ~ DABG, DA, span=0.2, degree=2, family=symmetric)

 I would like to know how to save the output from the loess fit
 so that I can read it again into another session of R.
 Can someone help me figure this out?

 Lana Schaffer
 Biostatistics/Informatics
 The Scripps Research Institute
 DNA Array Core Facility
 La Jolla, CA 92037
 (858) 784-2263
 (858) 784-2994
 schaf...@scripps.edu

 __
 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] Installing the Rstem package

2009-06-11 Thread Henrik Bengtsson
Google Rstem package - first hit. It is hosted by the Omegahat project. /H

On Thu, Jun 11, 2009 at 10:29 AM, Rajan, Ravira...@rand.org wrote:
 Hi,



 I can't find the package for LSA. When I try
 http://www.statistik.uni-dortmund.de/~ligges/Rstem_0.3-1.zip
 http://www.statistik.uni-dortmund.de/%7Eligges/Rstem_0.3-1.zip

 It says file not found.

 Is there an updated link?



 Ravi


 __

 This email message is for the sole use of the intended r...{{dropped:9}}

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


__
R-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] Installing the Rstem package

2009-06-11 Thread Marc Schwartz
Yep...except it looks like the package has not been submitted to CRAN  
for some time, which would facilitate the building of a Windows  
binary. From a check of the list archives, it looks like Uwe's link  
was a temporary solution.


Prof Ripley appears to be building a binary of the package and the  
2.9.0 version is available from:


  http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9/

HTH,

Marc Schwartz


On Jun 11, 2009, at 12:57 PM, Henrik Bengtsson wrote:

Google Rstem package - first hit. It is hosted by the Omegahat  
project. /H


On Thu, Jun 11, 2009 at 10:29 AM, Rajan, Ravira...@rand.org wrote:

Hi,



I can't find the package for LSA. When I try
http://www.statistik.uni-dortmund.de/~ligges/Rstem_0.3-1.zip
http://www.statistik.uni-dortmund.de/%7Eligges/Rstem_0.3-1.zip

It says file not found.

Is there an updated link?



Ravi


__
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] gfortran command not found?

2009-06-11 Thread Marc Schwartz

On Jun 11, 2009, at 12:34 PM, Alon Ben-Ari wrote:


Hello, I have openSUSE 11.1
Trying to install randomForest
as SU  after invoking R   install.packages(randomForest)

and I get this

* Installing *source* package ‘randomForest’ ...
** libs
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  - 
O2 -c

classTree.c -o classTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  - 
O2 -c

regTree.c -o regTree.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  - 
O2 -c

regrf.c -o regrf.o
gcc -std=gnu99 -I/usr/lib/R/include  -I/usr/local/include-fpic  - 
O2 -c

rf.c -o rf.o
gfortran   -fpic  -O2 -c rfsub.f -o rfsub.o
make: gfortran: Command not found
make: *** [rfsub.o] Error 127
ERROR: compilation failed for package ‘randomForest’
* Removing ‘/usr/lib/R/library/randomForest’

The downloaded packages are in
   ‘/tmp/RtmpLEyfgR/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning message:
In install.packages(randomForest) :
 installation of package 'randomForest' had non-zero exit status





I checked that I have th  fortran library

S | Name  | Summary  | Type
--+---+--+
i | libgfortran41 | The GNU Fortran Compiler Runtime Library | package
i | libgfortran43 | The GNU Fortran Compiler Runtime Library | package

Any ideas how to solve this impass?




I have not worked on SUSE, but check to see where gfortran is located:

  $ which gfortran

and be sure that it returns the path to the executable and that the  
path to it is in your $PATH.


You might also want to review:

  http://cran.r-project.org/doc/manuals/R-admin.html#Using-FORTRAN

HTH,

Marc Schwartz

__
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 force R to print 2 decimal places in column of a data.frame?

2009-06-11 Thread Marc Schwartz


On Jun 11, 2009, at 11:48 AM, Lesandro wrote:



How to force R to print 2 decimal places in column of a data.frame?  
I tried to do so:


x = inp(format(rounf(inp$Tamanho, 2), nsmall = 2),)

where INP is data.frame and Size is the name of column. But has  
error:


Error in eval.with.vis(expr, envir, enclos) :
 could not find function inp

Lesandro




Your code and description above appear to have some typos in it and  
the use of the round() and format() functions are not what you want  
here.


You code has inp(...), where R is presuming that you are referring to  
a function called 'inp', hence the error message, since the function  
does not exist.


Better to use sprintf() with an appropriate format specifier:

set.seed(1)
vec - rnorm(10)

 vec
 [1] -0.6264538  0.1836433 -0.8356286  1.5952808  0.3295078 -0.8204684
 [7]  0.4874291  0.7383247  0.5757814 -0.3053884

 sprintf(%.2f, vec)
 [1] -0.63 0.18  -0.84 1.60  0.33  -0.82 0.49  0.74
 [9] 0.58  -0.31

See ?sprintf for more information.  Note that the presumption here is  
that you want to output the numeric values to a formatted character  
vector for display purposes, perhaps in a table, etc.


So if your actual data frame is called 'INP' and the column is called  
'Size', you would use:


  sprintf(%.2f, INP$Size)


HTH,

Marc Schwartz

__
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] Matrix manipulation

2009-06-11 Thread Payam Minoofar
Hello everyone,

I have a couple of fairly simple questions (I hope) the answers to which I 
cannot find through the documentation at the moment.


 1.  I would like to delete the a row from a matrix if a certain elimination 
criterion is met. I am familiar with x - x[-7,] (to remove row 7, for 
example). Are there any other means of removing an entire row?
 2.  Is there a single command that will rename the index of each row to match 
the row number once a row has been deleted. For example, when row 7 is deleted 
above, the old row 8 is now row 7, but the row name is still 8. I have 
figured out how to assign a sequence vector to the row names, but I am 
wondering if there is a built-in command that does the same thing. (I.e., 
change the name of row 7 to 7 from 8.)

Thank you very much.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


[[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] Installing the Rstem package

2009-06-11 Thread Prof Brian Ripley

On Thu, 11 Jun 2009, Marc Schwartz wrote:

Yep...except it looks like the package has not been submitted to CRAN for 
some time, which would facilitate the building of a Windows binary. From a 
check of the list archives, it looks like Uwe's link was a temporary 
solution.


It is perhaps worth noting that until ca a year ago Omegahat did 
distribute Windows binaries, but no longer (as far as I recall they 
existed for R 2.7.x but not 2.8.x, and I know for sure not for R 
2.9.x).


Prof Ripley appears to be building a binary of the package and the 2.9.0 
version is available from:


http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9/


And in the corresponding directory for 2.8.x (an older version of 
Rstem), which means that Rstem should just install from the Rgui menus 
for users of recent versions of R.  (Assumming this is for Windows -- 
we were not actually told).


For the record, Windows builds of the Omegahat packages

RCurl, XML (also on CRAN)
Rcompression, SSOAP, Rstem, XMLSchema

are on CRANextras.  Builds of (in some cases older versions) of RCurl, 
Rlibstree, SSOAP, XML and XMLSchema are available from 'BioC extras' 
(which you can select as a repository from the menu).




HTH,

Marc Schwartz


On Jun 11, 2009, at 12:57 PM, Henrik Bengtsson wrote:

Google Rstem package - first hit. It is hosted by the Omegahat project. 
/H


On Thu, Jun 11, 2009 at 10:29 AM, Rajan, Ravira...@rand.org wrote:

Hi,



I can't find the package for LSA. When I try
http://www.statistik.uni-dortmund.de/~ligges/Rstem_0.3-1.zip
http://www.statistik.uni-dortmund.de/%7Eligges/Rstem_0.3-1.zip

It says file not found.

Is there an updated link?



Ravi


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


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] Re strict AIC comparison to succesful models?

2009-06-11 Thread Ben Bolker



Manuel Morales wrote:
 
 Hello list,
 
 I'm doing a bootstrap analysis where some models occasionally fail to
 converge. I'd like to automate the process of restricting AIC to the
 models that do converge. A contrived example of what I'd like to do is
 below:
 
 resp - c(1,1,2)
 pred - c(1,2,3)
 
 m1 - lm(resp~pred)
 m2 - lm(resp~poly(pred,2))
 m3 - lm(resp~poly(pred,3)) # Fails, obviously
 
 ## Some test to see which models were successful
 models - test(m1,m2,m3)
 

How about 

models - list(m1,m2,m3)
is.OK - sapply(models,test)
do.call(AIC,models[is.OK])

  ?

-- 
View this message in context: 
http://www.nabble.com/Restrict-AIC-comparison-to-succesful-models--tp23985797p23987185.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Count observation

2009-06-11 Thread MarcioRibeiro

Hi listers,
I have the following code...

data-as.matrix(c(1,2,3,4,5,6,7,8,9,10),nrow=10,ncol=1,byrow=TRUE)
n-nrow(data)
m-n-1
boot-data[sample(m,replace=T),]

So, I need to count the number of times each observation was selected at the
sample with replacement...
Suppose I sampled...
4 5 1 3 7 5 1 4 7

So, I would count...
x  count
1  2
2  0
3  1
4  2
5  2
6  0
7  2
8  0
9  0
10 0

Thanks in advance,
Marcio
-- 
View this message in context: 
http://www.nabble.com/Count-observation-tp23987251p23987251.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] standard error beta glm

2009-06-11 Thread Ricardo Arias Brito

Dear All,

The std. error of the estimated coefficients 
obtained by the summary.lm function can be calculated
as:

y=rnorm(20)
x=y+rnorm(20)
fit - lm(y ~ x)
summary(fit)

sqrt(  sum(fit$resid**2)/fit$df.resid  * 
solve(t(model.matrix(fit))%*%model.matrix(fit))  )

Is posible calculate Std. Error for glm as lm, using
cov(hat beta) = phi * solve(t(X) %*% hat W %*% X)^-1
on R? Who is hat W and phi output glm?

y=rpois(20,4)
fit.glm - glm(y ~ x, family=poisson
summary(fit.glm)


Fitted to a model glm using constrast contr.sum and need compute
the error standard for last level of the factor.
 

best wishes for all,

Ricardo.













  Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

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


Re: [R] Count observation

2009-06-11 Thread milton ruser
Hi Marcio,

data.frame(table(boot))
?

milton
brazil=toronto
On Thu, Jun 11, 2009 at 3:13 PM, MarcioRibeiro mes...@pop.com.br wrote:


 Hi listers,
 I have the following code...

 data-as.matrix(c(1,2,3,4,5,6,7,8,9,10),nrow=10,ncol=1,byrow=TRUE)
 n-nrow(data)
 m-n-1
 boot-data[sample(m,replace=T),]

 So, I need to count the number of times each observation was selected at
 the
 sample with replacement...
 Suppose I sampled...
 4 5 1 3 7 5 1 4 7

 So, I would count...
 x  count
 1  2
 2  0
 3  1
 4  2
 5  2
 6  0
 7  2
 8  0
 9  0
 10 0

 Thanks in advance,
 Marcio
 --
 View this message in context:
 http://www.nabble.com/Count-observation-tp23987251p23987251.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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] formula for degrees of freedom for nonlinear mixed model in nlme

2009-06-11 Thread J S

Dear forum members,
 
What is the formula to calculate denominator degrees of freedom (den df) for 
nonlinear mixed-effect models with covariates? My model is similar to a CO2 
uptake example from  Pinheiro and Bates (2000, page 376). In this CO2 dataset, 
there are two treatments and two types (84 observations in total), but den df 
for each parameter of the model is 64. Isn’t it too high? 
 
Your help is greatly appreciated,
Julia
 
Summary of the CO2 example:
 
 summary(fm4CO2.nlme)
Nonlinear mixed-effects model fit by maximum likelihood
  Model: uptake ~ SSasympOff(conc, Asym, lrc, c0) 
 Data: CO2 
   AIC  BIClogLik
  388.4185 420.0191 -181.2092
 
Random effects:
 Formula: list(Asym ~ 1, lrc ~ 1)
 Level: Plant
 Structure: General positive-definite, Log-Cholesky parametrization
 StdDev   Corr  
Asym.(Intercept) 2.349640 As.(I)
lrc.(Intercept)  0.079597 -0.92 
Residual 1.791962   
 
Fixed effects: list(Asym + lrc ~ Type * Treatment, c0 ~ 1) 
  Value Std.Error DF   t-value p-value
Asym.(Intercept)   41.81756  1.562426 64  26.76451  0.
Asym.TypeMississippi  -10.53045  2.208318 64  -4.76854  0.
Asym.Treatmentchilled  -2.96943  2.213172 64  -1.34171  0.1844
Asym.TypeMississippi:Treatmentchilled -10.90037  3.112220 64  -3.50244  0.0008
lrc.(Intercept)-4.55724  0.096291 64 -47.32785  0.
lrc.TypeMississippi-0.10412  0.121683 64  -0.85570  0.3954
lrc.Treatmentchilled   -0.17124  0.111959 64  -1.52953  0.1311
lrc.TypeMississippi:Treatmentchilled0.74188  0.221742 64   3.34570  0.0014
c0 50.51075  4.364727 64  11.57249  0.
 Correlation: 
  As.(I) Asy.TM Asym.T A.TM:T lr.(I) lrc.TM
Asym.TypeMississippi  -0.703   
Asym.Treatmentchilled -0.701  0.496
Asym.TypeMississippi:Treatmentchilled  0.497 -0.709 -0.711 
lrc.(Intercept)   -0.627  0.415  0.407 -0.278  
lrc.TypeMississippi0.458 -0.680 -0.322  0.482 -0.535   
lrc.Treatmentchilled   0.500 -0.351 -0.717  0.509 -0.594  0.445
lrc.TypeMississippi:Treatmentchilled  -0.262  0.375  0.362 -0.547  0.365 -0.553
c0-0.086  0.014  0.001  0.019  0.590 -0.033
  lrc.Tr l.TM:T
Asym.TypeMississippi   
Asym.Treatmentchilled  
Asym.TypeMississippi:Treatmentchilled  
lrc.(Intercept)
lrc.TypeMississippi
lrc.Treatmentchilled   
lrc.TypeMississippi:Treatmentchilled  -0.511   
c0-0.057  0.140
 
Standardized Within-Group Residuals:
Min  Q1 Med  Q3 Max 
-2.86206487 -0.49445730 -0.04217037  0.56599012  3.04061332 
 
Number of Observations: 84
Number of Groups: 12 
 
Link to the book:
http://books.google.com/books?id=N3WeyHFbHLQCpg=PA139lpg=PA139dq=mixed-effect+model+building+first+stepsource=blots=pR7PWIuKu8sig=TLhq-k5O4ZNwkBWcyQI8VZk9Umkhl=enei=1HguSrKaPJi0Nb3DnfUJsa=Xoi=book_resultct=resultresnum=1#PPA376,M1
 
 

_


[[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] Count observation

2009-06-11 Thread Jorge Ivan Velez
Dear Marcio,
Here is one way. Please notice that even thought I changed the name of your
data as well as its structure, you can easily modify it to your needs.

# Data
somedata - 1:10
n-length(somedata)
m-n-1

# 1 sample
boot - somedata[ sample(m,replace=T) ]
table(factor( boot, levels=1:10 ) )

# 100 samples
boots - replicate(100, somedata[ sample(m,replace=T)] )

# The counts
apply(boots, 2, function(x) table(factor(x,levels=1:10)) )

see ?replicate, and ?apply for more information.

HTH,

Jorge



On Thu, Jun 11, 2009 at 3:13 PM, MarcioRibeiro mes...@pop.com.br wrote:


 Hi listers,
 I have the following code...

 data-as.matrix(c(1,2,3,4,5,6,7,8,9,10),nrow=10,ncol=1,byrow=TRUE)
 n-nrow(data)
 m-n-1
 boot-data[sample(m,replace=T),]

 So, I need to count the number of times each observation was selected at
 the
 sample with replacement...
 Suppose I sampled...
 4 5 1 3 7 5 1 4 7

 So, I would count...
 x  count
 1  2
 2  0
 3  1
 4  2
 5  2
 6  0
 7  2
 8  0
 9  0
 10 0

 Thanks in advance,
 Marcio
 --
 View this message in context:
 http://www.nabble.com/Count-observation-tp23987251p23987251.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[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] Re strict AIC comparison to succesful models?

2009-06-11 Thread Manuel Morales
On Thu, 2009-06-11 at 12:08 -0700, Ben Bolker wrote:
 
 
 Manuel Morales wrote:
  
  Hello list,
  
  I'm doing a bootstrap analysis where some models occasionally fail to
  converge. I'd like to automate the process of restricting AIC to the
  models that do converge. A contrived example of what I'd like to do is
  below:
  
  resp - c(1,1,2)
  pred - c(1,2,3)
  
  m1 - lm(resp~pred)
  m2 - lm(resp~poly(pred,2))
  m3 - lm(resp~poly(pred,3)) # Fails, obviously
  
  ## Some test to see which models were successful
  models - test(m1,m2,m3)
  
 
 How about 
 
 models - list(m1,m2,m3)
 is.OK - sapply(models,test)
 do.call(AIC,models[is.OK])
 
   ?

Good idea but unfortunately I get an error message with:

models - list(m1,m2,m3)
test - function(x) length(x)1
is.OK - sapply(models,test)
do.call(AIC,models[is.OK])

I think the issue is that AIC is expecting a ... of model objects (not a
list or a vector) and I'm not sure how to construct that.

Manuel

__
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 force R to print 2 decimal places in column of a data.frame?

2009-06-11 Thread Lesandro

Hi Marc Schwartz,

Your suggestion solved my problem.

Thanks you.

--- Em qui, 11/6/09, Marc Schwartz marc_schwa...@me.com escreveu:

 De: Marc Schwartz marc_schwa...@me.com
 Assunto: Re: [R] How to force R to print 2 decimal places in column of a 
 data.frame?
 Para: Lesandro lesand...@yahoo.com.br
 Cc: r-help@r-project.org
 Data: Quinta-feira, 11 de Junho de 2009, 15:45
 
 On Jun 11, 2009, at 11:48 AM, Lesandro wrote:
 
  
  How to force R to print 2 decimal places in column of
 a data.frame? I tried to do so:
  
  x = inp(format(rounf(inp$Tamanho, 2), nsmall = 2),)
  
  where INP is data.frame and Size is the name of
 column. But has error:
  
  Error in eval.with.vis(expr, envir, enclos) :
   could not find function inp
  
  Lesandro
 
 
 
 Your code and description above appear to have some typos
 in it and the use of the round() and format() functions are
 not what you want here.
 
 You code has inp(...), where R is presuming that you are
 referring to a function called 'inp', hence the error
 message, since the function does not exist.
 
 Better to use sprintf() with an appropriate format
 specifier:
 
 set.seed(1)
 vec - rnorm(10)
 
  vec
  [1] -0.6264538  0.1836433 -0.8356286 
 1.5952808  0.3295078 -0.8204684
  [7]  0.4874291  0.7383247  0.5757814
 -0.3053884
 
  sprintf(%.2f, vec)
  [1] -0.63 0.18  -0.84 1.60  0.33 
 -0.82 0.49  0.74
  [9] 0.58  -0.31
 
 See ?sprintf for more information.  Note that the
 presumption here is that you want to output the numeric
 values to a formatted character vector for display purposes,
 perhaps in a table, etc.
 
 So if your actual data frame is called 'INP' and the column
 is called 'Size', you would use:
 
   sprintf(%.2f, INP$Size)
 
 
 HTH,
 
 Marc Schwartz
 
 


  Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

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


Re: [R] Re strict AIC comparison to succesful models?

2009-06-11 Thread Ben Bolker
Manuel Morales wrote:
 On Thu, 2009-06-11 at 12:08 -0700, Ben Bolker wrote:

 Manuel Morales wrote:
 Hello list,

 I'm doing a bootstrap analysis where some models occasionally fail to
 converge. I'd like to automate the process of restricting AIC to the
 models that do converge. A contrived example of what I'd like to do is
 below:

 resp - c(1,1,2)
 pred - c(1,2,3)

 m1 - lm(resp~pred)
 m2 - lm(resp~poly(pred,2))
 m3 - lm(resp~poly(pred,3)) # Fails, obviously

 ## Some test to see which models were successful
 models - test(m1,m2,m3)

 How about 

 models - list(m1,m2,m3)
 is.OK - sapply(models,test)
 do.call(AIC,models[is.OK])

   ?
 
 Good idea but unfortunately I get an error message with:
 
 models - list(m1,m2,m3)
 test - function(x) length(x)1
 is.OK - sapply(models,test)
 do.call(AIC,models[is.OK])
 
 I think the issue is that AIC is expecting a ... of model objects (not a
 list or a vector) and I'm not sure how to construct that.
 
 Manuel
 

  The problem is that when your fitting function fails,
NOTHING gets created.

   Try this:

#
resp - c(1,1,2)
pred - c(1,2,3)

m1 - try(lm(resp~pred))
m2 - try(lm(resp~poly(pred,2)))
m3 - try(lm(resp~poly(pred,3))) # Fails, obviously

models - list(m1,m2,m3)
test - function(x) !inherits(x,try-error)
is.OK - sapply(models,test)

AIC(m1,m2) ## works

## all these work but lead to objects with ugly row names
do.call(AIC,models[is.OK])
do.call(AIC,models[is.OK])
do.call(stats:::AIC.default,models[is.OK])
dd - do.call(AIC,list(m1,m2))
rownames(dd) - NULL
dd


-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bol...@ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc



signature.asc
Description: OpenPGP digital 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] formula for degrees of freedom for nonlinear mixed model in nlme

2009-06-11 Thread David Winsemius


The FAQ 7.35 links to this posting:

https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html


On Jun 11, 2009, at 3:57 PM, J S wrote:



Dear forum members,

What is the formula to calculate denominator degrees of freedom (den  
df) for nonlinear mixed-effect models with covariates? My model is  
similar to a CO2 uptake example from  Pinheiro and Bates (2000, page  
376). In this CO2 dataset, there are two treatments and two types  
(84 observations in total), but den df for each parameter of the  
model is 64. Isn’t it too high?


Your help is greatly appreciated,
Julia

Summary of the CO2 example:


summary(fm4CO2.nlme)

Nonlinear mixed-effects model fit by maximum likelihood
 Model: uptake ~ SSasympOff(conc, Asym, lrc, c0)
Data: CO2
  AIC  BIClogLik
 388.4185 420.0191 -181.2092

Random effects:
Formula: list(Asym ~ 1, lrc ~ 1)
Level: Plant
Structure: General positive-definite, Log-Cholesky parametrization
StdDev   Corr
Asym.(Intercept) 2.349640 As.(I)
lrc.(Intercept)  0.079597 -0.92
Residual 1.791962

Fixed effects: list(Asym + lrc ~ Type * Treatment, c0 ~ 1)
 Value Std.Error DF   t- 
value p-value
Asym.(Intercept)   41.81756  1.562426 64   
26.76451  0.
Asym.TypeMississippi  -10.53045  2.208318 64   
-4.76854  0.
Asym.Treatmentchilled  -2.96943  2.213172 64   
-1.34171  0.1844
Asym.TypeMississippi:Treatmentchilled -10.90037  3.112220 64   
-3.50244  0.0008
lrc.(Intercept)-4.55724  0.096291 64  
-47.32785  0.
lrc.TypeMississippi-0.10412  0.121683 64   
-0.85570  0.3954
lrc.Treatmentchilled   -0.17124  0.111959 64   
-1.52953  0.1311
lrc.TypeMississippi:Treatmentchilled0.74188  0.221742 64
3.34570  0.0014
c0 50.51075  4.364727 64   
11.57249  0.

Correlation:
 As.(I) Asy.TM Asym.T A.TM:T lr. 
(I) lrc.TM

Asym.TypeMississippi  -0.703
Asym.Treatmentchilled -0.701  0.496
Asym.TypeMississippi:Treatmentchilled  0.497 -0.709 -0.711
lrc.(Intercept)   -0.627  0.415  0.407 -0.278
lrc.TypeMississippi0.458 -0.680 -0.322  0.482  
-0.535
lrc.Treatmentchilled   0.500 -0.351 -0.717  0.509  
-0.594  0.445
lrc.TypeMississippi:Treatmentchilled  -0.262  0.375  0.362 -0.547   
0.365 -0.553
c0-0.086  0.014  0.001  0.019   
0.590 -0.033

 lrc.Tr l.TM:T
Asym.TypeMississippi
Asym.Treatmentchilled
Asym.TypeMississippi:Treatmentchilled
lrc.(Intercept)
lrc.TypeMississippi
lrc.Treatmentchilled
lrc.TypeMississippi:Treatmentchilled  -0.511
c0-0.057  0.140

Standardized Within-Group Residuals:
   Min  Q1 Med  Q3 Max
-2.86206487 -0.49445730 -0.04217037  0.56599012  3.04061332

Number of Observations: 84
Number of Groups: 12

Link to the book:
http://books.google.com/books?id=N3WeyHFbHLQCpg=PA139lpg=PA139dq=mixed-effect+model+building+first+stepsource=blots=pR7PWIuKu8sig=TLhq-k5O4ZNwkBWcyQI8VZk9Umkhl=enei=1HguSrKaPJi0Nb3DnfUJsa=Xoi=book_resultct=resultresnum=1#PPA376,M1



_


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] color in grouped lattice xyplot plot

2009-06-11 Thread Katharina May
Hi,

I've got a data.frame object which I would like to plot in a lattice
xyplot grouped by a variable and using a value for the color of each
point which is stored in a variable in the same data.frame.

I tried the following code:

my.panel.xy - function(x, y, ...){
  panel.xyplot(x, y,  ...)
  panel.lmline(x, y, lwd = 2)
  panel.abline(0, 1, col=red, lty=2)
  panel.grid(h = -1, v = -1, lty=1)
  }

xyplot(log(AGB) ~ log(BM_roots) | as.character(taxa),
data=sub_agb_data,main=list(AGB in dependence of BM_root [per
taxa!],cex=0.7),

ylab=list(log(AGB),cex=0.7),xlab=list(log(BM_root),cex=0.7),col=sub_agb_data$color,
panel = my.panel.xy)

xyplot(log(AGB) ~ log(BM_roots) | as.character(species),
data=sub_agb_data,main=list(AGB in dependence of BM_root [per
species!],cex=0.7),

ylab=list(log(AGB),cex=0.7),xlab=list(log(BM_root),cex=0.7),col=sub_agb_data$color,
panel = my.panel.xy)



Somehow the colors are not displayed correctly (it works if I use plot
in a for loop for each value for the variables for which I group my
lattice plots. The color variable is of type character so this
shouldn't be the reason)

The object sub_agb_object can be downloaded here:
http://www.wzw.tum.de/oekophys/fileadmin/sub_agb_data.rData

Maybe somebody has any idea how to make this work or what the problem might be?

Thanks,

Katharina

__
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] Automatically placing legend in location of most whitespace.

2009-06-11 Thread Jason Rupert


Just read the following:
https://stat.ethz.ch/pipermail/r-help/2003-October/039940.html

Is the labcurve function, really the putKey function, in the Hmisc package the 
best way the to go about automatically placing legend in location of most 
whitespace?

Thanks for any insights.

__
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] Matrix manipulation

2009-06-11 Thread Henrique Dallazuanna
Try this:

For the first and the second question:

transform(subset(d, row.names(d) != 2), row.names=NULL)

On Thu, Jun 11, 2009 at 3:53 PM, Payam Minoofar payam.minoo...@meissner.com
 wrote:

 Hello everyone,

 I have a couple of fairly simple questions (I hope) the answers to which I
 cannot find through the documentation at the moment.


  1.  I would like to delete the a row from a matrix if a certain
 elimination criterion is met. I am familiar with x - x[-7,] (to remove row
 7, for example). Are there any other means of removing an entire row?
  2.  Is there a single command that will rename the index of each row to
 match the row number once a row has been deleted. For example, when row 7 is
 deleted above, the old row 8 is now row 7, but the row name is still 8. I
 have figured out how to assign a sequence vector to the row names, but I am
 wondering if there is a built-in command that does the same thing. (I.e.,
 change the name of row 7 to 7 from 8.)

 Thank you very much.

 Payam
 --
 Payam Minoofar, Ph.D.
 Scientist
 Meissner Filtration Products
 4181 Calle Tesoro
 Camarillo, CA 93012
 USA
 +1 805 388 9911
 +1 805 388 5948 fax
 payam.minoo...@meissner.com


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




-- 
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] Matrix manipulation

2009-06-11 Thread David Winsemius


On Jun 11, 2009, at 2:53 PM, Payam Minoofar wrote:


Hello everyone,

I have a couple of fairly simple questions (I hope) the answers to  
which I cannot find through the documentation at the moment.



1.  I would like to delete the a row from a matrix if a certain  
elimination criterion is met. I am familiar with x - x[-7,] (to  
remove row 7, for example). Are there any other means of removing an  
entire row?


?which   # useful for converting logical vectors into argument for  
functions that require numerics


M10 - matrix(1:100, nrow = 10)

# find row with 63
which( sapply( 1:10, function(x) 63 %in% M10[x, ]) )
[1] 3

M10[-which( sapply( 1:10, function(x) 63 %in% M10[x, ]) ), ]   #  
remove row with 63


  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]1   11   21   31   41   51   61   71   8191
 [2,]2   12   22   32   42   52   62   72   8292
 [3,]4   14   24   34   44   54   64   74   8494
 [4,]5   15   25   35   45   55   65   75   8595
 [5,]6   16   26   36   46   56   66   76   8696
 [6,]7   17   27   37   47   57   67   77   8797
 [7,]8   18   28   38   48   58   68   78   8898
 [8,]9   19   29   39   49   59   69   79   8999
 [9,]   10   20   30   40   50   60   70   80   90   100

 2.  Is there a single command that will rename the index of each  
row to match the row number once a row has been deleted. For  
example, when row 7 is deleted above, the old row 8 is now row 7,  
but the row name is still 8. I have figured out how to assign a  
sequence vector to the row names, but I am wondering if there is a  
built-in command that does the same thing. (I.e., change the name of  
row 7 to 7 from 8.)


Thank you very much.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Re strict AIC comparison to succesful models?

2009-06-11 Thread Manuel Morales
On Thu, 2009-06-11 at 16:10 -0400, Ben Bolker wrote:
 Manuel Morales wrote:
  On Thu, 2009-06-11 at 12:08 -0700, Ben Bolker wrote:
 
  Manuel Morales wrote:
  Hello list,
 
  I'm doing a bootstrap analysis where some models occasionally fail to
  converge. I'd like to automate the process of restricting AIC to the
  models that do converge. A contrived example of what I'd like to do is
  below:
 
  resp - c(1,1,2)
  pred - c(1,2,3)
 
  m1 - lm(resp~pred)
  m2 - lm(resp~poly(pred,2))
  m3 - lm(resp~poly(pred,3)) # Fails, obviously
 
  ## Some test to see which models were successful
  models - test(m1,m2,m3)
 
  How about 
 
  models - list(m1,m2,m3)
  is.OK - sapply(models,test)
  do.call(AIC,models[is.OK])
 
?
  
  Good idea but unfortunately I get an error message with:
  
  models - list(m1,m2,m3)
  test - function(x) length(x)1
  is.OK - sapply(models,test)
  do.call(AIC,models[is.OK])
  
  I think the issue is that AIC is expecting a ... of model objects (not a
  list or a vector) and I'm not sure how to construct that.
  
  Manuel
  
 
   The problem is that when your fitting function fails,
 NOTHING gets created.
 
Try this:
 
 #
 resp - c(1,1,2)
 pred - c(1,2,3)
 
 m1 - try(lm(resp~pred))
 m2 - try(lm(resp~poly(pred,2)))
 m3 - try(lm(resp~poly(pred,3))) # Fails, obviously
 
 models - list(m1,m2,m3)
 test - function(x) !inherits(x,try-error)
 is.OK - sapply(models,test)
 
 AIC(m1,m2) ## works
 
 ## all these work but lead to objects with ugly row names
 do.call(AIC,models[is.OK])
 do.call(AIC,models[is.OK])
 do.call(stats:::AIC.default,models[is.OK])
 dd - do.call(AIC,list(m1,m2))
 rownames(dd) - NULL
 dd
 
I see, it wasn't an error message just a very ugly output. Reassigning the row 
names works great!

Thanks,

Manuel
-- 
http://mutualism.williams.edu

__
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 extract from a matrix based on indices in a vector?

2009-06-11 Thread Logickle

Thanks, guys. I'll take at a look at these solutions. BTW, my apologies, by
A,B,C,D,... I meant just some real number, not characters A,B,..., but
I wasn't clear about that. If that effects the solution approach please let
me know, but I don't think it does. Thanks again, Doug


Marc Schwartz-3 wrote:
 
 On Jun 10, 2009, at 7:05 PM, William Dunlap wrote:
 
 Subscripting by a 2-column matrix
   M[cbind(v, seq_len(ncol(M)))]
 uses much less space (hence time) than making
 the ncol(M) by ncol(M) intermediate matrix just
 to extract its diagonal.  E.g.

 test - function(n, seed) {
   if (!missing(seed))
  set.seed(seed)
   M - matrix(sample(LETTERS, 2*n, replace = TRUE), 2)
   v - sample(2, n, replace=T)
   t1-system.time(r1-M[cbind(v,seq_len(ncol(M)))])
   t2-system.time(r2-diag(M[v, 1:ncol(M)]))
   list(identical=identical(r1,r2), time(matrix subscript)=t1,
 time(diag(big matrix))=t2)
 }

 test(100)
 $identical
 [1] TRUE

 $`time(matrix subscript)`
   user  system elapsed
  0.000   0.000   0.001

 $`time(diag(big matrix))`
   user  system elapsed
  0.001   0.000   0.001

 test(1000)
 $identical
 [1] TRUE

 $`time(matrix subscript)`
   user  system elapsed
  0.000   0.000   0.001

 $`time(diag(big matrix))`
   user  system elapsed
  0.082   0.021   0.103

 test(5000)
 $identical
 [1] TRUE

 $`time(matrix subscript)`
   user  system elapsed
  0.001   0.000   0.001

 $`time(diag(big matrix))`
   user  system elapsed
  3.379   0.552   3.932
 
 
 
 Nicely done comparison Bill.
 
 Thanks,
 
 Marc
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-extract-from-a-matrix-based-on-indices-in-a-vector--tp23967316p23988270.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Optimization Question

2009-06-11 Thread Brecknock, Peter
Hi All
 
Apologies if this is not the correct list for this question.
 
The Rglpk package offers the following example in its documentation
 
library(Rglpk)
## Simple mixed integer linear program.
## maximize: 3 x_1 + 1 x_2 + 3 x_3
## subject to: -1 x_1 + 2 x_2 + x_3 = 4
## 4 x_2 - 3 x_3 = 2
## x_1 - 3 x_2 + 2 x_3 = 3
## x_1, x_3 are non-negative integers
## x_2 is a non-negative real number
obj - c(3, 1, 3)
mat - matrix(c(-1, 0, 1, 2, 4, -3, 1, -3, 2), nrow = 3)
dir - c(=, =, =)
rhs - c(4, 2, 3)
types - c(I, C, I)
max - TRUE
Rglpk_solve_LP(obj, mat, dir, rhs, types, max)
 
## Same as before but with bounds replaced by
## -Inf  x_1 = 4
## 0 = x_2 = 100
## 2 = x_3  Inf
 
bounds - list(lower = list(ind = c(1L, 3L), val = c(-Inf, 2)),
upper = list(ind = c(1L, 2L), val = c(4, 100)))
Rglpk_solve_LP(obj, mat, dir, rhs, types, max, bounds)
 
I have 2 questions
 
1. What is the purpose of the L in the bounds statement (e.g. 1L, 3L
etc)? 
 
2. Is it possible to further constrain a variable such that in the
optimal solution to the objective function it will be a specific integer
or an integer multiple of that integer. For example, x_3 must be 2 or
4,6,8,10 etc
 
Thanks
 
Pete
 

This e-mail may contain confidential or proprietary information
belonging to the BP group and is intended only for the use of the
recipients named above.  If you are not the intended recipient, please
immediately notify the sender and either delete this email or return to
the sender immediately.  You may not review, copy or distribute this
email.  Within the bounds of law, this part of BP retains all emails and
IMs and may monitor them to ensure compliance with BP's internal
policies and for other legitimate business purposes.

 

[[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] TCLTK Times out Leopard.

2009-06-11 Thread INBEL

I'm trying to get the Tcltk package loaded on R 2.9 (I think, it's just
recently updated). At first it was looking for X11 files in the wrong
library so created an alias to point it in the right direction. Now when I
load it nothing happens, the program stops responding. Any ideas? I should
point out I'm just starting to use this program.
Kailer
-- 
View this message in context: 
http://www.nabble.com/TCLTK-Times-out-Leopard.-tp23988562p23988562.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Matrix manipulation

2009-06-11 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
 Sent: Thursday, June 11, 2009 1:49 PM
 To: Payam Minoofar
 Cc: r-help@r-project.org
 Subject: Re: [R] Matrix manipulation
 
 
 On Jun 11, 2009, at 2:53 PM, Payam Minoofar wrote:
 
  Hello everyone,
 
  I have a couple of fairly simple questions (I hope) the answers to  
  which I cannot find through the documentation at the moment.
 
 
  1.  I would like to delete the a row from a matrix if a certain  
  elimination criterion is met. I am familiar with x - x[-7,] (to  
  remove row 7, for example). Are there any other means of 
 removing an  
  entire row?
 
 ?which   # useful for converting logical vectors into argument for  
 functions that require numerics
 
 M10 - matrix(1:100, nrow = 10)
 
 # find row with 63
 which( sapply( 1:10, function(x) 63 %in% M10[x, ]) )
 [1] 3
 
 M10[-which( sapply( 1:10, function(x) 63 %in% M10[x, ]) ), ]   #  
 remove row with 63
 
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
   [1,]1   11   21   31   41   51   61   71   8191
   [2,]2   12   22   32   42   52   62   72   8292
   [3,]4   14   24   34   44   54   64   74   8494
   [4,]5   15   25   35   45   55   65   75   8595
   [5,]6   16   26   36   46   56   66   76   8696
   [6,]7   17   27   37   47   57   67   77   8797
   [7,]8   18   28   38   48   58   68   78   8898
   [8,]9   19   29   39   49   59   69   79   8999
   [9,]   10   20   30   40   50   60   70   80   90   100

which() is dangerous here.  E.g., if you wanted to use that
idiom to delete any row containing 666 you would get
a 0-row by 10-column matrix, not the expected copy of
the input matrix
   M10[-which( sapply( 1:10, function(x) 666 %in% M10[x, ]) ), ]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
(This happens because -integer(0) is no different than integer(0):
both are 0-long vectors.)

I think you should use logical subscripts unless you are really
pressed for space.
M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]
When you read '[', say 'such that'.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

 
   2.  Is there a single command that will rename the index of each  
  row to match the row number once a row has been deleted. For  
  example, when row 7 is deleted above, the old row 8 is now row 7,  
  but the row name is still 8. I have figured out how to assign a  
  sequence vector to the row names, but I am wondering if there is a  
  built-in command that does the same thing. (I.e., change 
 the name of  
  row 7 to 7 from 8.)
 
  Thank you very much.
 
  Payam
  --
  Payam Minoofar, Ph.D.
  Scientist
  Meissner Filtration Products
  4181 Calle Tesoro
  Camarillo, CA 93012
  USA
  +1 805 388 9911
  +1 805 388 5948 fax
  payam.minoo...@meissner.com
 
 
  [[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.
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 __
 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] Inf in nnet final value for validation data

2009-06-11 Thread jude.ryan
Andrea,

 

You can calculate predictions for your validation data based on nnet objects 
using the predict function (the predict function can also be used for 
regressions, quantile regressions, etc.)

If you create a neural net with the following code: 

 

library(nnet)

# 3 hidden neurons, for classification (linout = F), and not a skip layer 
network (skip = F, or T if you want)

mynet.nn - nnet(dependent_variable ~ ., data = train, size = 3, decay = 1e-3, 
linout = F, skip = F, maxit = 1000, Hess = T)  

# calculate predictions for your training data and append to data frame called 
train

train$predictions - predict(mynet.nn)

# calculate predictions for your validation data and append to data frame 
called valid

valid$predictions  - predict(mynet.nn, valid)  # you need to pass your neural 
net object and your validation dataset to the predict function

 

To just get the predictions for your validation dataset this is all you need. I 
do not know why you need to calculate the log likelihood.

 

Hope this helps.

 

Jude

 

 

Andrea wrote:

 

Hi,

 

I use nnet for my classification problem and have a problem concerning the 
calculation of the final value for my validation data.(nnet only calculates the 
final value for the training data). I made my own final value formula (for the 
training data I get the same value as nnet):

  

# prob-matrix

pmatrix - cat*fittedValues

tmp - rowSums(pmatrix) 



# -log likelihood

finalValue - sum(-log(tmp))



# add penalty term

finalValue + sum(decay * weights^2)

  

where cat is a matrix with cols for each possible category and a row for each 
data record. The values are 1 for the target categories of a data record and 0 
otherwise.

 

My problem is, that I get Inf-values for some validation data records, because 
the rowsum of cat*fittedValues gets 0 and the log gets Inf.

 

Has anyone an idea how to deal with that problem properly? How does nnet?

 

I´m thinking of a penalty value for those values. That means if 
cat*fittedValues == 0 not to calculate the log but add e.g. 100 instead of 
-log(tmp) to the finalValue-sum??

But how to determine the penalty value???

 

I´m looking forwar for all suggestions,

 

Andrea.

 

 

___
Jude Ryan
Director, Client Analytical Services
Strategy  Business Development
UBS Financial Services Inc.
1200 Harbor Boulevard, 4th Floor
Weehawken, NJ 07086-6791
Tel. 201-352-1935
Fax 201-272-2914
Email: jude.r...@ubs.com



Please do not transmit orders or instructions regarding a UBS 
account electronically, including but not limited to e-mail, 
fax, text or instant messaging. The information provided in 
this e-mail or any attachments is not an official transaction 
confirmation or account statement. For your protection, do not 
include account numbers, Social Security numbers, credit card 
numbers, passwords or other non-public information in your e-mail. 
Because the information contained in this message may be privileged, 
confidential, proprietary or otherwise protected from disclosure, 
please notify us immediately by replying to this message and 
deleting it from your computer if you have received this 
communication in error. Thank you. 

UBS Financial Services Inc. 
UBS International Inc. 
UBS Financial Services Incorporated of Puerto Rico 
UBS AG

 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.__
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] Tables without names

2009-06-11 Thread Stavros Macrakis
A table without names displays like a vector:

 unname(table(2:3))
[1] 1 1 1

and preserves the table class (as with unname in general):

 dput(unname(table(2:3)))
structure(c(1L, 1L), .Dim = 2L, class = table)

Does that make sense?  R is not consistent in its treatment of such unname'd
tables:

In plot, they are considered erroneous input:

 plot(unname(table(2:3)))
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ

but in melt, they act as though they have names 1:n:

melt(unname(table(2:3)))
 indicies value
11 1
22 1

(By the way, is the spelling error built into too much code to be
corrected?)

-s

PS What is the standard way of extracting just the underlying vector?
c(unname(...)) works -- is that what is recommended?

[[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 installing Rmpi

2009-06-11 Thread ALAN SMITH
Hello R users and developers,
I would like to install Rmpi so that I may take advantage of all of
the CPUs in my computer, but I cannot get it to install and I am not
very good with linux so it is adding to the headache.  I have looked
through the help archive, but I have not been successful at getting
Rmpi to work.  I am not sure if I am even installing openMPI correctly
in linux.  I would really like to get Rmpi to work so that I can take
advantage of libraries that use Rmpi and more importantly reduce my
computation time from several days to maybe a day.
I am using fedora 11 (64-bit) on a AMD phenom III (AM3) system and I
am not an expert at linux so I run into trouble compiling and
installing software out of inexperience.
I would truly appreciated it if someone could please provide me with
some instructions on how to get openMPI installed correctly on
Fedora11 and Rmpi to work?
I have included the processes I attempted below.
Thank you,
Alan Smith

#  what I have attempted so far 
#I have tried two different ways to install openMPI in fedora in the linux shell
#in the linux shell
cd Download
wget http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.2.tar.gz
tar -xzf openmpi*
cd openmpi*
./configure
make
make install

#AND
#in the linux shell
cd Download
wget 
ftp://rpmfind.net/linux/fedora/releases/11/Everything/x86_64/os/Packages/openmpi-1.3.1-1.fc11.x86_64.rpm
sudo yum install openmpi-devel
# I find the program in this path /usr/lib64/openmpi/1.3.1-gcc/openmpi


#I then try to install Rmpi using two methods neither of which work
#Using the linux shell I have tried
wget http://cran.r-project.org/src/contrib/Rmpi_0.5-7.tar.gz
R CMD INSTALL Rmpi_0.5-7.tar.gz
#and
R CMD INSTALL Rmpi_0.5-7.tar.gz
--configure-args=--with-mpi=/usr/lib64/openmpi/1.3.1-gcc
R CMD INSTALL Rmpi_0.5-7.tar.gz --configure-args=--with-mpi=/usr/lib64/openmpi/
#All of these attempt lead to error cannot find mpi head file and tell
me to use  with-mpi=path/to/mpi or specify the MPI_ROOT which I
clearly cant find

#I have also tried this in R using
R
install.packages(Rmpi)
#but it gives the same error.



sessionInfo()
R version 2.9.0 (2009-04-17)
x86_64-unknown-linux-gnu
locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base




-- 
Alan Smith

__
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] Matrix manipulation

2009-06-11 Thread Gabor Grothendieck
Or perhaps:

M10[rowSums(M10 == 63) == 0, ]


On Thu, Jun 11, 2009 at 4:49 PM, David Winsemiusdwinsem...@comcast.net wrote:

 On Jun 11, 2009, at 2:53 PM, Payam Minoofar wrote:

 Hello everyone,

 I have a couple of fairly simple questions (I hope) the answers to which I
 cannot find through the documentation at the moment.


 1.  I would like to delete the a row from a matrix if a certain
 elimination criterion is met. I am familiar with x - x[-7,] (to remove row
 7, for example). Are there any other means of removing an entire row?

 ?which   # useful for converting logical vectors into argument for functions
 that require numerics

 M10 - matrix(1:100, nrow = 10)

 # find row with 63
 which( sapply( 1:10, function(x) 63 %in% M10[x, ]) )
 [1] 3

 M10[-which( sapply( 1:10, function(x) 63 %in% M10[x, ]) ), ]   # remove row
 with 63

      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
  [1,]    1   11   21   31   41   51   61   71   81    91
  [2,]    2   12   22   32   42   52   62   72   82    92
  [3,]    4   14   24   34   44   54   64   74   84    94
  [4,]    5   15   25   35   45   55   65   75   85    95
  [5,]    6   16   26   36   46   56   66   76   86    96
  [6,]    7   17   27   37   47   57   67   77   87    97
  [7,]    8   18   28   38   48   58   68   78   88    98
  [8,]    9   19   29   39   49   59   69   79   89    99
  [9,]   10   20   30   40   50   60   70   80   90   100

  2.  Is there a single command that will rename the index of each row to
 match the row number once a row has been deleted. For example, when row 7 is
 deleted above, the old row 8 is now row 7, but the row name is still 8. I
 have figured out how to assign a sequence vector to the row names, but I am
 wondering if there is a built-in command that does the same thing. (I.e.,
 change the name of row 7 to 7 from 8.)

 Thank you very much.

 Payam
 --
 Payam Minoofar, Ph.D.
 Scientist
 Meissner Filtration Products
 4181 Calle Tesoro
 Camarillo, CA 93012
 USA
 +1 805 388 9911
 +1 805 388 5948 fax
 payam.minoo...@meissner.com


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

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 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] Postcript font size

2009-06-11 Thread Andre Nathan
Hello

I'm doing a number of plots and in all of them I'm specifying the same
font size. However, comparing one plot to the other, they have fonts of
different sizes, so it appears some scaling is being done.

I tried using both postcript(pointsize = ...) and par(ps = ...), but the
results were the same.

Is there a way to specify a font size that is consistent among calls to
plot()?

Thanks,
Andre

__
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] Postcript font size

2009-06-11 Thread Andre Nathan
On Thu, 2009-06-11 at 19:09 -0300, Andre Nathan wrote:
 Is there a way to specify a font size that is consistent among calls to
 plot()?

To put it correctly: is there a way to specify a font size that is
consistent among calls to postcript()?

All the fonts in the same file have the same size, but comparing files,
even when par(ps = ...) or postcript(pointsize = ...) are specified the
same way, the fonts have different sizes.

Best regards,
Andre

__
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] Postcript font size

2009-06-11 Thread Ted Harding
On 11-Jun-09 22:16:22, Andre Nathan wrote:
 On Thu, 2009-06-11 at 19:09 -0300, Andre Nathan wrote:
 Is there a way to specify a font size that is consistent among calls
 to plot()?
 
 To put it correctly: is there a way to specify a font size that is
 consistent among calls to postcript()?
 
 All the fonts in the same file have the same size, but comparing files,
 even when par(ps = ...) or postcript(pointsize = ...) are specified
 the same way, the fonts have different sizes.
 
 Best regards,
 Andre

How are you comparing?
A: Looking into the PostScript code in the files, and identifying
   the font-sizes where they are set in the code?
B: Comparing apparent font sizes when looking at two plots on screen?
C: Comparing apparent font sizes when looking at plots as printed
   on paper (and, in this case, have the plots been included in an
   enacapsulated document as EPS graphics)?

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 11-Jun-09   Time: 23:47:59
-- XFMail --

__
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] Count observation

2009-06-11 Thread MarcioRibeiro

Hey... Milton...
Is that a equation... Brazil=Toronto
If so, mine is... Brazil=Montreal
You got it...
I am not having a good time with R... There is no help for data manipulation
at all...
Thanks for the help... 
Marcio



milton ruser wrote:
 
 Hi Marcio,
 
 data.frame(table(boot))
 ?
 
 milton
 brazil=toronto
 On Thu, Jun 11, 2009 at 3:13 PM, MarcioRibeiro mes...@pop.com.br wrote:
 

 Hi listers,
 I have the following code...

 data-as.matrix(c(1,2,3,4,5,6,7,8,9,10),nrow=10,ncol=1,byrow=TRUE)
 n-nrow(data)
 m-n-1
 boot-data[sample(m,replace=T),]

 So, I need to count the number of times each observation was selected at
 the
 sample with replacement...
 Suppose I sampled...
 4 5 1 3 7 5 1 4 7

 So, I would count...
 x  count
 1  2
 2  0
 3  1
 4  2
 5  2
 6  0
 7  2
 8  0
 9  0
 10 0

 Thanks in advance,
 Marcio
 --
 View this message in context:
 http://www.nabble.com/Count-observation-tp23987251p23987251.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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.
 
 

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

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


Re: [R] Count observation

2009-06-11 Thread Henrique Dallazuanna
Try this also:

cbind(data, tabulate(boot, nbins=nrow(data)))

On Thu, Jun 11, 2009 at 4:13 PM, MarcioRibeiro mes...@pop.com.br wrote:


 Hi listers,
 I have the following code...

 data-as.matrix(c(1,2,3,4,5,6,7,8,9,10),nrow=10,ncol=1,byrow=TRUE)
 n-nrow(data)
 m-n-1
 boot-data[sample(m,replace=T),]

 So, I need to count the number of times each observation was selected at
 the
 sample with replacement...
 Suppose I sampled...
 4 5 1 3 7 5 1 4 7

 So, I would count...
 x  count
 1  2
 2  0
 3  1
 4  2
 5  2
 6  0
 7  2
 8  0
 9  0
 10 0

 Thanks in advance,
 Marcio
 --
 View this message in context:
 http://www.nabble.com/Count-observation-tp23987251p23987251.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] Postcript font size

2009-06-11 Thread Andre Nathan
On Thu, 2009-06-11 at 23:48 +0100, ted.hard...@manchester.ac.uk wrote:
 How are you comparing?
 A: Looking into the PostScript code in the files, and identifying
the font-sizes where they are set in the code?

This. To get the size I wanted in both files, I had to use par(ps = 15)
in one of them, and par(ps = 18) in the other. Strangely, the generated
files had the following PS code:

  /ps 12 def /Font1 findfont 12 s

I don't know PostScript, but I assume this means pointsize = 12.

Best,
Andre

__
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] More basic question

2009-06-11 Thread Payam Minoofar
I have encountered a more fundamental problem in my data set. I'm using 
read.csv, and all the data are imported as character. How do I do a string 
comparison in a line like this:

M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]

Alternately, how do I change the class type on a column in a data frame from 
character to numeric?

Thank you very much.

Payam

[[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] More basic question

2009-06-11 Thread Payam Minoofar
Never mind the query regarding setting attributes. I just found the relevant 
section in the manual.

The only remaining question is regarding doing string comparisons in sapply 
argument below.

Thank you.

Payam

I have encountered a more fundamental problem in my data set. I'm using 
read.csv, and all the data are imported as character. How do I do a string 
comparison in a line like this:

M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]

Alternately, how do I change the class type on a column in a data frame from 
character to numeric?

Thank you very much.

Payam

[[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] More basic question

2009-06-11 Thread milton ruser
Hi there,

It may works:
df$myvar-as.numeric(as.character(df$myvar))
bests

milton
brazil=toronto


On Thu, Jun 11, 2009 at 7:37 PM, Payam Minoofar payam.minoo...@meissner.com
 wrote:

 I have encountered a more fundamental problem in my data set. I'm using
 read.csv, and all the data are imported as character. How do I do a string
 comparison in a line like this:

 M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]

 Alternately, how do I change the class type on a column in a data frame
 from character to numeric?

 Thank you very much.

 Payam

[[alternative HTML version deleted]]

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


[[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] formula for degrees of freedom for nonlinear mixed model in nlme

2009-06-11 Thread Ben Bolker



David Winsemius wrote:
 
 
 The FAQ 7.35 links to this posting:
 
 https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html
 
 

Actually, this is a different question from the usual why don't I
get denominator df? question -- it is how are these calculated
(since the poster is using nlme, not (n)lmer).  The answer in this
case is check Pinheiro and Bates 2000 -- I don't remember the
page number exactly, looks like it's page 91 -- see Google books:
http://tinyurl.com/ntygq3

If the denominator df don't agree with your intuition, you can
always recompute p-values with the appropriate den df:
(two-tailed) 2*pt(abs(t.score),df=dendf,lower.tail=FALSE)

-- 
View this message in context: 
http://www.nabble.com/formula-for-degrees-of-freedom-for-nonlinear-mixed-model-in-nlme-tp23987913p23991255.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] deSolve question

2009-06-11 Thread spencerg
Dear In-Sun: 



 I have not seen a reply, so I will offer some suggestions, hoping 
I can help without understanding all the details. 



  1.  Have you run that code with options(warn=2)?  It 
produced over 50 warnings for me, and options(warn=2) will convert the 
warnings to errors, making it easier for you to find the exact problem 
lines of code.  With this, have you used the debug function to trace 
through your code line by line to provide more detail about what the 
code is doing?  I use that routinely. 



  2.  Have you considered the PKfit package?  I don't know if 
it includes your model, but it includes code for many pharmacokinetic 
models.  If your interest in deSolve is as a means to solve this 
problem, you might consider PKfit. 



  3.  Have you tried writing directly to the authors?  Names 
and email addresses are available in help(pac=deSolve). 



 Hope this helps. 
 Spencer Graves



insun nam wrote:

Dear All,

I like to simulate a physiologically based pharmacokinetics model using R
but am having a problem with the daspk routine.

The same problem has been implemented in Berkeley madonna and Winbugs so
that I know that it is working. However, with daspk it is not, and the
numbers are everywhere!

Please see the following and let me know if I am missing something...

Thanks a lot in advance,
In-Sun

#---

library(deSolve)

y - c(Agi = 0,Alu = 0, Abr  = 0, Ah = 0, Ali = 0,  Ak = 0,  Am = 0,  Ask =
0,  Aad  = 0,  Apa  = 0, Asp  = 0, Aar  = 0,  Ave  = 0)
times = seq(0, 100, length=100)

pars - c(
dose = 80 * 0.26,
doseduration = 10,
Vmax = 1.44,
Km = 0.96,
s = 1.33,
fp = 0.236,
Kpfgi=0.324,
Kpflu = 1.092,
Kpfbr= 0.155 ,
Kpfh=0.767,
Kpfli = 0.551,
Kpfk=0.537,
Kpfm=0.339,
Kpfsk=0.784,
Kpfad=0.465,
Kpfpa=0.595,
Kpfsp=0.410,
Qar = 51.9,
Qve = 51.9,
Qgi = 12.3,
Qlu = 51.9,
Qbr = 3.2,
Qh = 6.4,
Qli = 16.5,
Qk = 12.8,
Qm = 7.6,
Qsk = 5.0,
Qad = 0.4,
Qpa = 1.0,
Qsp = 1.0,
Var = 7.0,
Vve = 14.1,
Vgi = 12.4,
Vlu = 1.3,
Vbr = 1.3,
Vh = 1.2,
Vli = 12.4,
Vk = 2.2,
Vm = 140.0,
Vsk = 49.0,
Vad = 11.2,
Vpa = 1.0,
Vsp = 1.0
)

Fun_ODE - function(t,y, pars){
with (as.list(c(y, pars)), {
It - dose/doseduration
Car - Aar/Var
Cve - Ave/Vve
Clu - Alu/Vlu
Cli - Ali/Vli
Cbr - Abr/Vbr
Ch - Ah/Vh
Cpa - Apa/Vpa
Csp - Asp/Vsp
Cgi - Agi/Vgi
Ck - Ak/Vk
Cm - Am/Vm
Cad - Aad/Vad
Csk - Ask/Vsk

Kpbbr - s*fp*Kpfbr
Kpbli - s*fp*Kpfli
Kpbh - s*fp*Kpfh
Kpbpa - s*fp*Kpfpa
Kpbsp - s*fp*Kpfsp
Kpbgi - s*fp*Kpfgi
Kpbk - s*fp*Kpfk
Kpbm - s*fp*Kpfm
Kpbad - s*fp*Kpfad
Kpbsk - s*fp*Kpfsk
Kpblu - s*fp*Kpflu

dAar - (Clu/Kpblu - Car)*Qar
dAve - if (t  10) It + Cbr*Qbr/Kpbbr + Ch *Qh/Kpbh + Cli*Qli/Kpbli +
Ck*Qk/Kpbk + Cm*Qm/Kpbm + Csk * Qsk /Kpbsk + Cad*Qad/Kpbad - Cve*Qve

else Cbr*Qbr/Kpbbr + Ch *Qh/Kpbh + Cli*Qli/Kpbli + Ck*Qk/Kpbk +
Cm*Qm/Kpbm + Csk * Qsk /Kpbsk + Cad*Qad/Kpbad - Cve*Qve
dAlu - (Cve-Clu/Kpblu)*Qlu

dAli - ((Qli - Qgi- Qpa-Qsp)*Car + Cgi*Qgi/Kpbgi + Csp*Qsp/Kpbsp +
Cpa*Qpa/Kpbpa - Cli*Qli/Kpbli) - Vmax*Cli/Kpfli/(Km + Cli/Kpfli)
dAbr - (Car - Cbr/Kpbbr)*Qbr
dAh - (Car - Ch/Kpbh)*Qh
dApa - (Car - Cpa/Kpbpa)*Qpa
dAsp - (Car - Csp/Kpbsp)*Qsp
dAgi - (Car - Cgi/Kpbgi)*Qgi
dAk - (Car - Ck/Kpbk)*Qk
dAm - (Car - Cm/Kpbm)*Qm
dAad - (Car - Cad/Kpbad)*Qad
dAsk - (Car - Csk/Kpbsk)*Qsk

return(list(dy = c(dAar, dAve, dAlu, dAli, dAbr, dAh, dApa, dAsp, dAgi, dAk,
dAm, dAad, dAsk),
Car = Car, Cve=Cve, Clu=Clu, Cli=Cli, Cbr=Cbr, Ch=Ch, Cpa=Cpa,
Csp=Csp, Cgi=Cgi, Ck=Ck, Cm=Cm, Cad=Cad, Csk=Csk))
})
}

ODE - as.data.frame(daspk(y = y, times = times, func = Fun_ODE,
parms = pars, atol = 1e-10, rtol = 1e-10))







__
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] Tables without names

2009-06-11 Thread David Winsemius

On Jun 11, 2009, at 5:35 PM, Stavros Macrakis wrote:


A table without names displays like a vector:


unname(table(2:3))

   [1] 1 1 1

and preserves the table class (as with unname in general):


dput(unname(table(2:3)))

   structure(c(1L, 1L), .Dim = 2L, class = table)

Does that make sense?  R is not consistent in its treatment of such  
unname'd

tables:

In plot, they are considered erroneous input:


plot(unname(table(2:3)))

   Error in xy.coords(x, y, xlabel, ylabel, log) :
   'x' and 'y' lengths differ

but in melt, they act as though they have names 1:n:


melt(unname(table(2:3)))

indicies value
   11 1
   22 1

(By the way, is the spelling error built into too much code to be
corrected?)

   -s

PS What is the standard way of extracting just the underlying vector?
c(unname(...)) works -- is that what is recommended?


I think of R (contingency) tables as just integer arrays with  
attitude  ... er, attributes.


 tt - table(c(1,1,1,3,3,3,5,5))
 is.array(tt)
[1] TRUE

 is.matrix( with(warpbreaks, table(wool, tension)) )
[1] TRUE

So what would you do with a matrix that had row or column names?


--


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] formula for degrees of freedom for nonlinear mixed model in nlme

2009-06-11 Thread David Winsemius


On Jun 11, 2009, at 8:47 PM, Ben Bolker wrote:


David Winsemius wrote:



The FAQ 7.35 links to this posting:

https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html




Actually, this is a different question from the usual why don't I
get denominator df? question -- it is how are these calculated
(since the poster is using nlme, not (n)lmer).  The answer in this
case is check Pinheiro and Bates 2000 -- I don't remember the
page number exactly, looks like it's page 91 -- see Google books:
http://tinyurl.com/ntygq3

If the denominator df don't agree with your intuition, you can
always recompute p-values with the appropriate den df:
(two-tailed) 2*pt(abs(t.score),df=dendf,lower.tail=FALSE)


Point well taken. So neither my citation nor page 91 (which also deals  
with LME models) are on point to the OP's question. P  B say that  
inference regarding  covariates in nlme models (which i believe was  
the question posed) are generally Wald statistics, and so don't really  
have denominator degrees of freedom, only numerators DFs.  The  
numerator is then the observation count minus the model degrees of  
freedom. See  365-368 which deals with the sort of nlme model about  
which the OP is asking. A method for generating an anova analysis is  
also demonstrated on page 374.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


  1   2   >