Re: [R] deSolve question

2009-06-12 Thread Karline
In-Sun, 

It is very simple. You define your state variables in the following order:
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)

and your rates of change in another order:
dy = c(dAar, dAve, dAlu, dAli, dAbr, dAh, dApa, dAsp, dAgi, dAk,
dAm, dAad, dAsk)

So, The solver uses the rate of change of Aar to update Agi etc... and you
get nonsense in the end.

I hope correcting this will solve your problem. 

I have seen this multiple times; it is definitely the most common type of
mistake in using R for solving differential equations.

Btw, why use daspk ? It is really meant for solving DAEs, not ODEs. 
lsoda or lsode or vode might be a better choice.

Cheers,
Karline


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

-- 
View this message in context: 
http://www.nabble.com/deSolve-question-tp23985008p23994033.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] Sending a function as an argument to C code.

2009-06-12 Thread Christophe Genolini
Hi the list,

I am writing a function (myFunc) that is using an other function (let 
say distance).


+++
dist1 <- function(x,y)dist(rbind(x,y))
dist2 <- function(x,y)y2

myFunc <- function(x,distance){
 cat("...\n")
 cat(distance(1,x))
}
myFunc(x=3,distance=dist1)
myFunc(x=3,distance=dist2)


In order to optimize the code, I would like to write myFunc in C. Is it 
possible, in the C code, to call a function define in R (dist1 or dist2) 
that will be send to myFunc as an argument ?


Christophe

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

It works for me.
According to YAST I got libgfortran4.3, gcc-43fortran and gcc-fortran
installed

Kees
Marc Schwartz wrote:
> 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.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] removing elements from a "unit" vector

2009-06-12 Thread baptiste auguie
Paul Murrell wrote:

Hi

The bug is now fixed in the development version
(thanks to Duncan for the diagnosis and suggested fix).

Paul




Thank you both for your help and dedication!

Best regards,

baptiste



--
_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


[R] Changing CRAN package compile option defaults?

2009-06-12 Thread Allan Engelhardt
Is there an easy way to override the compile options when installing 
packages from CRAN on Unix-style systems?  I tried setting CFLAGS, 
CXXFLAGS, and FFLAGS but they are not picked up.


For example (with a random package and adding -mtune only to try to get 
rid of the default)


export CFLAGS="-march=native -mtune=native"
export CXXFLAGS="-march=native -mtune=native"
R CMD INSTALL gstat_0.9-60.tar.gz
[...]
gcc -m64 -std=gnu99 -I/usr/include/R  -I/usr/local/include-fpic  -O2 
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m64 -mtune=generic -c block.c -o block.o

[...]

I am building a custom system and I'd like to get rid of '-g' (won't 
debug on that system) and change '-mtune=generic' to '-march=native' 
(don't need compatibility with other systems).


Is there an easy way of doing this for all packages I build?

Allan

(Currently re-compiling BLAS and friends with -march=native.)

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

2009-06-12 Thread Thomas Liebig
Hello R users,

i'm wondering how to trigger variable creation.
Whenever a variable is created i want my own function myFun(...) to be 
started.


if (exists("x")) {rm(x)} # after removal of x
 # any of these calls
x<-10# should call myFun
x=10 # should call myFun
assign(x,10) # should call myFun
etc.
 # afterwards, each of the calls
x<-15# should not call myFun
x=15 # should not call myFun
assign(x,15) # should not call myFun
etc.

Has anyone an idea? Unfortunately, this feature is also missing in the 
library trackObjs.


regards,
Thomas

--
Thomas Liebig
Fraunhofer-Institut für Intelligente Analyse- und
Informationssysteme (IAIS)

Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
Email:  thomas.lie...@iais.fraunhofer.de
Phone:  +49 2241 142050
Fax:+49 2241 142072

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Automatically placing legend in location of most whitespace.

2009-06-12 Thread Jim Lemon
Jason Rupert wrote:

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?

  

Hi Jason,
I wasn't aware of the largest.empty function (thanks), and the code is 
packed away in a Fortran routine, so I couldn't compare it to the 
emptyspace function in the plotrix package. However, I suspect that 
largest.empty is a more sophisticated way of finding space for a legend.


Jim

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


[R] (kein Betreff)

2009-06-12 Thread helios16
Hi all,

first of all: Sorry for my bad englis, and now the Question:

I have some problems with running R from Java. First i tried using rJava (JRI). 
But the examples didnt work properly.

Now im trying to establish a connection by using Rserve and JRclient (RF503). 
I have the following code, which i`ve found:



public class RTester {



public static void main(String[] args) {
Rconnection c = getLocalRconnection();
if (c != null) {
try {
double[] d = c.eval("rnorm(10)").asDoubleArray();
for (double n : d)
System.out.println(n);
} catch (RSrvException e) {
e.printStackTrace();
}
}
}

private static Rconnection getLocalRconnection() {
try {
return new Rconnection();
} catch (RSrvException e) {
//If we get this kind of error, it may be because Rserve is not 
running
if (e.getMessage().equals("Cannot connect: Connection refused")) {
try {
String rserveStartCommand = "R CMD Rserve --vanilla";
//do a blocking call to the shell command for starting 
Rserve
int exitValue = 
Runtime.getRuntime().exec(rserveStartCommand).waitFor();
//if it returned success, try connecting again
if (exitValue == 0)
return new Rconnection();
//otherwise, Rserve is probably not installed
else
System.err.println("Could not start Rserve - is it 
installed properly? Shell command \""+rserveStartCommand+"\" exited with exit 
value "+exitValue+".");
} catch (Exception e1) {
e1.printStackTrace();
}
}
else
e.printStackTrace();
}
return null;
}


-
The Problem ist, that i get the following Exception:
org.rosuda.JRclient.RSrvException: Handshake failed: The server uses more 
recent protocol than this client.
at org.rosuda.JRclient.Rconnection.(Rconnection.java:113)
at org.rosuda.JRclient.Rconnection.(Rconnection.java:58)
at org.rosuda.JRclient.Rconnection.(Rconnection.java:42)
at tester.RTester.getLocalRconnection(RTester.java:28)
at tester.RTester.main(RTester.java:14)


Well, i understand, that tehre seems to be a version problem, but i dont 
understand what kind of. Im using the most recent Versions of RServe and 
JRclient which i could find on the page.

btw. im using Windows XP Pro and Eclipse ganimed (recent Version) as IDE.
Java jdk is at version 1.6.

Thx in advance for any help!
-- 
GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und Telefonanschluss
für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 plot hyperbolic iso-lines of a cost function?

2009-06-12 Thread Nikos Alexandris
Hi R-specialists!

I would like to draw some hyperbolic (iso-)lines of a cost function in a
bi-dimensional space ( =shapes of a cost function ), based on (the
general form):

C(x) = c1*Ce + c2*Oe + c3*{ 1 - [ (1 - Ce)^a * (1 - Oe)^b ] }

where:

- Oe/Ce are Omission/Commission (ranging between 0 and 1 ) values in a
bi-dimensional space ( see example of Oe/Ce values [1])
- c1, c2, c3, a and b are some parameters which determine "sensitivity"
of the function


Is there a ready-to-use plotting - function?
Kind regards, Nikos
---

[1] Omission/ Commission errors
0.0.42497404
0.010124160.35377707
0.031503210.30218908
0.061586110.26031315
0.101884180.21955793
0.155588280.17899955
0.225111560.14204273
0.316631640.10425152
0.427280350.06922038
0.584208960.03561727
0.903683970.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Function for AIC or logLIK for nlsList object

2009-06-12 Thread Lindsay Banin
Dear R users,

Does anybody have a function to calculate logLik or AIC for nlsList objects? 
After receiving error messages, another user helped me ascertain that this 
function is not currently written into R.

Many thanks
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] JRclient.RSrvException Exception: Handshake

2009-06-12 Thread helios16
Hi all,

first of all: Sorry for my bad englis, and now the Question:

I have some problems with running R from Java. First i tried using rJava (JRI). 
But the examples didnt work properly.

Now im trying to establish a connection by using Rserve and JRclient (RF503). 
I have the following code, which i`ve found:



public class RTester {



public static void main(String[] args) {
Rconnection c = getLocalRconnection();
if (c != null) {
try {
double[] d = c.eval("rnorm(10)").asDoubleArray();
for (double n : d)
System.out.println(n);
} catch (RSrvException e) {
e.printStackTrace();
}
}
}

private static Rconnection getLocalRconnection() {
try {
return new Rconnection();
} catch (RSrvException e) {
//If we get this kind of error, it may be because Rserve is not 
running
if (e.getMessage().equals("Cannot connect: Connection refused")) {
try {
String rserveStartCommand = "R CMD Rserve --vanilla";
//do a blocking call to the shell command for starting 
Rserve
int exitValue = 
Runtime.getRuntime().exec(rserveStartCommand).waitFor();
//if it returned success, try connecting again
if (exitValue == 0)
return new Rconnection();
//otherwise, Rserve is probably not installed
else
System.err.println("Could not start Rserve - is it 
installed properly? Shell command \""+rserveStartCommand+"\" exited with exit 
value "+exitValue+".");
} catch (Exception e1) {
e1.printStackTrace();
}
}
else
e.printStackTrace();
}
return null;
}


-
The Problem ist, that i get the following Exception:
org.rosuda.JRclient.RSrvException: Handshake failed: The server uses more 
recent protocol than this client.
at org.rosuda.JRclient.Rconnection.(Rconnection.java:113)
at org.rosuda.JRclient.Rconnection.(Rconnection.java:58)
at org.rosuda.JRclient.Rconnection.(Rconnection.java:42)
at tester.RTester.getLocalRconnection(RTester.java:28)
at tester.RTester.main(RTester.java:14)


Well, i understand, that tehre seems to be a version problem, but i dont 
understand what kind of. Im using the most recent Versions of RServe and 
JRclient which i could find on the page.

btw. im using Windows XP Pro and Eclipse ganimed (recent Version) as IDE.
Java jdk is at version 1.6.

Thx in advance for any help!

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!

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


[R] Comparing model fits for NLME when models are not nested

2009-06-12 Thread Lindsay Banin
Hi there,

I am looking to compare nonlinear mixed effects models that have different 
nonlinear functions (different types of growth curve)embedded. Most of the 
literature I can find focuses on comparing nested models with likelihood ratios 
and AIC. Is there a way to compare model fits when models are not nested, i.e. 
when the nonlinear functions are not the same?

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] Replacing 0s with NA

2009-06-12 Thread Christine Griffiths
Hello

I have a dataset in which I would like to replace 0s with NAs. There is a 
lot of information on how to replace NAs with 0, but I have struggled to 
find anything with regards to doing the reverse. Any recommendations would 
be great.


Cheers
Christine

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


Re: [R] Replacing 0s with NA

2009-06-12 Thread Chuck Cleland
On 6/12/2009 4:55 AM, Christine Griffiths wrote:
> Hello
> 
> I have a dataset in which I would like to replace 0s with NAs. There is
> a lot of information on how to replace NAs with 0, but I have struggled
> to find anything with regards to doing the reverse. Any recommendations
> would be great.

X <- as.data.frame(matrix(sample(0:9, 100, replace=TRUE), ncol=10))

X
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1   7  5  8  9  6  6  4  8  5   8
2   6  2  9  6  8  5  9  1  1   3
3   4  1  5  8  9  5  3  2  1   4
4   4  8  7  7  4  1  1  4  9   8
5   9  2  5  8  4  8  4  8  6   0
6   3  4  2  8  2  0  6  4  8   5
7   3  5  0  2  7  7  9  9  3   1
8   7  3  3  4  8  3  9  2  7   1
9   4  7  9  1  5  4  8  2  1   9
10  7  7  6  1  0  9  0  5  7   0

X[] <- lapply(X, function(x){replace(x, x == 0, NA)})

X
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1   7  5  8  9  6  6  4  8  5   8
2   6  2  9  6  8  5  9  1  1   3
3   4  1  5  8  9  5  3  2  1   4
4   4  8  7  7  4  1  1  4  9   8
5   9  2  5  8  4  8  4  8  6  NA
6   3  4  2  8  2 NA  6  4  8   5
7   3  5 NA  2  7  7  9  9  3   1
8   7  3  3  4  8  3  9  2  7   1
9   4  7  9  1  5  4  8  2  1   9
10  7  7  6  1 NA  9 NA  5  7  NA

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

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


[R] replacing zeros by NAs

2009-06-12 Thread Robert Kinley
something like ...
 
> x<-c(1,2,3,0,5,6,0)
> is.na(x[x==0])<-T
> x
[1]  1  2  3 NA  5  6 NA


Robert  Kinley




[[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] Installing Rmpi on Fedora Linux [was: Re: help installing Rmpi]

2009-06-12 Thread Allan Engelhardt

On 11/06/09 22:46, ALAN SMITH wrote:

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

Package "multicore" *may* be easier for this.

, but I cannot get it to install [...]
The configuration file for Rmpi is, unfortunately, completely 
brain-damaged with hard-coded assumptions about which subdirectories 
should contain header and library files and no way of overriding it.  
This is what I did:

[...]
#I have tried two different ways to install openMPI in fedora in the linux shell

In any recent version of Fedora don't do any of what you suggest; instead do

# yum install openmpi openmpi-devel openmpi-libs

Then *download* the Rmpi package and unpack it using something like

$ tar xvf Rmpi_0.5-7.tar.gz

(version number may be different).

Then go into the Rmpi directory and change configure.ac.  If you are on 
a x86_64 platform, the following hack should work (for 32 bit try 
s/64/32/g):


+++[cut here]+++
 Process this file with autoconf to produce a configure script.

AC_INIT(DESCRIPTION)

AC_PROG_CC


MPI_LIBS=`pkg-config --libs openmpi-1.3.1-gcc-64`
MPI_INCLUDE=`pkg-config --cflags openmpi-1.3.1-gcc-64`
MPITYPE="OPENMPI"
MPI_DEPS="-DMPI2"

AC_CHECK_LIB(util, openpty, [ MPI_LIBS="$MPI_LIBS -lutil" ])
AC_CHECK_LIB(pthread, main, [ MPI_LIBS="$MPI_LIBS -lpthread" ])


PKG_LIBS="${MPI_LIBS} -fPIC"
PKG_CPPFLAGS="${MPI_INCLUDE} ${MPI_DEPS} -D${MPITYPE} -fPIC"

AC_SUBST(PKG_LIBS)
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(DEFS)

AC_OUTPUT(src/Makevars)
---[cut here]---

The number 1.3.1 may change in future updates to Fedora, I guess

Now (still in Rmpi directory) do

$ autoconf
$ cd ..
$ tar zcvf Rmpi-0.5-7-F1.tar.gz Rmpi
$ R CMD INSTALL Rmpi-0.5-7-F1.tar.gz

Which more-or-less works in R:

> library("Rmpi")
> mpi.spawn.Rslaves(nslaves=2)
2 slaves are spawned successfully. 0 failed.
master (rank 0, comm 1) of size 3 is running on: server
slave1 (rank 1, comm 1) of size 3 is running on: server
slave2 (rank 2, comm 1) of size 3 is running on: server
> x=c(10,20)
> mpi.apply(x,runif)
[[1]]
 [1] 0.25142616 0.93505554 0.03162852 0.71783194 0.35916139 0.85082154
 [7] 0.35404191 0.14221315 0.60063773 0.71805190

[[2]]
 [1] 0.84157864 0.63481773 0.38217188 0.67839089 0.27827728 0.35429266
 [7] 0.04898744 0.96601584 0.25687905 0.77381186 0.69011927 0.37391028
[13] 0.19017369 0.51196594 0.51970563 0.15791524 0.21358237 0.69642478
[19] 0.12690207 0.44177656

>

Hope this helps!

Allan.

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


Re: [R] Replacing 0s with NA

2009-06-12 Thread Gavin Simpson
On Fri, 2009-06-12 at 09:55 +0100, Christine Griffiths wrote:
> Hello
> 
> I have a dataset in which I would like to replace 0s with NAs. There is a 
> lot of information on how to replace NAs with 0, but I have struggled to 
> find anything with regards to doing the reverse. Any recommendations would 
> be great.

Here is one way:

## some dummy data
set.seed(123)
dat <- matrix(rnorm(100), ncol = 10)
## add some 0's
dat[sample(100, 20)] <- 0
## convert to df
dat <- data.frame(dat)
dat

## now replace 0 with NA
## replacement function
foo <- function(x) {
x[x == 0] <- NA
x
}
## lapply it, and force back to df
dat2 <- data.frame(lapply(dat, foo))
dat2

HTH

G

> 
> Cheers
> Christine
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Replacing 0s with NA

2009-06-12 Thread Gabor Grothendieck
Also try this:

X[X == 0] <- NA

or

X2 <- replace(X, X == 0, NA)


On Fri, Jun 12, 2009 at 5:54 AM, Chuck Cleland wrote:
> On 6/12/2009 4:55 AM, Christine Griffiths wrote:
>> Hello
>>
>> I have a dataset in which I would like to replace 0s with NAs. There is
>> a lot of information on how to replace NAs with 0, but I have struggled
>> to find anything with regards to doing the reverse. Any recommendations
>> would be great.
>
> X <- as.data.frame(matrix(sample(0:9, 100, replace=TRUE), ncol=10))
>
> X
>   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
> 1   7  5  8  9  6  6  4  8  5   8
> 2   6  2  9  6  8  5  9  1  1   3
> 3   4  1  5  8  9  5  3  2  1   4
> 4   4  8  7  7  4  1  1  4  9   8
> 5   9  2  5  8  4  8  4  8  6   0
> 6   3  4  2  8  2  0  6  4  8   5
> 7   3  5  0  2  7  7  9  9  3   1
> 8   7  3  3  4  8  3  9  2  7   1
> 9   4  7  9  1  5  4  8  2  1   9
> 10  7  7  6  1  0  9  0  5  7   0
>
> X[] <- lapply(X, function(x){replace(x, x == 0, NA)})
>
> X
>   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
> 1   7  5  8  9  6  6  4  8  5   8
> 2   6  2  9  6  8  5  9  1  1   3
> 3   4  1  5  8  9  5  3  2  1   4
> 4   4  8  7  7  4  1  1  4  9   8
> 5   9  2  5  8  4  8  4  8  6  NA
> 6   3  4  2  8  2 NA  6  4  8   5
> 7   3  5 NA  2  7  7  9  9  3   1
> 8   7  3  3  4  8  3  9  2  7   1
> 9   4  7  9  1  5  4  8  2  1   9
> 10  7  7  6  1 NA  9 NA  5  7  NA
>
>> Cheers
>> Christine
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
> Chuck Cleland, Ph.D.
> NDRI, Inc. (www.ndri.org)
> 71 West 23rd Street, 8th floor
> New York, NY 10010
> tel: (212) 845-4495 (Tu, Th)
> tel: (732) 512-0171 (M, W, F)
> fax: (917) 438-0894
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Changing CRAN package compile option defaults?

2009-06-12 Thread Prof Brian Ripley
On Fri, 12 Jun 2009, Allan Engelhardt wrote:

Is there an easy way to override the compile options when installing packages 
from CRAN on Unix-style systems?  I tried setting CFLAGS, CXXFLAGS, and 
FFLAGS but they are not picked up.


For example (with a random package and adding -mtune only to try to get rid 
of the default)


export CFLAGS="-march=native -mtune=native"
export CXXFLAGS="-march=native -mtune=native"
R CMD INSTALL gstat_0.9-60.tar.gz
[...]
gcc -m64 -std=gnu99 -I/usr/include/R  -I/usr/local/include-fpic  -O2 -g 
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m64 -mtune=generic -c block.c -o block.o

[...]

I am building a custom system and I'd like to get rid of '-g' (won't debug on 
that system) and change '-mtune=generic' to '-march=native' (don't need 
compatibility with other systems).


Is there an easy way of doing this for all packages I build?


Yes: read 'R Installation and Administration' section 6.3.3 (at least 
of the version on CRAN).


Also, it seems likely that you should be building R itself with the 
options you want for packages: how to do that is discussed in the same 
manual.  (Looks like this may be a pre-compiled Linux binary 
distribution of R, but we don't know, of course.)  In that case you 
don't need to set anything else.




Allan

(Currently re-compiling BLAS and friends with -march=native.)


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

2009-06-12 Thread Duncan Murdoch
On 11/06/2009 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:


One of the complaints about the S3 object system is that anything can 
claim to be of class "foo", even if it doesn't have the right structure 
so that foo methods work for it.  I think that's all you're seeing here: 
 you've got something that is mislabelled as being of class "table". 
The solution is "don't do that".


 > 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 would use as.numeric(), but I don't claim it's standard.

Duncan Murdoch

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


Re: [R] replacing zeros by NAs

2009-06-12 Thread tommaso_unifi
Other method:

a<-matrix(seq(1,20,2), 4,5)
a[c(1:2),c(2:4)]<-0

a[a==0]<-NA

- Original Message - 
From: "Robert Kinley" 

To: 
Sent: Friday, June 12, 2009 11:59 AM
Subject: [R] replacing zeros by NAs



something like ...


x<-c(1,2,3,0,5,6,0)
is.na(x[x==0])<-T
x

[1]  1  2  3 NA  5  6 NA


Robert  Kinley




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







No virus found in this incoming message.
Checked by AVG - www.avg.com

17:59:00

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Comparing model fits for NLME when models are not nested

2009-06-12 Thread Peter Flom
Lindsay Banin  wrote
>Hi there,
>
>I am looking to compare nonlinear mixed effects models that have different 
>nonlinear functions (different types of growth curve)embedded. Most of the 
>literature I can find focuses on comparing nested models with likelihood 
>ratios and AIC. Is there a way to compare model fits when models are not 
>nested, i.e. when the nonlinear functions are not the same?
>

What I like to do in these cases (and, in fact, for comparing model fits in 
general, even if nested) is graph the results of one vs the other, and of each 
vs. actual values.  If the predicted values from the two models are very 
similar, then I can choose based on complexity or some other criterion; if they 
are not similar, then which is closer to the actual values?  Is the difference 
large? Is it "worth it"?

It's  not a formal test, but I often find it illuminating.

HTH

Peter



Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT 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] Installing Rmpi on Fedora Linux [was: Re: help installing Rmpi]

2009-06-12 Thread Allan Engelhardt
For future reference, I put up the instructions here: 
http://www.cybaea.net/Blogs/Data/R-tips-Installing-Rmpi-on-Fedora-Linux.html


Allan

On 12/06/09 10:59, Allan Engelhardt wrote:


On 11/06/09 22:46, ALAN SMITH wrote:

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

Package "multicore" *may* be easier for this.

, but I cannot get it to install [...]
The configuration file for Rmpi is, unfortunately, completely 
brain-damaged with hard-coded assumptions about which subdirectories 
should contain header and library files and no way of overriding it.  
This is what I did:

[...]
#I have tried two different ways to install openMPI in fedora in the 
linux shell
In any recent version of Fedora don't do any of what you suggest; 
instead do


# yum install openmpi openmpi-devel openmpi-libs

Then *download* the Rmpi package and unpack it using something like

$ tar xvf Rmpi_0.5-7.tar.gz

(version number may be different).

Then go into the Rmpi directory and change configure.ac.  If you are 
on a x86_64 platform, the following hack should work (for 32 bit try 
s/64/32/g):


+++[cut here]+++
 Process this file with autoconf to produce a configure script.

AC_INIT(DESCRIPTION)

AC_PROG_CC


MPI_LIBS=`pkg-config --libs openmpi-1.3.1-gcc-64`
MPI_INCLUDE=`pkg-config --cflags openmpi-1.3.1-gcc-64`
MPITYPE="OPENMPI"
MPI_DEPS="-DMPI2"

AC_CHECK_LIB(util, openpty, [ MPI_LIBS="$MPI_LIBS -lutil" ])
AC_CHECK_LIB(pthread, main, [ MPI_LIBS="$MPI_LIBS -lpthread" ])


PKG_LIBS="${MPI_LIBS} -fPIC"
PKG_CPPFLAGS="${MPI_INCLUDE} ${MPI_DEPS} -D${MPITYPE} -fPIC"

AC_SUBST(PKG_LIBS)
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(DEFS)

AC_OUTPUT(src/Makevars)
---[cut here]---

The number 1.3.1 may change in future updates to Fedora, I guess

Now (still in Rmpi directory) do

$ autoconf
$ cd ..
$ tar zcvf Rmpi-0.5-7-F1.tar.gz Rmpi
$ R CMD INSTALL Rmpi-0.5-7-F1.tar.gz

Which more-or-less works in R:

> library("Rmpi")
> mpi.spawn.Rslaves(nslaves=2)
2 slaves are spawned successfully. 0 failed.
master (rank 0, comm 1) of size 3 is running on: server
slave1 (rank 1, comm 1) of size 3 is running on: server
slave2 (rank 2, comm 1) of size 3 is running on: server
> x=c(10,20)
> mpi.apply(x,runif)
[[1]]
 [1] 0.25142616 0.93505554 0.03162852 0.71783194 0.35916139 0.85082154
 [7] 0.35404191 0.14221315 0.60063773 0.71805190

[[2]]
 [1] 0.84157864 0.63481773 0.38217188 0.67839089 0.27827728 0.35429266
 [7] 0.04898744 0.96601584 0.25687905 0.77381186 0.69011927 0.37391028
[13] 0.19017369 0.51196594 0.51970563 0.15791524 0.21358237 0.69642478
[19] 0.12690207 0.44177656

>

Hope this helps!

Allan.



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

2009-06-12 Thread Paul Smith
On Thu, Jun 11, 2009 at 9:56 PM, Brecknock, Peter wrote:
> 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

Regarding your first question, I am not very sure, but it seems that

iL

means the constraint i.

Concerning your second question, the answer is positive. To force x_3
being an even number, just add the following constraints:

x_3 = 2 * y,

y >= 1,

y integer.

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] R 2.9.0 on AIX 5.3: Error: Invalid DESCRIPTION file

2009-06-12 Thread Dr. Loris Bennett
loris.benn...@fu-berlin.de (Loris Bennett) writes:

> Hi,
>
> I am trying to install R 2.9.0 on AIX 5.3. During the 'make' run I get
> the following error:
>
>Error: Invalid DESCRIPTION file
>
>Invalid Priority field.
>Packages with priorities 'base' or 'recommended' or 'defunct-base' must
>already be known to R.
>
>See the information on DESCRIPTION files in section 'Creating R
>packages' of the 'Writing R Extensions' manual.
>Execution halted
>
> Any ideas? Full output below.
>
> Thanks
>
> Loris
>
> Here is the full output of 'make':
>
>Target "R" is up to date.
>Target "R" is up to date.
>Target "R" is up to date.
>Target "R" is up to date.
>Target "Makedeps" is up to date.
>Target "libbz2.a" is up to date.
>Target "all" is up to date.
>Target "Makedeps" is up to date.
>Target "libpcre.a" is up to date.
>Target "all" is up to date.
>Target "Makedeps" is up to date.
>Target "libz.a" is up to date.
>Target "all" is up to date.
>Target "R" is up to date.
>Target "Makedeps" is up to date.
>Target "libappl.a" is up to date.
>Target "Makedeps" is up to date.
>Target "libnmath.a" is up to date.
>Target "Makedeps" is up to date.
>Target "libunix.a" is up to date.
>xlc_r -q64 -I. -I../../src/include -I../../src/include
>-I/usr/lpp/X11/include/X11 -DHAVE_CONFIG_H -O -qstrict
>-DR_HOME='"/opt/sw/install/R-2.9.0"' -o Rscript ./Rscript.c
>Target "Makedeps" is up to date.
>/opt/sw/install/R-2.9.0/bin/exec/R is unchanged
>Target "Makedeps" is up to date.
>Target "internet.so" is up to date.
>Target "all" is up to date.
>Target "Makedeps" is up to date.
>Target "libRlapack.so" is up to date.
>/opt/sw/install/R-2.9.0/lib/libRlapack.so is unchanged
>Target "lapack.so" is up to date.
>Target "all" is up to date.
>Target "Makedeps" is up to date.
>Target "vfonts.so" is up to date.
>Target "all" is up to date.
>Target "Makedeps" is up to date.
>Target "R_X11.so" is up to date.
>building system startup profile
>building package 'base'
>all.R is unchanged
>building package 'tools'
>all.R is unchanged
>Target "Makedeps" is up to date.
>../../../../library/tools/libs/tools.so is unchanged
>Error: Invalid DESCRIPTION file
>
>Invalid Priority field.
>Packages with priorities 'base' or 'recommended' or 'defunct-base' must
>already be known to R.
>
>See the information on DESCRIPTION files in section 'Creating R
>packages' of the 'Writing R Extensions' manual.
>Execution halted
>make: 1254-004 The error code from the last command is 1.
>
>
>Stop.
>make: 1254-004 The error code from the last command is 1.
>
>
>Stop.
>make: 1254-004 The error code from the last command is 1.
>
>
>Stop.
>make: 1254-004 The error code from the last command is 1.
>
>
>Stop.

I'm still stuck with this problem. Does anyone know how the
description files could cause a problem?

Cheers

Loris

-- 
Dr. Loris Bennett
Computer Centre
Freie Universität Berlin
Berlin, Germany

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please Help pairwise.t.test!!

2009-06-12 Thread Peter Flom
Chunhao Tu  wrote
>Hi R users,
>My question is, If I have 3 groups, A, B, C and I know mean of A =20, B=21,
>and C=20.5 and I also know the 
>standard error of A =1.1, B=2.2, C=3.2. Plus, I know A has 30 observations,
>B has 78, C has 45. But I do not have the raw data.
> 
>Can I use pairwise.t.test to conduct a Bonferroni test? If yes, Could you
>give me a hint? 

If the data in each group is normally distributed, you could use the mean
and sd and N in rnorm and then test the results.  But if you don't know that,
then I think it's a bit up in the air.

A - N = 30, sem = 1.1, mean = 20   sd = 1.1*30^.5 = 6.02
B - N = 78, sem = 2.2, mean = 21   sd = 2.2*78^.5 = 19.43
C - N = 45, sem = 3.2, mean = 20.5, sd = 3.2*45^.5 = 21.46

let's do just A and B, to keep it a bit simpler:

if both are normal:
A <- rnorm(n = 30, mean = 20, sd = 6.02)
B <- rnorm(n = 78, mean = 21, sd = 19.43)
t.test(A,B)

t = .927

but if A is uniform and B is normal

A <- rnorm(n = 30, mean = 20, sd = 6.02)
B <- runif(n = 78, mean = 21, sd = 19.43)
t.test(A,B)

t = 0.42

HTH, and hope I didn't mess up one of the calculations due to insufficient 
caffeine intake

Peter


Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT 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] GRASS raster data processing

2009-06-12 Thread Roger Bivand
Perhaps reading ?readRAST6 would help? It does say:
   vname: A vector of GRASS 6.0 raster file names

so you could write:

Kar <- readRAST6(c("Incis_Kar", "DEM_Kar"), plugin=FALSE)

and plot(Incis_Kar ~ DEM_Kar, data=Kar) should get you there - in spearfish:

sp <- readRAST6(c("erosion1", "elevation.dem"), plugin=FALSE)
plot(erosion1 ~ elevation.dem, data=sp)

works for me. (Aside - using @ in S4 classes should be avoided unless you
both know what you are doing and need to be doing it, use the provided
access mechanisms, here treating a Spatial*DataFrame as an ordinary data
frame.)

Roger



Nikos Alexandris wrote:
> 
> 
> 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
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/GRASS-raster-data-processing-tp23981740p23996501.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] fix for RMate (TextMate/E-Texteditor bundle)

2009-06-12 Thread Hans-Peter Suter
Arg, I already needed to fix the bundle. If anyone downloaded it
yesterday, please update, the help index building was broken (on
Macs). Should work now.

Repo/Infos: http://github.com/swissr/rmate.tmbundle/tree/master

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


Re: [R] replacing zeros by NAs

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

 is.na(x) <- x == 0

On Fri, Jun 12, 2009 at 6:59 AM, Robert Kinley wrote:

> something like ...
>
> > x<-c(1,2,3,0,5,6,0)
> > is.na(x[x==0])<-T
> > x
> [1]  1  2  3 NA  5  6 NA
>
> 
> Robert  Kinley
>
> 
>
>
>[[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.


[R] Comparing nonlinear regressions for different subsets of data

2009-06-12 Thread Martin Kellner
I have a dataset with four different treatments and two different values
for each sample. I need to compare the subsets(the different treatments)
somehow. The data look suspiciously much like some kind of e-function to
me, or maybe michaelis-menten so they are not linear. With linear models
it's straight forward enough but what about nonlinear regressions? With
linear model I do:
data<-read.csv(file, header=T)
attach(data)
mod1<-lm(column1~column2)
mod2<-lm(column1~column2+treatment)
anova(mod1,mod2)

The I can also go on to get the interaction by:

mod3<-lm(column1~column2*treatment)

But the same kind of methodology does not seem to work for nls
functions. How should I do? Can I linearize the data? how to do that in
a good way? The best would of course be if I could do it without
linearization.
Regards
Martin

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

2009-06-12 Thread Kenny Larsen
Hi,

A fairly basic problem I think, here although searching the inetrnet doesn't
seem to reveal a solution. I have a dataset with two columns of real
numbers. It is read in via read.table. I simply need to square the data in
the second column and then plot it. I have tried extracting the second
column (b <- z[2]) and then squaring it and merging it to a variable which
is the first column extracted. Firstly thsi seems very convoluted, secondly
it gives a seg fault (I'm guessing because memory hasn't been allocated for
the second column on the creation of teh first variable).

So any ideas about the easy way of doing the matsh so I can then just use
plot(z, .) as before?

Cheers in advance,

Kenny
-- 
View this message in context: 
http://www.nabble.com/Squaring-one-column-of-data-tp23997104p23997104.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] Multinomial logistic regression in an ANOVA-like framework

2009-06-12 Thread Stats Wolf
Dear all,

I have a problem for multinomial logistic regression: the response
variable is multinomial (score 1-5) and the two predictors are
categorical; all that comes from panelists (it's a kind of preference
study), which I treat as a block and include in the model (is it
correct?). I would like to see the results in the ANOVA-like
framework. Fitting the multinom() function from the nnet package works
pretty well and using the Anova() from the package car I got the
hypothesis testing for the predictors as well as their interaction.
However, I would like to go further and (because I am do look at means
when interpreting the results) I would like to make some kind of
multiple comparisons, if it is at all possible.

Any suggestions if I am doing anything wrong and if not, what could I
do to get these multiple comparisons?

Thank you,

Stats Wolf

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

2009-06-12 Thread Kenny Larsen
Have sorted it, it was simple, for anyone else who needs it:

z[2] <- z[2]*z[2]

squares the second column of a data table and writes it back to the second
column

Kenny



Kenny Larsen wrote:
> 
> Hi,
> 
> A fairly basic problem I think, here although searching the inetrnet
> doesn't seem to reveal a solution. I have a dataset with two columns of
> real numbers. It is read in via read.table. I simply need to square the
> data in the second column and then plot it. I have tried extracting the
> second column (b <- z[2]) and then squaring it and merging it to a
> variable which is the first column extracted. Firstly thsi seems very
> convoluted, secondly it gives a seg fault (I'm guessing because memory
> hasn't been allocated for the second column on the creation of teh first
> variable).
> 
> So any ideas about the easy way of doing the matsh so I can then just use
> plot(z, .) as before?
> 
> Cheers in advance,
> 
> Kenny
> 

-- 
View this message in context: 
http://www.nabble.com/Squaring-one-column-of-data-tp23997104p23997558.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] Squaring one column of data

2009-06-12 Thread baptiste auguie
Kenny Larsen wrote:

Hi,

A fairly basic problem I think, here although searching the inetrnet doesn't
seem to reveal a solution. I have a dataset with two columns of real
numbers. It is read in via read.table. I simply need to square the data in
the second column and then plot it. I have tried extracting the second
column (b <- z[2]) and then squaring it and merging it to a variable which
is the first column extracted. Firstly thsi seems very convoluted, secondly
it gives a seg fault (I'm guessing because memory hasn't been allocated for
the second column on the creation of teh first variable).

So any ideas about the easy way of doing the matsh so I can then just use
plot(z, .) as before?

Cheers in advance,

Kenny
  


Hi,

A few alternatives,

d <- data.frame(x = seq(1, 10), y=seq(1, 10))
d2 <- d # copy

# variants that make a new column
d$z <- d$y^2
d <- within(d, {z1 <- y^2})

# destructive transformation
d3 <- transform(d2, y=y^2)

ize  <-  # this may be useful if you want to apply a function to several 
columns (orig. idea from vQ)

function(d, columns=names(d), izer=`^`, ...)
{
  d[columns] = sapply(d[columns], izer, ...)
  d
}

d4 <- ize(d2, "y",`^`, 2)


HTH,

baptiste

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


[R] Snap axes to origin rather than around it

2009-06-12 Thread Paul Chatfield
I'm trying to plot a graph where the axes go through 0,0, rather than around
it combined with a box round the graph, so

x<-0:10;y<-0:10
plot(x,y) 

gives me a box but doesn't go through the point 0,0, but stays at a
distance.

In trying to circumvent this problem, I wrote 

plot(x,y)
axis(1, pos=c(0,0));axis(2,pos=c(0,0)) 

which gives me axes that go through the origin, but then I can't make a box
round a plot (box() goes again at this fixed distance from the origin rather
than through it)

Any thoughts, ideas gratefully accepted.  Perhaps I've been looking at it so
long I'm now missing the obvious! :)

Paul

Any ideas?
-- 
View this message in context: 
http://www.nabble.com/Snap-axes-to-origin-rather-than-around-it-tp23997802p23997802.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] External signal in ODE written in C (using deSolve and approx1?)

2009-06-12 Thread Glenn Woodart
Dear list

The deSolve package allows you to specify the model code in C or Fortran.
Thanks to the excellent vignette this works fine. However I have not yet
managed to use forcing functions in C code.

In pure R code this works very well with approxfun() specified outside the
model:

###
#Model
lvml <- function(t, x, parms) {
   with(as.list(c(parms, x)), {
 import <- sigimp(t)
 dS <- import - b*S*P + g*K #substrate
 dP <- c*S*P  - d*K*P   #producer
 dK <- e*P*K  - f*K #consumer
 res <- c(dS, dP, dK)
 list(res)
   })
 }

## Parameters
 parms  <- c(b = 0.0, c = 0.1, d = 0.1, e = 0.1, f = 0.1, g = 0.0)
## vector of timesteps
 times  <- seq(0, 100, length = 101)
## external signal with rectangle impulse
 signal <- as.data.frame(list(times = times,
 import = rep(0,length(times
signal$import[signal$times >= 10 & signal$times <= 21] <- 0.2
sigimp <- approxfun(signal$times, signal$import, rule = 2)
 ## Start values for steady state
y <- xstart <- c(S = 1, P = 1, K = 1)
## Solving
out2 <- as.data.frame(lsoda(xstart, times, lvml, parms))
###

I would like to do the same thing in C, and my guess is that the approx1
function has to be used in some way. So far did not figure out how. If
anyone has managed to do so, or know how to approach this problem, please
let me know.

Best wishes
Glenn

[[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] Snap axes to origin rather than around it

2009-06-12 Thread Marc Schwartz

On Jun 12, 2009, at 7:18 AM, Paul Chatfield wrote:



I'm trying to plot a graph where the axes go through 0,0, rather  
than around

it combined with a box round the graph, so

x<-0:10;y<-0:10
plot(x,y)

gives me a box but doesn't go through the point 0,0, but stays at a
distance.

In trying to circumvent this problem, I wrote

plot(x,y)
axis(1, pos=c(0,0));axis(2,pos=c(0,0))

which gives me axes that go through the origin, but then I can't  
make a box
round a plot (box() goes again at this fixed distance from the  
origin rather

than through it)

Any thoughts, ideas gratefully accepted.  Perhaps I've been looking  
at it so

long I'm now missing the obvious! :)

Paul

Any ideas?



See ?par and take note of 'xaxs' and 'yaxs':

  x <- 0:10
  y <- 0:10
  plot(x, y, xaxs = "i", yaxs = "i")

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

2009-06-12 Thread Martin Maechler
> "DM" == Duncan Murdoch 
> on Fri, 12 Jun 2009 06:09:14 -0400 writes:

DM> On 11/06/2009 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:

DM> One of the complaints about the S3 object system is that
DM> anything can claim to be of class "foo", even if it
DM> doesn't have the right structure so that foo methods
DM> work for it.  I think that's all you're seeing here:
DM> you've got something that is mislabelled as being of
DM> class "table".  The solution is "don't do that".

indeed!

>> 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 1 1 1 2 2 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?

DM> I would use as.numeric(), but I don't claim it's
DM> standard.

many months ago in a discussion about the use (and "misuse") of 
c() for coercing arrays/matrices to (atomic) vectors, Brian
Ripley  I think  advertized the use of as.vector() 
with which I strongly agree.

as.vector() here has the additional advantage of *not*
transforming integer into double.

Martin Maechler, ETH Zurich

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

2009-06-12 Thread Jim Lemon
Hi all,
I've been trying to work out how to slice an array of arbitrary 
dimension. I found a message showing how to stick two arrays together, 
but so far have been unable to transform that into what I need. Assume 
that I have a four dimensional array for example:


array4d
, , 1, 1

[,1] [,2]
[1,]36
[2,]11

, , 2, 1

[,1] [,2]
[1,]47
[2,]87

, , 1, 2

[,1] [,2]
[1,]78
[2,]87

, , 2, 2

[,1] [,2]
[1,]75
[2,]99

I want to slice the array from the rightmost dimension, getting in sequence:

array4d[,,,1]
array4d[,,,2]

then slicing those 3D arrays, and so on. I'm pretty sure that this will 
involve a:


do.call('[',...)

construction, but I haven't been able to work out how to specify the 
list of arguments, in particular the index vector, to slice up the last 
dimension. I have tried constructing index vectors with NULLs which of 
course doesn't work because they just disappear. Any suggestions?


Jim

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


[R] Programmatically copying a graphic to the clipboard

2009-06-12 Thread Hadley Wickham
Hi all,

Is there a cross-platform way to do this?  On the mac, I cando this by
saving an eps file, and then using pbcopy. Is it possible on other
platforms?

Hadley

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

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


Re: [R] Function for AIC or logLIK for nlsList object

2009-06-12 Thread Ben Bolker


Lindsay Banin wrote:
> 
> Dear R users,
> 
> Does anybody have a function to calculate logLik or AIC for nlsList
> objects? After receiving error messages, another user helped me ascertain
> that this function is not currently written into R.
> 

how about:

library(nlme)
example(nlsList)
sapply(fm1,logLik)
sum(sapply(fm1,logLik))

  ?

-- 
View this message in context: 
http://www.nabble.com/Function-for-AIC-or-logLIK-for-nlsList-object-tp23995762p23998109.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] Automate a data load and merge

2009-06-12 Thread Jon Loehrke
Hi R list,
I would like to automate, or speed up the process from which I take  
several separate datasets, stored in .csv formate, import and merge  
them by a common variable.  So far I have greatly sped up the loading  
process but cannot think of a way to automate the merger of all  
datasets into a common data.frame.
My apologies if this has been covered, any R search suggestions are  
appreciated.

# All scripts function out of the base directory
rm(list=ls())
setwd('/Users/myuser/Documents/workfolder/')

# Check files and list all .csv in directory
files<-list.files()
files<-files[grep('.csv', files)]
# Create labels for each file (ex. June08.csv becomes June08)
labels<-gsub('.csv', '', files)

# Load all .csv datasets and assign name

item<-vector() # preallocate an index of all items in datasets
for(i in 1:length(files)){
X<-read.csv(files[i])
item<-union(item, X$Item_Name)
assign(labels[i], X)
}
# What is loaded
ls()
# [1] "files""i""item" "June01" "June02" "June03"   
"labels"

# What does everything look like?
str(June03)
#'data.frame':  992 obs. of  8 variables:
# $ Item_Name: Factor w/ 992 levels "Birds","Fish",..: 1 2 3 4  
5 6 7 8 9 10 ...
# $ Occurance : int  30 30 50 450 75 550 100 500 250 75 ...

str(June01)
#'data.frame':  819 obs. of  8 variables:
# $ Item_Name: Factor w/ 819 levels "Birds","Turtles",..: 1 2  
3 4 5 6 7 8 9 10 ...
# $ Occurance : int  30 50 450 750 550 100 500 250 275 450 ...

# Here is where I'm stuck...
#I would like to:
#   Create a data.frame with an index column composed of the union of  
all items
#   Create columns in the frame by a merger of the 'Occurance' in each  
loaded dataset and are labeled by their name (eg. June01)
#   Automate this procedure so that I do not have to manuualy type in  
each column addition when I have a new dataset.

# This is my current strategy, but when I have new datasets I have to  
mannually setup the preallocation and merger

allData<-data.frame(Item=item, June01 =NA, June02=NA,  June03 =NA)
allData[match(June01$Item_Name, allData$Item ),]$June01 <-  
June01$Occurance
allData[match(June02$Item_Name, allData$Item ),]$June02 <-  
June02$Occurance
allData[match(June03$Item_Name, allData$Item ),]$June03 <-  
June03$Occurance

# Any help to automate this process is greatly appreciated!!!

sessionInfo()
#R version 2.9.0 (2009-04-17)
#i386-apple-darwin8.11.1
#
#locale:
#en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
#
#attached base packages:
#[1] stats graphics  grDevices utils datasets  methods   base


Jon Loehrke
Graduate Research Assistant
Department of Fisheries Oceanography
School for Marine Science and Technology
University of Massachusetts
200 Mill Road, Suite 325
Fairhaven, MA 02719
jloeh...@umassd.edu
T 508-910-6393
F 508-910-6396


[[alternative HTML version deleted]]

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


Re: [R] how to trigger variable creation?

2009-06-12 Thread Thomas Liebig
well,
for sure, one option is to trace the garbage collector gc() by a 
function that enumerates the list of known objects and compares this 
with its successor. But that's not reliable, as i can't really control 
when to call the garbage collector. i also don't like to enumerate 
objects and to compare these lists at each time step.


what else could be done?

cheers,
Thomas

Thomas Liebig schrieb:

Hello R users,

i'm wondering how to trigger variable creation.
Whenever a variable is created i want my own function myFun(...) to be 
started.


if (exists("x")) {rm(x)} # after removal of x
 # any of these calls
x<-10# should call myFun
x=10 # should call myFun
assign(x,10) # should call myFun
etc.
 # afterwards, each of the calls
x<-15# should not call myFun
x=15 # should not call myFun
assign(x,15) # should not call myFun
etc.

Has anyone an idea? Unfortunately, this feature is also missing in the 
library trackObjs.


regards,
Thomas



--
Thomas Liebig
Fraunhofer-Institut für Intelligente Analyse- und
Informationssysteme (IAIS)

Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
Email:  thomas.lie...@iais.fraunhofer.de
Phone:  +49 2241 142050
Fax:+49 2241 142072

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

2009-06-12 Thread spencerg
The "1L", etc., forces the number to be integer: 


> is.integer(1)
[1] FALSE
> is.integer(1L)
[1] TRUE


 Hope this helps. 
 Spencer


Paul Smith wrote:

On Thu, Jun 11, 2009 at 9:56 PM, Brecknock, Peter wrote:
  

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



Regarding your first question, I am not very sure, but it seems that

iL

means the constraint i.

Concerning your second question, the answer is positive. To force x_3
being an even number, just add the following constraints:

x_3 = 2 * y,

y >= 1,

y integer.

Paul

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




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

2009-06-12 Thread Olivier Nuñez
Dear John,

I have a question.

When I  run a RGtk code in my terminal (without using the R GUI)

R --vanilla << "EOF"
source("myRGtkcode.R")
EOF

the GTK objects do not remain on the screen.
Until now, I "bypass" this problem using the following commands:

require(tcltk)
tkmessageBox("Press to exit")

But it is not really satisfactory and the tcltk Box cannot be  
minimized (at least in Mac OSX).

Any idea?

Best regards. Olivier


--  


Olivier G. Nuñez
Email: onu...@iberstat.es
Tel : +34 663 03 69 09
Web: http://www.iberstat.es







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

2009-06-12 Thread David Carlson
You may have more luck with the triangle plot functions available in other R
libraries. In addition to triangle.plot in ade4, you have other options
(this may not be an exhaustive list):

plot.acomp in compositions
tri in cwhmisc.cwhtool
triax in plotrix
ternary in StatDA
ternaryplot in vcd
ternaryplot in Zelig


David L. Carlson
Anthropology Department
Texas A&M University
College Station, TX 77843-4352

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


[R] Sweave recode(car) and Lyx, compiling but not executing on Mac

2009-06-12 Thread Graham Smith
I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have
12 chunks of Sweave code that work fine, but this piece:

<<>>=
library(car)
cabbages$Year<-recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003';'X2004'='2004';'X2005'='2005';'X2006'='2006';'X2007'='2007';'X2008'='2008';'X2009'='2009';'X2010'='2010';'X2011'='2011';'X2012'='2012'")
@

just prints out verbatim as a single line running off the page (No
recoding occurs). It worked in R before pasting into Lyx.

Initially I had the double quotes and single quotes the other way
round, but this produced this in the complied pdf:
> cabbages$Year <- recode(cabbages$Year, 
> "\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc

The first double quote in the printout shown above was a single quote
before compiling.

I have asked on the Lyx forum for help, but maybe someone here can
suggest what I might be doing wrong. Of course it could be a Mac/Lyx
issue rather than an SWeave/R issue, but any help would be
appreciated.

Thanks,

Graham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] glm binomial logit - removing extra computations

2009-06-12 Thread utkarshsinghal
Hi all,

I am using glm function with family binomial(logit) to fit logistic 
regression model.  My data is very big and the algorithm is such that it 
has to run glm function hundreds of  times. Now *I need only the 
**estimates of the coefficients and std. error in my output, *but 
apparently glm function is computing several other statistics and 
parameters (mentioned below) which increases the run time.

[aic,  boundary,  call,  coefficients,  contrasts, control,  converged,  
data,  deviance, df.null, df.residual, effects, family, fitted.values, 
formula, iter, linear.predictors, method, model, null.deviance, offset, 
prior.weights, qr, R, rank, residuals, terms, weights, xlevels, y]

Is there a way (apart from scratching the glm code), which only do the 
minimal computations to output my requirements.

Any hints can be helpful.

Regards
Utkarsh



[[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] Slicing an array

2009-06-12 Thread Gabor Grothendieck
See the abind package.

On Fri, Jun 12, 2009 at 8:36 AM, Jim Lemon wrote:
> Hi all,
> I've been trying to work out how to slice an array of arbitrary dimension. I
> found a message showing how to stick two arrays together, but so far have
> been unable to transform that into what I need. Assume that I have a four
> dimensional array for example:
>
> array4d
> , , 1, 1
>
>    [,1] [,2]
> [1,]    3    6
> [2,]    1    1
>
> , , 2, 1
>
>    [,1] [,2]
> [1,]    4    7
> [2,]    8    7
>
> , , 1, 2
>
>    [,1] [,2]
> [1,]    7    8
> [2,]    8    7
>
> , , 2, 2
>
>    [,1] [,2]
> [1,]    7    5
> [2,]    9    9
>
> I want to slice the array from the rightmost dimension, getting in sequence:
>
> array4d[,,,1]
> array4d[,,,2]
>
> then slicing those 3D arrays, and so on. I'm pretty sure that this will
> involve a:
>
> do.call('[',...)
>
> construction, but I haven't been able to work out how to specify the list of
> arguments, in particular the index vector, to slice up the last dimension. I
> have tried constructing index vectors with NULLs which of course doesn't
> work because they just disappear. Any suggestions?
>
> Jim
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Creating this vector, any suggetions?

2009-06-12 Thread njhuang86
Suppose I have the first vector: c(1, 6, 8, 9)

I will like to create a second vector of size 10 composed of 0 and 1's. The
second vector will be composed of four 1's and six 0's. The position of the
1's will be specificed by the first vector. So essentially, I want a second
vector in the form:

c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)

Any help is greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000348.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] coupled ODE population model

2009-06-12 Thread Justin Frank

I'm fairly new to R, and I'm trying to write out a population model that
satisfies the following;

the system consists of s species, i= 1, 2,...,s
network of interactions between species is specified by a (s x s) real matrix,
C[i,j]

x[i] being the relative population of the "ith" species (0 =< x[i] =< 1,
sum(x[i]=1)

the evolution rule being considered is as follows;

xprime[i] = f[i] if x[i] > 0 or f[i] >= 0

xprime[i] = 0 if x[i] = 0 and f[i] < 0

where f[i] = sum(C[i,j]*x[j]) - x[i]*sum(C[k,j]*x[j])


I have a bit of attempted code written out, but are there any tricks or tips
that would condense or make this mess look nicer?

-Justin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Creating this vector, any suggetions?

2009-06-12 Thread Ben Bolker


njhuang86 wrote:
> 
> Suppose I have the first vector: c(1, 6, 8, 9)
> 
> I will like to create a second vector of size 10 composed of 0 and 1's.
> The second vector will be composed of four 1's and six 0's. The position
> of the 1's will be specificed by the first vector. So essentially, I want
> a second vector in the form:
> 
> c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)
> 
> Any help is greatly appreciated!
> 

z <- numeric(10)
pos <- c(1,6,8,9)
z[pos] <- 1


-- 
View this message in context: 
http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000457.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] Creating this vector, any suggetions?

2009-06-12 Thread Henrique Dallazuanna
Try this:

x <- c(1, 6, 8, 9)
tabulate(x, nbins = max(x) + 1)

On Fri, Jun 12, 2009 at 11:45 AM, njhuang86  wrote:

>
> Suppose I have the first vector: c(1, 6, 8, 9)
>
> I will like to create a second vector of size 10 composed of 0 and 1's. The
> second vector will be composed of four 1's and six 0's. The position of the
> 1's will be specificed by the first vector. So essentially, I want a second
> vector in the form:
>
> c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)
>
> Any help is greatly appreciated!
> --
> View this message in context:
> http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000348.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.


[R] R: Creating this vector, any suggetions?

2009-06-12 Thread Guazzetti Stefano
try this
 
>  a<-c(1, 6, 8, 9)
>  1*(1:10 %in% a)
 [1] 1 0 0 0 0 1 0 1 1 0

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di njhuang86
Inviato: Friday, June 12, 2009 4:45 PM
A: r-help@r-project.org
Oggetto: [R] Creating this vector, any suggetions?



Suppose I have the first vector: c(1, 6, 8, 9)

I will like to create a second vector of size 10 composed of 0 and 1's. The
second vector will be composed of four 1's and six 0's. The position of the
1's will be specificed by the first vector. So essentially, I want a second
vector in the form:

c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)

Any help is greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000348.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.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


"Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03)".

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-12 Thread Stavros Macrakis
On Fri, Jun 12, 2009 at 6:09 AM, Duncan Murdoch wrote:

> On 11/06/2009 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:
>>
>
> One of the complaints about the S3 object system is that anything can claim
> to be of class "foo", even if it doesn't have the right structure so that
> foo methods work for it.


Yes, that is one of its flaws.  More specifically, in this case, operations
on S3 objects can change them from being valid to being invalid.


> I think that's all you're seeing here:  you've got something that is
> mislabelled as being of class "table".


Yes.


> The solution is "don't do that".


Agreed!  But it's not clear to me how unname can *know* how not to do that
in the general case.  After all, unname on a vector of POSIXct's leaves a
valid POSIXct object.

...
>> PS What is the standard way of extracting just the underlying vector?
>> c(unname(...)) works -- is that what is recommended?
>>
>
> I would use as.numeric(), but I don't claim it's standard.
>

Makes sense, as does the suggestion as.vector.  So I guess the summary of
'stripping' operations is:

c  --- strip all attributes (including most but not all classes) except for
names
unname -- strip name attributes, but no other attributes (including class)
unclass -- strip only class attribute
as.vector -- strip all attributes including class and name; convert generic
vectors to atomic vectors

Am I missing others?

   -s

[[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] Slicing an array

2009-06-12 Thread Charles C. Berry


Jim,

Is

do.call( '[', list( array4d,TRUE,TRUE,TRUE,1 ) )

what you want?

HTH,

Chuck


On Fri, 12 Jun 2009, Jim Lemon wrote:


Hi all,
I've been trying to work out how to slice an array of arbitrary dimension. I 
found a message showing how to stick two arrays together, but so far have 
been unable to transform that into what I need. Assume that I have a four 
dimensional array for example:


array4d
, , 1, 1

   [,1] [,2]
[1,]36
[2,]11

, , 2, 1

   [,1] [,2]
[1,]47
[2,]87

, , 1, 2

   [,1] [,2]
[1,]78
[2,]87

, , 2, 2

   [,1] [,2]
[1,]75
[2,]99

I want to slice the array from the rightmost dimension, getting in sequence:

array4d[,,,1]
array4d[,,,2]

then slicing those 3D arrays, and so on. I'm pretty sure that this will 
involve a:


do.call('[',...)

construction, but I haven't been able to work out how to specify the list of 
arguments, in particular the index vector, to slice up the last dimension. I 
have tried constructing index vectors with NULLs which of course doesn't work 
because they just disappear. Any suggestions?


Jim

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



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

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


Re: [R] Tables without names

2009-06-12 Thread Gabor Grothendieck
On Fri, Jun 12, 2009 at 10:57 AM, Stavros Macrakis wrote:
> On Fri, Jun 12, 2009 at 6:09 AM, Duncan Murdoch wrote:
>
>> On 11/06/2009 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:
>>>
>>
>> One of the complaints about the S3 object system is that anything can claim
>> to be of class "foo", even if it doesn't have the right structure so that
>> foo methods work for it.
>
>
> Yes, that is one of its flaws.  More specifically, in this case, operations
> on S3 objects can change them from being valid to being invalid.
>
>
>> I think that's all you're seeing here:  you've got something that is
>> mislabelled as being of class "table".
>
>
> Yes.
>
>
>> The solution is "don't do that".
>
>
> Agreed!  But it's not clear to me how unname can *know* how not to do that
> in the general case.  After all, unname on a vector of POSIXct's leaves a
> valid POSIXct object.
>
> ...
>>> PS What is the standard way of extracting just the underlying vector?
>>> c(unname(...)) works -- is that what is recommended?
>>>
>>
>> I would use as.numeric(), but I don't claim it's standard.
>>
>
> Makes sense, as does the suggestion as.vector.  So I guess the summary of
> 'stripping' operations is:
>
> c  --- strip all attributes (including most but not all classes) except for
> names
> unname -- strip name attributes, but no other attributes (including class)
> unclass -- strip only class attribute
> as.vector -- strip all attributes including class and name; convert generic
> vectors to atomic vectors
>
> Am I missing others?

There is also unlist.

Also c and unlist are generic so their action can depend on the class
of their argument.

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

On Jun 12, 2009, at 10:13 AM, David Carlson wrote:

You may have more luck with the triangle plot functions available in  
other R
libraries. In addition to triangle.plot in ade4, you have other  
options

(this may not be an exhaustive list):

plot.acomp in compositions
tri in cwhmisc.cwhtool
triax in plotrix


Your posting was especially helpful because it is not reproducible  
with the combination of resutls from ??"triangle" amd ??"ternary". But  
in plotrix the function is triax.plot



ternary in StatDA
ternaryplot in vcd


Very nice looking plot if you add labels with the id= parameter. In  
the help page example using , id=rownames(tab), was what worked for me.



ternaryplot in Zelig


David L. Carlson
Anthropology Department
Texas A&M University
College Station, TX 77843-4352


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] R course in Italy

2009-06-12 Thread r...@quantide.com

Quantide is pleased to announce the above course in Milan:

--
   Introduction to the R language
6-7th July 2009
  Milano Italy
--

* Who Should Attend ?

This is a course suitable for beginners and improvers in the R language
and is ideal for people wanting an all round introduction to R

* Course Goals

- To allow attendees to understand the technology behind the R package
- Improve attendees programming style and confidence
- To enable users to access a wide range of available functionality

* Course Outline

1. Introduction to the R language and the R community
2. The R Environment
3. R data objects
4. Functions and Operators
5. Data import and export
7. Standard Graphics
8. Advanced Graphics
9. Introduction to R Statistics

The cost of this course is Euro 500+VAT

Should your organization have more than 3 possible attendees why not
talk to us about hosting a customized and focused course delivered at
your premises?

Should you want to book a place on this course or have any questions
please visit:
http://www.quantide.com/formazioneR.php
or contact:
Daniela Manzato
daniela.manz...@quantide.com
+39 328 537 51 09

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

2009-06-12 Thread Van Wyk, Jaap
I am trying to find studentized bootstrap intervals for the skewness of a data 
set. I have tried the following (nerve.dat is a set of data containing 
observations on one variable) (using Windows XP):

x <- scan("e:/Flashbackup2009/Nonparametrics/nerve.dat")
n <- length(x)
library(e1071)
skewness(x)
library(boot)
sampleskew <- function(x,d) {return(skewness(x[d]))}
bb <- boot(x,sampleskew,R=1000)
boot.ci(bb)


This gives four intervals (Normal, Basic, Percentile, BCa)
But gives the following warning message:

Warning message:
In boot.ci(bb, type = "all") :
  bootstrap variances needed for studentized intervals
The questions is: Why does the function not provide the bootstrap variances (or 
estimates thereof) for computing the studentized intervals?
Another question: How then can I compute the studentized intervals without 
physically doing a double bootstrap. Does the function use a "nonparametric 
delta mathod"?

Any help is much appreciated. I have probably overlooked something?

Thank you.
Jacob


Jacob L van Wyk, Dept. of Statistics, University of Johannesburg (APK),
Box 524, Auckland Park, 2006.
Office: +27 11 559 3080, Fax: +27 11 559 2499



This email and all contents are subject to the following disclaimer:

http://www.uj.ac.za/UJ_email_legal_disclaimer.htm

[[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] Sweave recode(car) and Lyx, compiling but not executing on Mac

2009-06-12 Thread John Fox
Dear Graham,

I just tried a similar recode() command using Sweave on a Windows system
(not through LyX) and it worked fine.

I hope this helps,
 John

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of Graham Smith
> Sent: June-12-09 10:27 AM
> To: r-help@r-project.org
> Subject: [R] Sweave recode(car) and Lyx, compiling but not executing on
Mac
> 
> I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have
> 12 chunks of Sweave code that work fine, but this piece:
> 
> <<>>=
> library(car)
> cabbages$Year<-
>
recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003';'X2004'='
2
>
004';'X2005'='2005';'X2006'='2006';'X2007'='2007';'X2008'='2008';'X2009'='20
0
> 9';'X2010'='2010';'X2011'='2011';'X2012'='2012'")
> @
> 
> just prints out verbatim as a single line running off the page (No
> recoding occurs). It worked in R before pasting into Lyx.
> 
> Initially I had the double quotes and single quotes the other way
> round, but this produced this in the complied pdf:
> > cabbages$Year <- recode(cabbages$Year,
> "\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc
> 
> The first double quote in the printout shown above was a single quote
> before compiling.
> 
> I have asked on the Lyx forum for help, but maybe someone here can
> suggest what I might be doing wrong. Of course it could be a Mac/Lyx
> issue rather than an SWeave/R issue, but any help would be
> appreciated.
> 
> Thanks,
> 
> Graham
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Automate a data load and merge

2009-06-12 Thread jim holtman
See if this works for you:

# read into a list and then rbind to single data frame
input <- do.call(rbind, lapply(files, function(.file){
X <- read.csv(.file)
X$label <- gsub('.csv$', '', .file)  # add name
X
}))
# use the reshape package
require(reshape)
i.melt <- melt(input, id=c("label", "Item_name"), measure="Occurance")
output <- cast(i.melt, Item_name ~ label)



On Fri, Jun 12, 2009 at 9:27 AM, Jon Loehrke  wrote:

> Hi R list,
>I would like to automate, or speed up the process from which I take
> several separate datasets, stored in .csv formate, import and merge
> them by a common variable.  So far I have greatly sped up the loading
> process but cannot think of a way to automate the merger of all
> datasets into a common data.frame.
>My apologies if this has been covered, any R search suggestions are
> appreciated.
>
> # All scripts function out of the base directory
> rm(list=ls())
> setwd('/Users/myuser/Documents/workfolder/')
>
> # Check files and list all .csv in directory
> files<-list.files()
> files<-files[grep('.csv', files)]
> # Create labels for each file (ex. June08.csv becomes June08)
> labels<-gsub('.csv', '', files)
>
> # Load all .csv datasets and assign name
>
> item<-vector() # preallocate an index of all items in datasets
> for(i in 1:length(files)){
>X<-read.csv(files[i])
>item<-union(item, X$Item_Name)
>assign(labels[i], X)
>}
> # What is loaded
> ls()
> # [1] "files""i""item" "June01" "June02" "June03"
> "labels"
>
> # What does everything look like?
> str(June03)
> #'data.frame':  992 obs. of  8 variables:
> # $ Item_Name: Factor w/ 992 levels "Birds","Fish",..: 1 2 3 4
> 5 6 7 8 9 10 ...
> # $ Occurance : int  30 30 50 450 75 550 100 500 250 75 ...
>
> str(June01)
> #'data.frame':  819 obs. of  8 variables:
> # $ Item_Name: Factor w/ 819 levels "Birds","Turtles",..: 1 2
> 3 4 5 6 7 8 9 10 ...
> # $ Occurance : int  30 50 450 750 550 100 500 250 275 450 ...
>
> # Here is where I'm stuck...
> #I would like to:
> #   Create a data.frame with an index column composed of the union of
> all items
> #   Create columns in the frame by a merger of the 'Occurance' in each
> loaded dataset and are labeled by their name (eg. June01)
> #   Automate this procedure so that I do not have to manuualy type in
> each column addition when I have a new dataset.
>
> # This is my current strategy, but when I have new datasets I have to
> mannually setup the preallocation and merger
>
> allData<-data.frame(Item=item, June01 =NA, June02=NA,  June03 =NA)
> allData[match(June01$Item_Name, allData$Item ),]$June01 <-
> June01$Occurance
> allData[match(June02$Item_Name, allData$Item ),]$June02 <-
> June02$Occurance
> allData[match(June03$Item_Name, allData$Item ),]$June03 <-
> June03$Occurance
>
> # Any help to automate this process is greatly appreciated!!!
>
> sessionInfo()
> #R version 2.9.0 (2009-04-17)
> #i386-apple-darwin8.11.1
> #
> #locale:
> #en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> #
> #attached base packages:
> #[1] stats graphics  grDevices utils datasets  methods   base
>
>
> Jon Loehrke
> Graduate Research Assistant
> Department of Fisheries Oceanography
> School for Marine Science and Technology
> University of Massachusetts
> 200 Mill Road, Suite 325
> Fairhaven, MA 02719
> jloeh...@umassd.edu
> T 508-910-6393
> F 508-910-6396
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

[[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] Automate a data load and merge

2009-06-12 Thread jim holtman
I think the last should be:

output <- cast(i.melt, Item_name ~ label, sum)




On Fri, Jun 12, 2009 at 9:27 AM, Jon Loehrke  wrote:

> Hi R list,
>I would like to automate, or speed up the process from which I take
> several separate datasets, stored in .csv formate, import and merge
> them by a common variable.  So far I have greatly sped up the loading
> process but cannot think of a way to automate the merger of all
> datasets into a common data.frame.
>My apologies if this has been covered, any R search suggestions are
> appreciated.
>
> # All scripts function out of the base directory
> rm(list=ls())
> setwd('/Users/myuser/Documents/workfolder/')
>
> # Check files and list all .csv in directory
> files<-list.files()
> files<-files[grep('.csv', files)]
> # Create labels for each file (ex. June08.csv becomes June08)
> labels<-gsub('.csv', '', files)
>
> # Load all .csv datasets and assign name
>
> item<-vector() # preallocate an index of all items in datasets
> for(i in 1:length(files)){
>X<-read.csv(files[i])
>item<-union(item, X$Item_Name)
>assign(labels[i], X)
>}
> # What is loaded
> ls()
> # [1] "files""i""item" "June01" "June02" "June03"
> "labels"
>
> # What does everything look like?
> str(June03)
> #'data.frame':  992 obs. of  8 variables:
> # $ Item_Name: Factor w/ 992 levels "Birds","Fish",..: 1 2 3 4
> 5 6 7 8 9 10 ...
> # $ Occurance : int  30 30 50 450 75 550 100 500 250 75 ...
>
> str(June01)
> #'data.frame':  819 obs. of  8 variables:
> # $ Item_Name: Factor w/ 819 levels "Birds","Turtles",..: 1 2
> 3 4 5 6 7 8 9 10 ...
> # $ Occurance : int  30 50 450 750 550 100 500 250 275 450 ...
>
> # Here is where I'm stuck...
> #I would like to:
> #   Create a data.frame with an index column composed of the union of
> all items
> #   Create columns in the frame by a merger of the 'Occurance' in each
> loaded dataset and are labeled by their name (eg. June01)
> #   Automate this procedure so that I do not have to manuualy type in
> each column addition when I have a new dataset.
>
> # This is my current strategy, but when I have new datasets I have to
> mannually setup the preallocation and merger
>
> allData<-data.frame(Item=item, June01 =NA, June02=NA,  June03 =NA)
> allData[match(June01$Item_Name, allData$Item ),]$June01 <-
> June01$Occurance
> allData[match(June02$Item_Name, allData$Item ),]$June02 <-
> June02$Occurance
> allData[match(June03$Item_Name, allData$Item ),]$June03 <-
> June03$Occurance
>
> # Any help to automate this process is greatly appreciated!!!
>
> sessionInfo()
> #R version 2.9.0 (2009-04-17)
> #i386-apple-darwin8.11.1
> #
> #locale:
> #en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> #
> #attached base packages:
> #[1] stats graphics  grDevices utils datasets  methods   base
>
>
> Jon Loehrke
> Graduate Research Assistant
> Department of Fisheries Oceanography
> School for Marine Science and Technology
> University of Massachusetts
> 200 Mill Road, Suite 325
> Fairhaven, MA 02719
> jloeh...@umassd.edu
> T 508-910-6393
> F 508-910-6396
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

[[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] Studentized intervals

2009-06-12 Thread Prof Brian Ripley
The help page ?boot.ci says

 Variance estimates are required for studentized intervals.


(and the warning you got repeated the point).

Package 'boot' is support software for a book by Davison & Hinkley 
which explains how to used boot.ci() for studentized examples and has 
several examples.  You will need to study it for further elucidation.



On Fri, 12 Jun 2009, Van Wyk, Jaap wrote:


I am trying to find studentized bootstrap intervals for the skewness of a data 
set. I have tried the following (nerve.dat is a set of data containing 
observations on one variable) (using Windows XP):

x <- scan("e:/Flashbackup2009/Nonparametrics/nerve.dat")
n <- length(x)
library(e1071)
skewness(x)
library(boot)
sampleskew <- function(x,d) {return(skewness(x[d]))}
bb <- boot(x,sampleskew,R=1000)
boot.ci(bb)


This gives four intervals (Normal, Basic, Percentile, BCa)
But gives the following warning message:

Warning message:
In boot.ci(bb, type = "all") :
 bootstrap variances needed for studentized intervals
The questions is: Why does the function not provide the bootstrap 
variances (or estimates thereof) for computing the studentized 
intervals? Another question: How then can I compute the studentized 
intervals without physically doing a double bootstrap. Does the 
function use a "nonparametric delta mathod"?


Any help is much appreciated. I have probably overlooked something?

Thank you.
Jacob


Jacob L van Wyk, Dept. of Statistics, University of Johannesburg (APK),
Box 524, Auckland Park, 2006.
Office: +27 11 559 3080, Fax: +27 11 559 2499



This email and all contents are subject to the following disclaimer:

http://www.uj.ac.za/UJ_email_legal_disclaimer.htm

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



--
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] Sweave recode(car) and Lyx, compiling but not executing on Mac

2009-06-12 Thread Graham Smith
John,

Thanks, its difficult when you don't know where the problem is. The
code works fine directly in R on the Mac, and from whta you say it
works with Sweave, so it seems to narrow it down to Lyx/Sweave/Mac
interaction.

Graham

2009/6/12 John Fox :
> Dear Graham,
>
> I just tried a similar recode() command using Sweave on a Windows system
> (not through LyX) and it worked fine.
>
> I hope this helps,
>  John
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
>> Behalf Of Graham Smith
>> Sent: June-12-09 10:27 AM
>> To: r-help@r-project.org
>> Subject: [R] Sweave recode(car) and Lyx, compiling but not executing on
> Mac
>>
>> I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have
>> 12 chunks of Sweave code that work fine, but this piece:
>>
>> <<>>=
>> library(car)
>> cabbages$Year<-
>>
> recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003';'X2004'='
> 2
>>
> 004';'X2005'='2005';'X2006'='2006';'X2007'='2007';'X2008'='2008';'X2009'='20
> 0
>> 9';'X2010'='2010';'X2011'='2011';'X2012'='2012'")
>> @
>>
>> just prints out verbatim as a single line running off the page (No
>> recoding occurs). It worked in R before pasting into Lyx.
>>
>> Initially I had the double quotes and single quotes the other way
>> round, but this produced this in the complied pdf:
>> > cabbages$Year <- recode(cabbages$Year,
>> "\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc
>>
>> The first double quote in the printout shown above was a single quote
>> before compiling.
>>
>> I have asked on the Lyx forum for help, but maybe someone here can
>> suggest what I might be doing wrong. Of course it could be a Mac/Lyx
>> issue rather than an SWeave/R issue, but any help would be
>> appreciated.
>>
>> Thanks,
>>
>> Graham
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Comparing model fits for NLME when models are not nested

2009-06-12 Thread Robert A LaBudde
At 05:42 AM 6/12/2009, Lindsay Banin wrote:

Hi there,

I am looking to compare nonlinear mixed effects models that have 
different nonlinear functions (different types of growth 
curve)embedded. Most of the literature I can find focuses on 
comparing nested models with likelihood ratios and AIC. Is there a 
way to compare model fits when models are not nested, i.e. when the 
nonlinear functions are not the same?


Transform back into original units, if necessary, and compare 
distributions of and statistics of residuals from fitted values in 
original units.


This is not a significance-test, but instead a measure of the better 
approximation to the observed model.


Types of measures: 1) rms residual, 2) max absolute residual, 3) mean 
absolute residual.


In my opinion, models should be chosen based on the principles of 
causality (theory), degree of approximation and parsimony. None of 
these involve significance testing.


Choosing models based upon significance testing (which merely 
identifies whether or not the experiment is large enough to 
distinguish an effect clearly) amounts to admitting intellectually 
that you have no subject matter expertise, and you must therefore 
fall back on the crumbs of significance testing to get glimmers of 
understanding of what's going on. (Much like stepwise regression techniques.)


As an example, suppose you have two models, one with 5 parameters and 
one with only 1. The rms residual error for the two models are 0.50 
and 0.53 respectively. You have a very large study, and all 4 
additional parameters are significant at p = 0.01 or less.  What 
should you do? What I would do is select the 1 parameter study as my 
baseline model. It will be easy to interpret physically, will 
generalize to other studies much better (stable), and is almost 
identical in degree of approximation as the 5 parameter model. I 
would be excited that a one parameter model could do this. The fact 
that the other 4 parameters have detectable effects at a very low 
level is not important for modeling the study, but may conceivably 
have some special significance on their own for future investigations.


So not being able to do significance testing on non-nested models is 
not that big a loss, in my opinion. Such tests encourage wrong 
thinking, in my opinion.


What I've expressed as an opinion here (which I am sure some will 
disagree with) is similar to the philosophy of choosing the number of 
principal components to use, or number of latent factors in factor 
analysis. What investigation do people ever do on the small 
eigenvalue principal components, even if their contributions are 
"statistically significant"?



Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: r...@lcfltd.com
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

"Vere scire est per causas scire"

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

2009-06-12 Thread Robbie Morrison
Hello R users

I am looking for a package to visualize "relatively
planar" directed graphs, with say 100 nodes and
specified using an adjacency list.

'Rgraphviz', currently listed on the R-FAQ, seemed
suitable (FAQ version 2.9.2009-06-05)

But when I looked for the package, I found it had been
recently "removed" and was instead directed to archive
copies (http://cran.r-project.org/web/packages/Rgraphviz)

Can anybody suggest an alternative R package ('igraph'
perhaps)?  Or would I be better it generate my own .gv
GraphViz files and then pass these directly to
GraphViz.  Or will 'Rgraphviz' return soon?

Any suggestions much appreciated, Robbie
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : morri...@iet.tu-berlin.de
Webmail (preferred)   : rob...@actrix.co.nz
[from IMAP client]

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

2009-06-12 Thread Martin Morgan
Robbie Morrison wrote:
> Hello R users
> 
> I am looking for a package to visualize "relatively
> planar" directed graphs, with say 100 nodes and
> specified using an adjacency list.
> 
> 'Rgraphviz', currently listed on the R-FAQ, seemed
> suitable (FAQ version 2.9.2009-06-05)
> 
> But when I looked for the package, I found it had been
> recently "removed" and was instead directed to archive
> copies (http://cran.r-project.org/web/packages/Rgraphviz)

Rgraphviz is available in Bioconductor

  http://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html

Martin

> 
> Can anybody suggest an alternative R package ('igraph'
> perhaps)?  Or would I be better it generate my own .gv
> GraphViz files and then pass these directly to
> GraphViz.  Or will 'Rgraphviz' return soon?
> 
> Any suggestions much appreciated, Robbie
> ---
> Robbie Morrison
> PhD student -- policy-oriented energy system simulation
> Technical University of Berlin (TU-Berlin), Germany
> University email (redirected) : morri...@iet.tu-berlin.de
> Webmail (preferred)   : rob...@actrix.co.nz
> [from IMAP client]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] FBI Homicide data?

2009-06-12 Thread Mario Valle
Dear all,
do you know if it's available and where the "FBI Homicide" dataset?
It has at least the following columns: "victim age", "homicide age".
A scatterplot of this data is visible here:
 http://www.uml.edu/gallery/main.php?g2_itemId=6016

Thanks for your help!
mario
-- 
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.


[R] using lattice dotplot with two equal data points

2009-06-12 Thread Chosid, David (FWE)
I'm wondering if I am dealing with a limitation in lattice.  It's
probably due to my own limitations though.  

I'm working with a lattice dotplot.  The x-axis is set at "free".  In
one panel, there are only two data points that have equal x-axis values.
Since no range exists, lattice isn't plotting those points. It reports: 

"Error Packet using 6 
'x' and 'units' must have length>0" 

Is there a way that I can get it to plot anyway?  Do I have to
manipulate that one panel?  Any suggestions on how to do that?  I'd
rather have some sort of automatic backup range set instead.

David Chosid
Massachusetts Division of Marine Fisheries
1213 Purchase St., 3rd Floor
New Bedford, MA 02740
508-990-2860 x140
email: david.cho...@state.ma.us

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


Re: [R] Sweave recode(car) and Lyx, compiling but not executing on Mac

2009-06-12 Thread Graham Smith
Just to follow this up. Changing the document encoding in Lyx from the
default (whatever that was) to utf8 (with some help from Jay)  allowed
some sample"recode"  code  to run (it wouldn't run initially), but my
original code still won't run.

Strangely looking at the Latex code window in Lyx shows some strange
syntax highlighting in my code

cabbages$Year<-recode(cabbages$Year,"'X2001'...

The code is higlighted between the $ signs  and I wonder if this
suggests there are still some sort of encoding problem.

Graham

2009/6/12 John Fox :
> Dear Graham,
>
> I just tried a similar recode() command using Sweave on a Windows system
> (not through LyX) and it worked fine.
>
> I hope this helps,
>  John
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
>> Behalf Of Graham Smith
>> Sent: June-12-09 10:27 AM
>> To: r-help@r-project.org
>> Subject: [R] Sweave recode(car) and Lyx, compiling but not executing on
> Mac
>>
>> I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have
>> 12 chunks of Sweave code that work fine, but this piece:
>>
>> <<>>=
>> library(car)
>> cabbages$Year<-
>>
> recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003';'X2004'='
> 2
>>
> 004';'X2005'='2005';'X2006'='2006';'X2007'='2007';'X2008'='2008';'X2009'='20
> 0
>> 9';'X2010'='2010';'X2011'='2011';'X2012'='2012'")
>> @
>>
>> just prints out verbatim as a single line running off the page (No
>> recoding occurs). It worked in R before pasting into Lyx.
>>
>> Initially I had the double quotes and single quotes the other way
>> round, but this produced this in the complied pdf:
>> > cabbages$Year <- recode(cabbages$Year,
>> "\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc
>>
>> The first double quote in the printout shown above was a single quote
>> before compiling.
>>
>> I have asked on the Lyx forum for help, but maybe someone here can
>> suggest what I might be doing wrong. Of course it could be a Mac/Lyx
>> issue rather than an SWeave/R issue, but any help would be
>> appreciated.
>>
>> Thanks,
>>
>> Graham
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Mixture of normals

2009-06-12 Thread Jim Silverton
Can anyone send me the R code for fitting a mixture of normal distributions.
Or in fact any'combination' of mixtures of distributions. I looke dta mix
but it is still not clear to me.


Jim

[[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] Mixture of normals

2009-06-12 Thread David Winsemius
The package mixtools appears a more appropriate place to look.


On Jun 12, 2009, at 2:57 PM, Jim Silverton wrote:

Can anyone send me the R code for fitting a mixture of normal  
distributions.
Or in fact any'combination' of mixtures of distributions. I looke  
dta mix

but it is still not clear to me.


Jim

[[alternative HTML version deleted]]

--

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] Sweave recode(car) and Lyx, compiling but not executing on Mac

2009-06-12 Thread Graham Smith
While this is a bit embarrassing , it seems I had two problems, one
was that the recode command seems to need utf8 coding rather than the
Lyx default (which is fine), plus I had typing error in the data set,
which is not fine :-(.

I rewrote my code using the with command which allowed it to run, but
it then became obvious that the recoded resuts were not what I had
expected. The typing error then being obvious.

The first entry in my rcode was 'X2001'='2001' but the first level in
the data set was "X20001" and this was enough to cause recode to fail
in my original code, but run using the with command.

Its now working.

Thanks to everyone for there help.

Graham

2009/6/12 Graham Smith :
> I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have
> 12 chunks of Sweave code that work fine, but this piece:
>
> <<>>=
> library(car)
> cabbages$Year<-recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003';'X2004'='2004';'X2005'='2005';'X2006'='2006';'X2007'='2007';'X2008'='2008';'X2009'='2009';'X2010'='2010';'X2011'='2011';'X2012'='2012'")
> @
>
> just prints out verbatim as a single line running off the page (No
> recoding occurs). It worked in R before pasting into Lyx.
>
> Initially I had the double quotes and single quotes the other way
> round, but this produced this in the complied pdf:
>> cabbages$Year <- recode(cabbages$Year, 
>> "\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc
>
> The first double quote in the printout shown above was a single quote
> before compiling.
>
> I have asked on the Lyx forum for help, but maybe someone here can
> suggest what I might be doing wrong. Of course it could be a Mac/Lyx
> issue rather than an SWeave/R issue, but any help would be
> appreciated.
>
> Thanks,
>
> Graham
>

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


Re: [R] Mixture of normals

2009-06-12 Thread David Winsemius

On Jun 12, 2009, at 3:13 PM, David Winsemius wrote:


The package mixtools appears a more appropriate place to look.


... as well as:   http://cran.r-project.org/web/views/Cluster.html



On Jun 12, 2009, at 2:57 PM, Jim Silverton wrote:

Can anyone send me the R code for fitting a mixture of normal  
distributions.
Or in fact any'combination' of mixtures of distributions. I looke  
dta mix

but it is still not clear to me.


Jim

[[alternative HTML version deleted]]

--


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] xtable for plm objects

2009-06-12 Thread Stephen J. Barr
Hello,

I am trying to use Sweave to write up a report, and I have used the
plm package to do some panel models. I am trying to use xtable to make
a nice table for my regression objects (returned by the plm command),
but I am getting the error:
Error in UseMethod("xtable") : no applicable method for "xtable"

It seems like I would want to have xtable treat plm objects exactly as
lm objects. Is there a way I can force this behavior?

Thanks,
-stephen
==
Stephen J. Barr
University of Washington
WEB: www.econsteve.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] funnel plots

2009-06-12 Thread deanj2k
for the function funnelplot(), how do I include 95% confidence intervals for
the effect estimate ( ie. / \ )?
-- 
View this message in context: 
http://www.nabble.com/funnel-plots-tp24003106p24003106.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] Order data frame

2009-06-12 Thread MarcioRibeiro
Hi listers,
I have a data frame with 5 variables... And I want reorder the data frame
according a specific variable X...
I checked the sort and order functions... In my case I think that the ORDER
function is applicable... But I did not understand at all... The idea is
simple... Data order by X...
I know that this is very simple... Anyways... How I would do that...
Thanks in advance,
Marcio

-- 
View this message in context: 
http://www.nabble.com/Order-data-frame-tp24004394p24004394.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] Market Basket Analysis / Link Analysis

2009-06-12 Thread THEMARKETINGANALYSTS
The concept behind 
http://themarketinganalysts.com/en/pages/market-basket-analysis/ Market
Basket Analysis  is relatively simple but it requires a huge server and lots
of processing power.  If you run into problems and need to run your data on
larger machine, please keep us in mind.  We would be happy to provide you
with a free quote.  We are located in the Dallas/Fort Worth area if that
helps too.  Please feel free to visit our site at
www.themarketinganalysts.com.  



eugene dalt wrote:
> 
> 
> Hi folks,
> 
> I am looking for Market Basket Analysis / Link Analysis tools in R,
> packages or functions.
> 
> Tx - Eugene
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/Market-Basket-AnalysisLink-Analysis-tp23992852p24004518.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] Mixture of normals

2009-06-12 Thread Bert Gunter
.. and package mixdist.

Google on "R mixture models" or similar.

Bert Gunter
Genentech Nonclinical Biostatistics


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Winsemius
Sent: Friday, June 12, 2009 12:14 PM
To: Jim Silverton
Cc: r-help@r-project.org
Subject: Re: [R] Mixture of normals

The package mixtools appears a more appropriate place to look.


On Jun 12, 2009, at 2:57 PM, Jim Silverton wrote:

> Can anyone send me the R code for fitting a mixture of normal  
> distributions.
> Or in fact any'combination' of mixtures of distributions. I looke  
> dta mix
> but it is still not clear to me.
>
>
> Jim
>
>   [[alternative HTML version deleted]]
-- 

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] xtable for plm objects

2009-06-12 Thread Achim Zeileis
On Fri, 12 Jun 2009, Stephen J. Barr wrote:


Hello,

I am trying to use Sweave to write up a report, and I have used the
plm package to do some panel models. I am trying to use xtable to make
a nice table for my regression objects (returned by the plm command),
but I am getting the error:
Error in UseMethod("xtable") : no applicable method for "xtable"

It seems like I would want to have xtable treat plm objects exactly as
lm objects. Is there a way I can force this behavior?


I quickly checked and it seems that the xtable() method for "lm" objects 
just relies on the fact that


  summary(object)$coef

is the matrix with coef/std.error/t-stat/p-value. As this is the case for 
"plm" objects, I think you can do


  xtable.plm <- xtable:::xtable.lm

and then

  xtable(plm_object)

should give the desired result.

hth,
Z


Thanks,
-stephen
==
Stephen J. Barr
University of Washington
WEB: www.econsteve.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] Order data frame

2009-06-12 Thread Henrique Dallazuanna
Try this:

DF <- data.frame(ID = sample(5), v = rnorm(5))
DF[order(DF$ID),]

On Fri, Jun 12, 2009 at 3:54 PM, MarcioRibeiro  wrote:

>
> Hi listers,
> I have a data frame with 5 variables... And I want reorder the data frame
> according a specific variable X...
> I checked the sort and order functions... In my case I think that the ORDER
> function is applicable... But I did not understand at all... The idea is
> simple... Data order by X...
> I know that this is very simple... Anyways... How I would do that...
> Thanks in advance,
> Marcio
>
> --
> View this message in context:
> http://www.nabble.com/Order-data-frame-tp24004394p24004394.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] Competing risks Kalbfleisch & Prentice method

2009-06-12 Thread Ravi Varadhan
Dear Terry, Eleni & Heinz,

Please forgive me for imposing on your time, but since we have had similar
discussions before on this topic, I thought that it would be nice to get
your feedback on this problem.  

I have written a function to compute the cumulative incidence, for a given
covariate vector Z, based on Cox PH models for each competing event type.
It is based on Cheng, Fine, and Wei (Biometrics 1998), but is fairly
straightforward.  Fine calls it "indirect regression" approach, since it
models each cause-specific hazard and then puts it all together using the
basic definition of CIF.  I applied it to the Green & Byar data on DES trial
for prostate cancer (this data set was also discussed in Kay 1986 and Cheng
et al. 1998).  The data set is attached as STATA file, which can be read
into R using "foreign" package.

My function for CIF seems to do ok. However, I am not sure about this. I
computed the CIFs of prostate cancer for two sets of covariates (see the
code).  I compared the indirect CIFs to the "direct regression " CIFs
predicted by Fine & Gray's method.  There appears to be some significant
differences, especially for CVD deaths.  The CIF plots for the 3 competing
events can be easily generated by runnng the code.

Why would there be a big difference between FG direct approach and the
indirect CIF computed by my code? Is this because of the modeling
assumptions in the direct regression approach of FG? Or is there some
problem with my approach?

I would appreciate any comments.  

Thank you,
Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: Eleni Rapsomaniki [mailto:er...@medschl.cam.ac.uk] 
Sent: Friday, March 27, 2009 10:44 AM
To: Terry Therneau; tuech...@gmx.at; Ravi Varadhan
Cc: r-help@r-project.org
Subject: RE: RE: Competing risks Kalbfleisch & Prentice method


Dear Prof. Therneau, 

Thank you for your views on this subject. I think all R users who play with
survival analysis are most grateful for the functions you have already
supplied us with.

I'm guessing Ravi is wondering why you have not implemented the smoothing of
the baseline hazard from the Cox model. 

I actually tried to do this originally, inspired from this thread (i.e use
sm.spline to smooth the hazard):
https://stat.ethz.ch/pipermail/r-help/2004-July/053843.html

but it overestimated the CI (perhaps I implemented it wrong). I was then
advised to treat CI as a step function, rather than continuous, which means
that F(t+1, cause k)-F(t, cause k) will be 0 unless an event of cause k has
occurred in that interval (see also "Competing Risks, by Melanie Pintilie,
page 62). This is obviously problematic if one wants to estimate the CI at
times that are not close to observed events for either cause (perhaps a
parametric model could be used in this case).
But then again, this was not an issue wtih my data. 

Eleni Rapsomaniki
 Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care University of Cambridge
 

-Original Message-
From: Terry Therneau [mailto:thern...@mayo.edu]
Sent: 27 March 2009 13:53
To: Eleni Rapsomaniki; tuech...@gmx.at; Ravi Varadhan
Cc: r-help@r-project.org
Subject: RE: Competing risks Kalbfleisch & Prentice method

Ravi's last note finished with
>  I am wondering why Terry Therneau's "survival" package doesn't  have 
> this option.

  The short answer is that there are only so many hours in a day.  

  I've recently moved the code base from an internal Mayo repository to
R-forge, one long term goal with this is to broaden the developer base to
n>2 (me and Thomas Lumley).  
  
  A longer statistical answer:
  
  I'm not sure if the "this" of Ravi's question is a. smoothed hazards, b.
the K&P cumulative incidence or c. the Fine & Gray model.
  
  b. I like the CI model and am using it more.  We also have local code.
The
latest version of survival (on rforge, likely in the next default R
release) has
added simple CI curves to the survfit function.  Adding code for survfit on
Cox models is on the todo list.  But -- this release also fixes up
survfit.coxph to handle weighted Cox models and that was on my list for
approx 10 years, i.e., don't hold your breath.  I don't release something
until it also has a set of worked out test cases to add to the 'tests'
directory.
  
  a. smoothed hazards.  For the case at hand I don't see any particular
advantage of this.  On the other hand, I often would like to display hazard
functions instead of CI functions for Cox models; with time dependent
covariates I don

[R] R and Sound

2009-06-12 Thread Mike McGonagle
Hello,

I recently have started to learn about R, and am interested in using
it to generate data that would then get used to produce audio.

Basically, I am "envisioning" using R to create the data, based on
probability functions (and fractal data), which then gets output as a
text data file, and then processed by CSound to produce the finished
audio.

My interests are based on some of the work by Iannis Xenakis of using
probability functions to generate various synthesis parameter data.

Just curious if anyone has used this method of working with R.

Thanks,

-- 

Mae West  - "I like restraint, if it doesn't go too far." -
http://www.brainyquote.com/quotes/authors/m/mae_west.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.


[R] Referencing data frames

2009-06-12 Thread Payam Minoofar
Hi,

How do I use the string content of a string variable to reference a data frame 
of the same name? I want to do the typical tasks of 1) building a name with a 
string variable and using the string variable to create a data frame (or any 
object) whose name is the string value of the variable and 2) pass on a string 
to a function as a parameter, and then use that string to refer to an existing 
data frame.

Thanks in advance.

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] Referencing data frames

2009-06-12 Thread Duncan Murdoch
On 12/06/2009 6:00 PM, Payam Minoofar wrote:

Hi,

How do I use the string content of a string variable to reference a data frame 
of the same name? I want to do the typical tasks of 1) building a name with a 
string variable and using the string variable to create a data frame (or any 
object) whose name is the string value of the variable and 2) pass on a string 
to a function as a parameter, and then use that string to refer to an existing 
data frame.

Thanks in advance.


assign() and get() do the basic bits.  They aren't specific to dataframes.

Duncan Murdoch



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.


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

2009-06-12 Thread Kynn Jones
Is there a *fast* converter between JSON and R?  I'm aware of the rjson
package, but it is implemented in R, and it is too slow for my purposes.
TIA!

kynn

[[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] Fast JSON <-> R converter?

2009-06-12 Thread Duncan Temple Lang

It is not so much that rjson is implemented in R that makes it slow, 
just that it does not use vectorized operations.



The package RJSONIO

   http://www.omegahat.org/RJSONIO

can be used as a drop-in replacement for rjson and was written to be 
faster (by using vectorized operations) and extensible via S4 methods.


(We use R to JSON in the SVGAnnotation, FlashMXML and RGraphicsDevice 
packages.)


 D.

Kynn Jones wrote:

Is there a *fast* converter between JSON and R?  I'm aware of the rjson
package, but it is implemented in R, and it is too slow for my purposes.
TIA!

kynn

[[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] Extracting the name of an object

2009-06-12 Thread Payam Minoofar
With apologies if I missed the answer in the response given to my previous 
question.

How do I extract the name of an object and assign it to a string variable?

For example, I have a dataframe named comnoglyc

How do I assign this name to a variable dfname such that print(dfname) returns 
"comnoglyc"?

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] formatting numbers along axes as percents for perspective plot

2009-06-12 Thread Stephen Samaha
Hello, I'm producing a 3D plot using the persp function. All my values for X, 
Y, and Z are decimals ranging from 0 to 1. I'd like to be able format the three 
axes so that the tick values are 0% 20% 40%, etc... instead of just being 0 .2 
.4. Does anyone know how to do this?
 
Many thanks,
 
Steve


  
[[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] Extracting the name of an object

2009-06-12 Thread Duncan Murdoch
On 12/06/2009 7:53 PM, Payam Minoofar wrote:

With apologies if I missed the answer in the response given to my previous 
question.

How do I extract the name of an object and assign it to a string variable?

For example, I have a dataframe named comnoglyc

How do I assign this name to a variable dfname such that print(dfname) returns 
"comnoglyc"?


Objects don't know their own names, so this isn't possible in general.
However, arguments know what expression was passed as their value, which 
is somewhat similar. For example, the function


> f <- function(x) deparse(substitute(x))

uses substitute() to get the expression passed as x and then converts it 
to a string using deparse:


> f(comnoglyc)
[1] "comnoglyc"

Duncan Murdoch

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


Re: [R] formatting numbers along axes as percents for perspective plot

2009-06-12 Thread David Winsemius
Have you considered multiplying all values by 100?


On Jun 12, 2009, at 7:56 PM, Stephen Samaha wrote:

Hello, I'm producing a 3D plot using the persp function. All my  
values for X, Y, and Z are decimals ranging from 0 to 1. I'd like to  
be able format the three axes so that the tick values are 0% 20%  
40%, etc... instead of just being 0 .2 .4. Does anyone know how to  
do this?


Many thanks,

Steve



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] Referencing data frames

2009-06-12 Thread Steven McKinney
Hi Payam,

Here's a basic example using pointless
data frames and an otherwise useless
function to illustrate the issues you
want 

> ## Fresh R session with nothing yet defined
> foo <- data.frame(matrix(1:12, ncol = 3))
> bar <- data.frame(matrix(101:112, ncol = 3))
> 
> objects()
[1] "bar" "foo"
> 
> myrbind <- function(names) {
+   df1 <- get(names[1])
+   df2 <- get(names[2])
+   dfrbind <- rbind(df1, df2)
+   dfrbind.name <- paste(names, collapse = ".")
+   assign(dfrbind.name, dfrbind, pos = 1)
+   invisible()
+ }
> 
> dfnames <- c("foo", "bar", "baz")
> myrbind(dfnames)
> objects()
[1] "bar" "dfnames" "foo" "foo.bar.baz" "myrbind"
> foo.bar.baz
   X1  X2  X3
1   1   5   9
2   2   6  10
3   3   7  11
4   4   8  12
5 101 105 109
6 102 106 110
7 103 107 111
8 104 108 112
> 


HTH


Steven McKinney, Ph.D.

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: r-help-boun...@r-project.org on behalf of Payam Minoofar
Sent: Fri 6/12/2009 3:00 PM
To: r-help@r-project.org
Subject: [R] Referencing data frames
 
Hi,

How do I use the string content of a string variable to reference a data frame 
of the same name? I want to do the typical tasks of 1) building a name with a 
string variable and using the string variable to create a data frame (or any 
object) whose name is the string value of the variable and 2) pass on a string 
to a function as a parameter, and then use that string to refer to an existing 
data frame.

Thanks in advance.

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.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Insignificant variable improves AIC (multinom)?

2009-06-12 Thread Werner Wernersen
Hi,

I am trying to specify a multinomial logit model using the multinom function 
from the nnet package. Now I add another independent variable and it halves the 
AIC as given by summary(multinom()). But when I call Anova(multinom()) from the 
car package, it tells me that this added variable is insignificant 
(Pr(>Chisq)=0.39). Thus, the improved AIC suggests to keep the variable but the 
Anova suggests to drop it.

I am sure this is due to my lack of understanding of these models but could 
someone help me out with a pointer what my mistake is?

Thanks so much,
  Werner





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sending a function as an argument to C code.

2009-06-12 Thread Ian Fiske

Christophe Genolini wrote:
> 
> 
> In order to optimize the code, I would like to write myFunc in C. Is it 
> possible, in the C code, to call a function define in R (dist1 or dist2) 
> that will be send to myFunc as an argument ?
> 
> Christophe
> 
> 

You want to read section 5.11: "Evaluating R expressions from C" in the
Writing R Extensions manual.  Especially look at the lapply2 example.

Ian
-- 
View this message in context: 
http://www.nabble.com/Sending-a-function-as-an-argument-to-C-code.-tp23994631p24008711.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] standard error beta glm

2009-06-12 Thread Ian Fiske

Ricardo Arias Brito wrote:
> 
> Dear All,
> 
> 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.
> 

Does sqrt(diag(vcov(fit.glm))) not give you what you need?

Ian
-- 
View this message in context: 
http://www.nabble.com/standard-error-beta-glm-tp23987737p24008764.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] [R-help] how to install own R withour root?

2009-06-12 Thread Daofeng Li
Hi,

i had intstalled R in my home directory
and i can run the new install R from /path_of_my_home/R/bin/R
but when i type R, it runs the system installed older R 2.4
can i just type an R command and it runs my new installed R?

Thanks!

On Tue, Jun 9, 2009 at 4:00 PM, Paul Hiemstra  wrote:

> Hi,
>
> In addition. You can also install everything just in your home drive. Using
> the configure script you can change the installation path of all R related
> stuff:
>
> ./configure --prefix=/home/bla/progsandlibs
>
> The binaries end up in ~/progsandlibs/bin, and the libraries in
> ~/progsandlibs/bin. If you use this consistently with all the programs you
> install using ./configure and add progsandlibs to you $PATH, you can install
> all the software in your home drive with no difference in functionality.
>
> cheers,
> Paul
>
>
> Patrick Connolly wrote:
>
>> On Tue, 09-Jun-2009 at 11:50AM +0800, Daofeng Li wrote:
>>
>> |> Dear list members,
>> |> |> i am currently want to install Rpy2 in a linux box which has R 2.4.0
>> |> installed
>> |> RPy requries R 2.7.0 or above
>> |> but i have no root previlleges
>> |> so my question is how to install R 2.7.0 on my own directory?
>>
>> You might as well install R-2.9.0 while you're at it.
>>
>> |> and replace the system installed R 2.4.0 when i input R command from
>> the
>> |> bash Shell?
>>
>> You can download the R-2.9.0.tar.gz to a directory you have access to.
>> I'll call it ~/Rhome/
>>
>> uncompress the file with tar xvzf R-2.9.0.tar.gz
>> and then move to the R-2.9.0 subdirectory that will be created.
>>
>> In that directory, you'll find a file called INSTALL which will give
>> you very simple clear directions.  Don't try to make a site-wide
>> installation which isn't appropriate in your case.
>>
>> The executable will be at ~/Rhome/R-2.9.0/bin/R
>>
>> Assuming you have a ~/bin directory, I find the simplest thing is to
>> make a link in that directory to the executable.
>>
>> Now the part that might be slightly tricky.  If you can't get someone
>> with root access to remove the R-2.4.0 installation, it's simple
>> enough to prevent it clashing with your newer version.  Make the name
>> of the link in ~/bin/ something slightly different from R, such as RR
>> or whatever you fancy.  You then start R with that name.
>>
>> HTH
>>
>>
>>
>>
>>
>
>
> --
> 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
>
>


-- 
Daofeng Li,PhD Candidate
China Agricultural University

[[alternative HTML version deleted]]

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


Re: [R] [R-help] how to install own R withour root?

2009-06-12 Thread Bill.Venables
You need to adjust your PATH environment variable so that the 
/path_of_my_home/R/bin comes ahead of the system R/bin directory.  (Or you can 
simply remove the system R/bin and substitute your own R/bin.

W.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Daofeng Li [lid...@gmail.com]
Sent: 13 June 2009 15:28
To: Paul Hiemstra
Cc: r-help@r-project.org
Subject: Re: [R] [R-help] how to install own R withour root?

Hi,

i had intstalled R in my home directory
and i can run the new install R from /path_of_my_home/R/bin/R
but when i type R, it runs the system installed older R 2.4
can i just type an R command and it runs my new installed R?

Thanks!

On Tue, Jun 9, 2009 at 4:00 PM, Paul Hiemstra  wrote:

> Hi,
>
> In addition. You can also install everything just in your home drive. Using
> the configure script you can change the installation path of all R related
> stuff:
>
> ./configure --prefix=/home/bla/progsandlibs
>
> The binaries end up in ~/progsandlibs/bin, and the libraries in
> ~/progsandlibs/bin. If you use this consistently with all the programs you
> install using ./configure and add progsandlibs to you $PATH, you can install
> all the software in your home drive with no difference in functionality.
>
> cheers,
> Paul
>
>
> Patrick Connolly wrote:
>
>> On Tue, 09-Jun-2009 at 11:50AM +0800, Daofeng Li wrote:
>>
>> |> Dear list members,
>> |> |> i am currently want to install Rpy2 in a linux box which has R 2.4.0
>> |> installed
>> |> RPy requries R 2.7.0 or above
>> |> but i have no root previlleges
>> |> so my question is how to install R 2.7.0 on my own directory?
>>
>> You might as well install R-2.9.0 while you're at it.
>>
>> |> and replace the system installed R 2.4.0 when i input R command from
>> the
>> |> bash Shell?
>>
>> You can download the R-2.9.0.tar.gz to a directory you have access to.
>> I'll call it ~/Rhome/
>>
>> uncompress the file with tar xvzf R-2.9.0.tar.gz
>> and then move to the R-2.9.0 subdirectory that will be created.
>>
>> In that directory, you'll find a file called INSTALL which will give
>> you very simple clear directions.  Don't try to make a site-wide
>> installation which isn't appropriate in your case.
>>
>> The executable will be at ~/Rhome/R-2.9.0/bin/R
>>
>> Assuming you have a ~/bin directory, I find the simplest thing is to
>> make a link in that directory to the executable.
>>
>> Now the part that might be slightly tricky.  If you can't get someone
>> with root access to remove the R-2.4.0 installation, it's simple
>> enough to prevent it clashing with your newer version.  Make the name
>> of the link in ~/bin/ something slightly different from R, such as RR
>> or whatever you fancy.  You then start R with that name.
>>
>> HTH
>>
>>
>>
>>
>>
>
>
> --
> 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
>
>


--
Daofeng Li,PhD Candidate
China Agricultural University

[[alternative HTML version deleted]]

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

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