Re: [R] 3D plot

2010-02-19 Thread Jim Lemon

On 02/19/2010 03:43 AM, David A.G wrote:


Dearl list,

can anyone point me to a function or library that can create a graph similar to 
the one in the following powerpoint presentation?

http://bmi.osu.edu/~khuang/IBGP705/BMI705-Lecture7.ppt

(pages 36-37)

In order to try to explain the graph, the way I see it in R terms is something 
like this:

the "p-q" axis is a vector of positions (for example, seq(0,500,1))
the "Chr1-Chrx" is a vector of units, in this case chromosomes (so something 
like seq(1,10,1))
the plotted data is observations for each unit at each position

I guess the fancy gradient on the highest peaks is tougher to get (knowing I am 
not an R expert), but just plain blue would suffice.

I have checked some of the graphs in the R graph gallery but I don´t think any 
of them would work


Hi Dave,
This is a sort of 2.5D plot, with each chromosome being a 2D plot spaced 
out on the z axis. If we assume that it is a static viewpoint, it would 
be a case of drawing the parallelogram "base", then overlaying a 
sequence of polygons with the appropriate offset to give the 3D 
appearance. My eyeball says that there is no perspective correction.


Doable, but I would advise asking on the Bioconductor mailing list first.

Jim

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


Re: [R] Deleting colmuns with 0's and also writing multple csv files

2010-02-19 Thread DarioAustralia

Hi Anna,

A column with all 0s will have a column sum of zero. So do this :

dataset1[, which(colSums(dataSet1 > 0))]

If you have a list of data.frames you could do this

for(index in 1:10)
{
write.csv(yourListOfTables[[index]], file = paste("Dataset", index,
".csv", sep = ""), row.names = FALSE)
}

- Dario.
-- 
View this message in context: 
http://n4.nabble.com/Deleting-colmuns-with-0-s-and-also-writing-multple-csv-files-tp1561219p1561231.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] Date label lost while inverting y axis.

2010-02-19 Thread Jeremie Smaga
Good morning,

I am currently displaying a time series with the time on the Y axis, and the
values on the X axis.
The problem is that I wanted to reverse the Y axis (that is, to have the
latest date the closest to the X axis).
So I looked for a way to do this on this mailing list and I found a
response: inverting the ylim parameter of the plot.
I did it, the data are displayed correctly, but now the problem is that
there is no more labels on the Y axis.
How should I proceed to have it back?


Here is my code:

***
  sMin=min(series[,2:3])
  sMax=max(series[,2:3])
  
plot(series[,2],dates,xlim=c(sMin,sMax),ylim=c(max(dates),min(dates)),col="green",main="",type="l",xlab="Value")
***

Thanks,

-- 
Jeremie

[[alternative HTML version deleted]]

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


[R] How to use same function for diffrent input values

2010-02-19 Thread Madhavi Bhave
Dear R helpers
 
I have written some function (the actual code I have pasted at the end of mail) 
like say
 
indiv_rate = function(n, rate_name, rate, rate_rf1, rate_rf2, rate_rf3, 
rateprob1, rateprob2, rateprob3)

{
some R commands
 
return(data.frame(rate_name, rates = round(rate_data, digits = 4)))
 
}
 
## INPUT
 
rates = indiv_rate(n = read.csv('number.csv')$n, rate_name = 
read.csv('rate.csv')$rate_name, rate = read.csv('rate.csv')$rate, rate_rf1 = 
read.csv('rate_rf.csv')$rate_rf1, 
 rate_rf2 = read.csv('rate_rf.csv')$rate_rf2, rate_rf3 
= read.csv('rate_rf.csv')$rate_rf3, 
   rateprob1 = read.csv('rate_probability.csv')$probability1, rateprob2 = 
read.csv('rate_probability.csv')$probability2, rateprob3 = 
read.csv('rate_probability.csv')$probability3)
 
 
## OUTPUT
 
write.csv(data.frame(rates), 'indiv rates generated.csv', row.names = FALSE)

##___ end of code 
 
So for given rate (which I am deining as rate = read.csv('rate.csv')$rate), I 
get the desired results.
 
My problem is how do I use this fuction for different 'rates' i.e. for any 
given rate, I run the function and store the result with the respective rate 
name?
 
Regards
 
Madhavi
 
(PS - I am avoiding to paste my actual code consuming 60 lines. Still, if 
somene insists, I can post the same)
 
 
 


  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
[[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] Underlay Mapoutlines with Googlemapspictures

2010-02-19 Thread Malte Christian

Hello,

i created a picture with the outlines of mosambik. Does anyone now,  
how i could mack a background the outlines with a map from mosambik  
from googlemaps?



library(maps)
library(mapdata)
library(akima)

map("worldHires", "Moz")


regads

Malte

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Deleting colmuns with 0's and also writing multple csv files

2010-02-19 Thread K. Elo
Hi!

Right, my solution did not take into accound paired negative values
summing up to zero.

This should work in all cases:

df[, which(colSums(df!=0)!=0)]

Kind regards,
Kimmo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 use same function for diffrent input values

2010-02-19 Thread Barry Rowlingson
On Fri, Feb 19, 2010 at 8:20 AM, Madhavi Bhave  wrote:

> rates = indiv_rate(n = read.csv('number.csv')$n, rate_name = 
> read.csv('rate.csv')$rate_name, rate = read.csv('rate.csv')$rate, rate_rf1 = 
> read.csv('rate_rf.csv')$rate_rf1,
>  rate_rf2 = read.csv('rate_rf.csv')$rate_rf2, 
> rate_rf3 = read.csv('rate_rf.csv')$rate_rf3,
>    rateprob1 = read.csv('rate_probability.csv')$probability1, rateprob2 = 
> read.csv('rate_probability.csv')$probability2, rateprob3 = 
> read.csv('rate_probability.csv')$probability3)

 I'm not sure I understand your question fully, but this example above
shows me you have a few other things to learn. Don't do the same thing
more than once. Here you are reading the csv files several times.
That's horribly inefficient. Do it once, and store the value in a
variable:

 rateprobthing = read.csv('file.csv')

and then use 'rateprobthing$whatever' each time. It'll make your code
faster and easier to understand.

 For your question about different rates and whatnot, I don't think
it's clear where your different rates come from - is it a whole
different set of .csv files?

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [R] problem with multiple plots (mfrow, mar)

2010-02-19 Thread Jim Lemon

On 02/19/2010 04:10 AM, Peter Neuhaus wrote:

Dear R-users,

I often stack plots that have the same x-axis. To save space and have
the plots themselves as large as possible I like to minimize the margins
between the plots to zero. I use the "mfrow" and "mar" parameters to
achieve this.

However, the different margin settings for the individual plots lead to
the inner plots being higher than the two outer plots. To make the
data in the individual subplots visually comparable, I would like
to have all plots with a plotting area of exactly the same height.


Hi Peter,
The two par arguments "fin" and "pin" allow a solution. What you want is 
for the second values in "pin" (Plot dimensions in INches) to be the 
same for all your plots. You can get an approximation by using the 
layout function instead of mfrow and setting the height vector to 
correct for the space used in the top and bottom plots. If you are not 
doing lots of these plots or you are doing only a few variations, you 
can just print out par("pin") after each plot and see how much they 
differ and adjust the height vector until all "pin"s are the same. Try 
setting the height vector in layout to the "fin"s (Figure dimensions in 
INches) that are printed out using the default of all heights equal.


Jim

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


Re: [R] Use of R in clinical trials

2010-02-19 Thread Dieter Menne

Bert,

I like your comments. There is one issue, however, that drives me crazy
whenever I meet a customer asking "You are not using SAS? Too bad, we need
validated results."


Bert Gunter wrote:
> 
> ...
> Also to reiterate, it's not only
> statistical/reporting functionality but even more the integration into the
> existing clinical database systems that would have to be rewritten **and
> validated**. 
> 
> 

Implicitly: Even if you let your cat enter SAS code, the results are
correct, because they SAS is validated.

Dieter



-- 
View this message in context: 
http://n4.nabble.com/Use-of-R-in-clinical-trials-tp1559402p1561317.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] ellipsis-related error: used in an incorrect context, no ... to look in

2010-02-19 Thread lith
Does nobody have an advice concerning that problem? If it is a FAQ,
I'd appreciate a pointer to a discussion of this issue. With the docs
accessible to me, I wasn't able to solve that problem.

>     require(lattice)
>     f.barchart <- function(...) {
>         barchart(...,
>             panel = function(x, y, ...) {
>                 panel.barchart(x, y, ...)
>             }
>         )
>     }
>
>     x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
>     f.barchart(a ~ b, data = x, groups = c)
>
> Which results in the following error being thrown:
>
>     ..3 used in an incorrect context, no ... to look in

Regards,
Tom

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

2010-02-19 Thread Araujo-Enciso, Sergio Rene
I am having some problems using Quadprog in R. I want to minimize the
objective function :

 

200*P1-1/2*10*P1^2+100*P2-1/2*5*P2^2+160*P3-1/2*8*P3^2+50*P4-1/2*10*P4^2+50*P
5-1/2*20*P5^2+50*P6-1/2*10*P6^2, 

 

Subject to a set of constrains including not only the variables P1, P2, P3,
P4, P5, P6, but also the variables X1, X2,X3,X4,X5,X6,X7,X8,X9.

 

 As the set of variables X's are not affecting the objective function, I
assume that I have to enter them as zero's in the vector "dvec" and the
matrix "Dmat". 

 

My program states as: 

 

mat<-matrix(0,15,15)

diag(Dmat)<-c(10,5,8,10,20,10,0,0,0,0,0,0,0,0,0)

dvec<- c(-200,-100,-160,-50,-50,-50,0,0,0,0,0,0,0,0,0)

Amat<- matrix(c(-1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,1,

 0,0,0,0,0,0,0,0,0,0,0,0,0,-1,1,0,0,0,0,

 0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0,0,0,0,0,

 0,0,0,0,-1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,

 0,-1,0,1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,

 1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0,0,

 0,0,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,0,0,0,0,

 -10,0,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,0,-5,0,

 0,0,0,0,-1,0,0,-1,0,0,-1,0,0,0,-8,0,0,0,0,

 0,-1,0,0,-1,0,0,-1,0,0,0,-10,0,0,1,1,1,0,0,

 0,0,0,0,0,0,0,0,-20,0,0,0,0,1,1,1,0,0,0,0,0,

 0,0,0,-10,0,0,0,0,0,0,1,1,1),15,15)

bvec <-c(0,-2,-2,-2,0,-1,-2,-1,0,-200,-100,-160,-50,-50,-50)

solve.QP(Dmat,dvec,Amat,bvec=bvec)

 

Nonetheless I get the message: "Error en solve.QP(Dmat, dvec, Amat, bvec =
bvec) : matrix D in quadratic function is not positive definite!".

 

I think it has to do with the fact that in the Dmat matrix I end up with
several columns with zeros. Do anyone have an idea of how to solve such a
problem? 

 

Bests, 

 

Sergio René


[[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] Error using update.packages

2010-02-19 Thread Göran Broström
I'm updating packages by

$ sudo R --vanilla
.
> update.packages()

when I (finally) get the error message:

Error in unloadNamespace(pkg_name) :
  name space 'survival' is still used by: 'eha'
* removing '/usr/local/lib64/R/library/survival'
* restoring previous '/usr/local/lib64/R/library/survival'
-
I have never seen this before. I guess that R at start-up has read my
personal .Rprofile
and it seems to be the case: when I remove it, install.packages()
works as expected.

According to my understanding, the --vanilla flag should make R ignore
.Rprofile, so
what have I missed? Note that sessionInfo() does not report 'eha'.

 > sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-unknown-linux-gnu

locale:
 [1] LC_CTYPE=sv_SE   LC_NUMERIC=C LC_TIME=sv_SE
 [4] LC_COLLATE=sv_SE LC_MONETARY=CLC_MESSAGES=sv_SE
 [7] LC_PAPER=sv_SE   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=sv_SE LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] tcltk_2.10.1 tools_2.10.1

Göran Broström

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


[R] How to specify R CMD INSTALL arguments

2010-02-19 Thread Patrick Connolly
I've become a bit rusty using R CMD INSTALL from the shell prompt
since the install.packages normally works so well.

One of the arguments to R CMD INSTALL is --configure-args=ARGS

>From looking at the rsprng package's configure file, it would seem
that I need to be able to get this line to work:
SPRNG_INCLUDE="-I${SPRNG_ROOT}/include"

My sprng.h is in /usr/local/sprng2.0/include/, so I think I need to
know how I specify what SPRNG_ROOT is with --configure-args.  I
couldn't work out where braces, quotes and $ characters are used in
this context.

Or do I have to specify SPRNG_ROOT as an environment variable?


TIA


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Update RMySQL and ... it's no more running

2010-02-19 Thread PtitBleu

Hello,

I updated the RMySQL (and DBI) package but, since, it doesn't run anymore.
I followed the advices given here 
http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL
but with no success.
I also copied the libMySQL.dll in the bin directory of R. Also no good
result.

The error message (in french sorry) is just below. It seems there is a
problem with the registry key but I'm not good enough to solve this (without
the MySQL Gui Tools, it also doesn't work).
Below the error message, you will find the result of the command
readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)

If someone can help me ...
Thanks in advance,
Have a nice week-end,
Ptit Bleu.



> library(RMySQL)
Le chargement a nécessité le package : DBI
Error in fun(...) : 
  A MySQL Registry key was found but the folder C:\MySQL\MySQL Tools for
5.0\/. doesn't contain a bin or lib/opt folder. That's where we need to find
libmySQL.dll. 
De plus : Warning messages:
1: le package 'RMySQL' a été compilé avec la version R 2.9.2 
2: le package 'DBI' a été compilé avec la version R 2.9.2 
Error : .onLoad a échoué dans 'loadNamespace' pour 'RMySQL'
Erreur : le chargement du package / espace de noms a échoué pour 'RMySQL'

> readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)
$`MySQL Administrator 1.2`
$`MySQL Administrator 1.2`$Location
[1] "C:\\MySQL\\MySQL Tools for 5.0\\"

$`MySQL Administrator 1.2`$Version
[1] "5.0.17"


$`MySQL Connector/ODBC 3.51`
$`MySQL Connector/ODBC 3.51`$Version
[1] "3.51.27"


$`MySQL Migration Toolkit 1.1`
$`MySQL Migration Toolkit 1.1`$Location
[1] "C:\\MySQL\\MySQL Tools for 5.0\\"

$`MySQL Migration Toolkit 1.1`$Version
[1] "5.0.17"


$`MySQL Query Browser 1.2`
$`MySQL Query Browser 1.2`$Location
[1] "C:\\MySQL\\MySQL Tools for 5.0\\"

$`MySQL Query Browser 1.2`$Version
[1] "5.0.17"


$`MySQL Server 5.1`
$`MySQL Server 5.1`$DataLocation
[1] "C:\\MySQL\\MySQL Server 5.1\\"

$`MySQL Server 5.1`$FoundExistingDataDir
[1] "0"

$`MySQL Server 5.1`$Location
[1] "C:\\MySQL\\MySQL Server 5.1\\"

$`MySQL Server 5.1`$Version
[1] "5.1.44"


$`MySQL Tools for 5.0`
$`MySQL Tools for 5.0`$Location
[1] "C:\\MySQL\\MySQL Tools for 5.0\\"

$`MySQL Tools for 5.0`$Version
[1] "5.0.17"



-- 
View this message in context: 
http://n4.nabble.com/Update-RMySQL-and-it-s-no-more-running-tp1561401p1561401.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] Error message when using error.bars(x,add=TRUE)

2010-02-19 Thread Peter Ehlers

On 2010-02-18 8:22, fussel wrote:


Hey hey,
I`m analyzing a data set containing the element contentrations of various
samples...
I wanted to construct notched boxplots and got quite ugly results for some
of the boxplots. The notches are often larger then the hinges which resulted
in weird looking edges (even though I`m using a log-boxplot). To avoid this
problem I thought about using "normal" log-boxplots and adding some kind of
parantheses for showing the confidence interval.
I found an option to do this with the help of the package "psych".

It works beautifully for sth like that:
x<- replicate(20,rnorm(50))
boxplot(x,notch=TRUE,main="Notched boxplot with error bars")
error.bars(x,add=TRUE)
abline(h=0)


Beautifully? To me, that's one of the ugliest plots I've seen
in a while. But, as they say, it's in the eye of the beholder.

Anyway, what is the purpose of the notches? It's not clear
to me that you understand them. There's a good reason why the
notches sometimes stick out beyond the box. This is usually
the result of a small sample. If you have variable sample sizes
you might find variable-width boxplots somewhat informative.
Personally, I don't have much for use notched boxplots.



I tried to apply this to my own dataset:

## Ag
boxplotDAS(log10(Ag)~Aquifer,ylab="",xlab="Ag (mg/l)", main="",
data=samples, notch=TRUE, horizontal=TRUE, xaxt="n", col="gray85")
error.bars(samples,add=TRUE)
axis(1,at=log10(a<-sort(c((10^(-50:50))%*%t(c(1,5),labels=a, tick=T)
abline(v=log10(a),lty=3,col='gray')


I end up with lots of error messages - all of them saying:

Warning in arrows(s[s], x.stats$mean[s] - ci[s] * x.stats$se[s], s[s],
x.stats$mean[s] +  :
   zero-length arrow is of indeterminate angle and so skipped

What does that mean and how can I get rid of it? Any ideas?


These warning (not 'error') messages come from error.bars().
Why not try to plot the error bars without any boxplots to see
where the problems might lie. As a check, I would also do the
confidence interval calculations 'by hand'.

Or you could provide a *reproducible* example, preferably
minimal (i.e. skip the xlab= , etc stuff) and someone might
try the code and tell you where the problems lie.

 -Peter Ehlers


Thanks a lot,
fussel



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ellipsis-related error: used in an incorrect context, no ... to look in

2010-02-19 Thread Felix Andrews
The problem is related to the processing of the 'groups' argument,
which is subject to non-standard evaluation. The groups argument is
substitute()d and evaluated in a special context ('data' etc). But
this gets messed up if you are not passing the symbol directly. The
work-around is to rewrite the call inside f.barchart (as is done in,
for example, lattice:::barchart.formula)

Example:

f.barchart <- function(...) {
ccall <- match.call()
ccall[[1]] <- quote(barchart)
ccall$panel <- function(x, y, ...) {
   panel.barchart(x, y, ...)
   }
eval.parent(ccall)
}

   x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
   f.barchart(a ~ b, data = x, groups = c)

It is also good practice to update the $call component of the trellis
object to reflect your high-level function:

ans <- eval.parent(ccall)
ans$call <- match.call()
ans



On 19 February 2010 19:58, lith  wrote:
> Does nobody have an advice concerning that problem? If it is a FAQ,
> I'd appreciate a pointer to a discussion of this issue. With the docs
> accessible to me, I wasn't able to solve that problem.
>
>>     require(lattice)
>>     f.barchart <- function(...) {
>>         barchart(...,
>>             panel = function(x, y, ...) {
>>                 panel.barchart(x, y, ...)
>>             }
>>         )
>>     }
>>
>>     x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
>>     f.barchart(a ~ b, data = x, groups = c)
>>
>> Which results in the following error being thrown:
>>
>>     ..3 used in an incorrect context, no ... to look in
>
> Regards,
> Tom
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

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


[R] Plotting multiple table automatically

2010-02-19 Thread KennyL

Hi All,

I have a slight issue getting R to plot a series of tables automatically.
Essentially I have a series of tables that I wish to plot. They are named
on_2, on_3 etc. based on the file name when they were read in. I have
filelist <- list.files() to give me list of the table names. I wish to plot
each table, so I was thinking along some kind of for loop as below:

for (i in 1:Number_Files) {
plot(filelist[1])
}

With a few other bits a pieces, however obviously this tries to plot the
character string in filelist, any ideas on how to get R to read the
identically named table and plot that?

Thanks,

Kenny
-- 
View this message in context: 
http://n4.nabble.com/Plotting-multiple-table-automatically-tp1561478p1561478.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] Plotting multiple table automatically

2010-02-19 Thread Jim Lemon

On 02/19/2010 10:32 PM, KennyL wrote:


Hi All,

I have a slight issue getting R to plot a series of tables automatically.
Essentially I have a series of tables that I wish to plot. They are named
on_2, on_3 etc. based on the file name when they were read in. I have
filelist<- list.files() to give me list of the table names. I wish to plot
each table, so I was thinking along some kind of for loop as below:

for (i in 1:Number_Files) {
plot(filelist[1])
}

With a few other bits a pieces, however obviously this tries to plot the
character string in filelist, any ideas on how to get R to read the
identically named table and plot that?


Hi Kenny,
It's a bit hard to tell without seeing the data, but I think you may 
have the table in text form in the file, so you probably want something 
like:


for(i in 1:Number_files) {
 tabledata<-read.table(filelist[i])
 plot(tabledata,...)
}

But the reading in will depend upon what format the data are in the files.

Jim

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


Re: [R] Underlay Mapoutlines with Googlemapspictures

2010-02-19 Thread Roger Bivand

(Note that you did not follow the posting guide - please always start a new
thread/question by creating a new message - do not simply reply to an
existing posting erasing the subject; such a message stays in the old thread
and is hard to find in the archives)

See package RgoogleMaps on your nearest CRAN mirror to load image tiles.

Roger Bivand

-
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway

-- 
View this message in context: 
http://n4.nabble.com/Date-label-lost-while-inverting-y-axis-tp1561283p1561498.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] Plotting multiple table automatically

2010-02-19 Thread Paul Hiemstra

KennyL wrote:

Hi All,

I have a slight issue getting R to plot a series of tables automatically.
Essentially I have a series of tables that I wish to plot. They are named
on_2, on_3 etc. based on the file name when they were read in. I have
filelist <- list.files() to give me list of the table names. I wish to plot
each table, so I was thinking along some kind of for loop as below:

for (i in 1:Number_Files) {
plot(filelist[1])
}

With a few other bits a pieces, however obviously this tries to plot the
character string in filelist, any ideas on how to get R to read the
identically named table and plot that?

Thanks,

Kenny
  

Hi Kenny,

Take a look at parse() if you want it do your way, but consider the 
following much better way. Read the files into a list first not in 
seperate R objects, something like:


list_tables = lapply(list.files(), read.table)
?lapply

and plot:

for(tab %in% list_tables) plot(tab)

cheers,
Paul

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

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


[R] dot-dot-dot as an actual argument

2010-02-19 Thread Jyotirmoy Bhattacharya
I could not find any documentation of how dot-dot-dot works when used
as an argument in a function call (rather than as a formal argument in
a definition). I would appreciate some references to the rules
governing situations like:

f1<-function(x,y,...){
  print(x)
}

f2<-function(...){
  f1(...)
}

f2(1,2,3)

In the call above how are the three numbers bound to the individual
formal arguments x and y of f1 rather than f1 being called with a
single pairlist, which is what the documentation says ... is.

And while the example above succeeds, why does the following fail,

library(lattice)
f.barchart <- function(...) {
    barchart(...)
}

x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
print(f.barchart(a ~ b, data = x, groups = d))

This gives the error:
Error in eval(expr, envir, enclos) :
  ..3 used in an incorrect context, no ... to look in

Jyotirmoy Bhattacharya

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

2010-02-19 Thread KennyL

Thanks to you both, 

Both methods work, I was trying to do what you have suggested earlier Paul,
but got in a mess, thanks for the code I can see why it was all going wrong
now!

Kenny
-- 
View this message in context: 
http://n4.nabble.com/Plotting-multiple-table-automatically-tp1561478p1561507.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] dot-dot-dot as an actual argument

2010-02-19 Thread Gabor Grothendieck
It likely has to do with the fact that barchart uses unevaluated
arguments.  Look at its source by entering its name without arguments:
barchart

This does work:

library(lattice)
f.barchart2 <- function(...) eval.parent(substitute(barchart(...)))

x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
print(f.barchart2(a ~ b, data = x, groups = d))


On Fri, Feb 19, 2010 at 6:25 AM, Jyotirmoy Bhattacharya
 wrote:
> I could not find any documentation of how dot-dot-dot works when used
> as an argument in a function call (rather than as a formal argument in
> a definition). I would appreciate some references to the rules
> governing situations like:
>
> f1<-function(x,y,...){
>   print(x)
> }
>
> f2<-function(...){
>   f1(...)
> }
>
> f2(1,2,3)
>
> In the call above how are the three numbers bound to the individual
> formal arguments x and y of f1 rather than f1 being called with a
> single pairlist, which is what the documentation says ... is.
>
> And while the example above succeeds, why does the following fail,
>
> library(lattice)
> f.barchart <- function(...) {
>     barchart(...)
> }
>
> x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
> print(f.barchart(a ~ b, data = x, groups = d))
>
> This gives the error:
> Error in eval(expr, envir, enclos) :
>  ..3 used in an incorrect context, no ... to look in
>
> Jyotirmoy Bhattacharya
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] dot-dot-dot as an actual argument

2010-02-19 Thread Paul Hiemstra

Jyotirmoy Bhattacharya wrote:

I could not find any documentation of how dot-dot-dot works when used
as an argument in a function call (rather than as a formal argument in
a definition). I would appreciate some references to the rules
governing situations like:

f1<-function(x,y,...){
  print(x)
}
  

it would print(x), probably complain that y is missing

f2<-function(...){
  f1(...)
}

f2(1,2,3)
  

Hi!

print the .. and see what happens:

f2<-function(...){
 f1(...)
 print(list(...))
}

f2(1,2,3)


In the call above how are the three numbers bound to the individual
formal arguments x and y of f1 rather than f1 being called with a
single pairlist, which is what the documentation says ... is.

And while the example above succeeds, why does the following fail,

library(lattice)
f.barchart <- function(...) {
barchart(...)
}

x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
print(f.barchart(a ~ b, data = x, groups = d))

This gives the error:
Error in eval(expr, envir, enclos) :
  ..3 used in an incorrect context, no ... to look in
  
The problem is that d is a column in x and not a seperate R object. This 
is solved in barchart because the function knows that it needs to look 
in x for d. The problem only is that when the third (group = d) is taken 
from the ... (..3) it doesn't find any R object called d. So it crashes 
with the above error.


cheers,
Paul

Jyotirmoy Bhattacharya

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



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

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


[R] Confused about appending to list behavior...

2010-02-19 Thread Jason Rupert

Through help from the list and a little trial and error (mainly error) I think 
I figured out a couple of ways to append to a list.  Now I am trying to access 
the data that I appended to the list.   The example below shows where I'm 
trying to access that information via two different methods.  It turns out that 
trying to access the data the way one would elements in a data.frame does not 
work.  However, using the standard way of accessing data from a list, a la 
[[...]], seems to provide an answer.   

By any chance is there more documentation out there on lists and this behavior, 
as I would like to try to better understand what is really going on and why one 
approach works and another doesn't.   

Thank you again for all the help and feedback, as I love lists and especially 
the fact (that unlike data.frames) you can store different "type" data and also 
arrays of different lengths.   They are great. 




> example_list<-list(tracking<-c("house"), house_type<-c("brick", "wood"), 
> sizes<-c(1600, 1800, 2000, 2400))
> example_list
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

> 
> cost_limits<-c(20.25, 350010.15)
> 
> example_list[[4]]<-cost_limits
> 
> example_list
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

[[4]]
[1] 20.2 350010.2

> c(example_list,list(CostStuff=cost_limits))
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

[[4]]
[1] 20.2 350010.2

$CostStuff
[1] 20.2 350010.2

> example_list$CostStuff
NULL
> example_list[[5]]
Error in example_list[[5]] : subscript out of bounds
> example_list[[4]]
[1] 20.2 350010.2

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

2010-02-19 Thread Paul Hiemstra

chipmaney wrote:

Thanks, as a follow-up, how do i extract the list element name (ie, 4-2 or 44-1)
  

Look at names(your_list)

cheers,
Paul

thanks,

chipper

Date: Thu, 18 Feb 2010 11:56:45 -0800
From: ml-node+1560750-540257540-69...@n4.nabble.com
To: chipma...@hotmail.com
Subject: Re: Extracting values from a list



Try this:


sapply(x, '[', 'p.value')


On Thu, Feb 18, 2010 at 5:21 PM, chipmaney <[hidden email]> wrote:

  

  

I have run a kruskal.test() using the by() function, which returns a list of



  

results like the following (subset of results):



  

  

Herb.df$ID: 4-2



  

  Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841



  





  

Herb.df$ID: 44-1



  

   Kruskal-Wallis chi-squared = 4.43, df = 6, p-value = 0.6187



  

  

  

So then, how do extract a vector of p-values (i.e., result$p.value) for



  

every element in the list?



  

  

  

  

--



  

View this message in context: 
http://n4.nabble.com/Extracting-values-from-a-list-tp1560701p1560701.html
Sent from the R help mailing list archive at Nabble.com.



  

  

__



  

[hidden email] mailing list



  

https://stat.ethz.ch/mailman/listinfo/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.
  



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

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


Re: [R] Use of R in clinical trials

2010-02-19 Thread John Sorkin
Bert,
There is a lesson here. Just as intolerance of any statistical analysis program 
(or system) other than SAS should lead to our being drive crazy, so to should 
intolerance of
any statistical analysis program (or system) other than R. 
John  

>>> Dieter Menne  2/19/2010 3:46 AM >>>

Bert,

I like your comments. There is one issue, however, that drives me crazy
whenever I meet a customer asking "You are not using SAS? Too bad, we need
validated results."


Bert Gunter wrote:
> 
> ...
> Also to reiterate, it's not only
> statistical/reporting functionality but even more the integration into the
> existing clinical database systems that would have to be rewritten **and
> validated**. 
> 
> 

Implicitly: Even if you let your cat enter SAS code, the results are
correct, because they SAS is validated.

Dieter



-- 
View this message in context: 
http://n4.nabble.com/Use-of-R-in-clinical-trials-tp1559402p1561317.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.

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rgui.exe cannot be set as default program under Vista wtih R2.10.1

2010-02-19 Thread Schmitt, H. (Heike)
Dear moderators, 
when I installed the latest version of R (R2.10.1) under Microsoft Vista 
(service pack 2), I ran into problems associating Rgui.exe with .RData files. 
On doubleckicking such files in explorer, they open in a Rterm window. Trying 
to associate Rgui.exe with the Rdata files via control panel / default programs 
does not work - Rgui is not added to the list of recommended programs. I tried 
installing R both with file associations and without.
 
Opening Rgui.exe (eg. via shortcut) and then opening the RData files works, 
however.
 
Under my last R version (R 2.8.1), I had no problems.
I can't find hints in the help files so far.
 
Best regards and thanks for your help,
Heike Schmitt
 
 
- 
Heike Schmitt 
IRAS, Institute for Risk Assessment Sciences 
Utrecht University 

IRAS - VPH 
PO Box 80175 
3508 TD Utrecht 
The Netherlands 

Tel 0031 30 253 5372 
Fax 0031 30 253 2365 
email h.schm...@uu.nl   

[[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] dot-dot-dot as an actual argument

2010-02-19 Thread lith
> I could not find any documentation of how dot-dot-dot works when used
> as an argument in a function call (rather than as a formal argument in
> a definition).

You might also be interested in other thread regarding this problem:
http://groups.google.com/group/r-help-archive/msg/5c6ea5eb593337b4

Regards
Tom

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


Re: [R] problem with multiple plots (mfrow, mar)

2010-02-19 Thread Peter Neuhaus

Jim Lemon wrote:


Hi Peter,
The two par arguments "fin" and "pin" allow a solution. What you want is 
for the second values in "pin" (Plot dimensions in INches) to be the 
same for all your plots. You can get an approximation by using the 
layout function instead of mfrow and setting the height vector to 
correct for the space used in the top and bottom plots. If you are not 
doing lots of these plots or you are doing only a few variations, you 
can just print out par("pin") after each plot and see how much they 
differ and adjust the height vector until all "pin"s are the same. Try 
setting the height vector in layout to the "fin"s (Figure dimensions in 
INches) that are printed out using the default of all heights equal.


Thanks, Jim. I'll try and see which solution works best for me. I often
use layout() for more complicated and print-quality plots, where "fin"
and "pin" will come in handy.

It's just amazing how much I still don't know after one year of daily
R-programming...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] BMDP and SAS (was R in clinical trials)

2010-02-19 Thread Terry Therneau
  I used both BMDP and SAS in my earlier years, side by side.  At that
time the BMDP statistical methods were much more mature and
comprehensive: we treated them as the standard when the two packages
disagreed.  (It was a BMDP manual that clearly explained to me what the
hypothesis of "Yate's weighted mean test" is, something SAS decided to
call "type III" and eternally obfuscate by defining it in terms of a
computational algorithm).  
  The BMDP programs had reasonable facilities for data manipulation ---
not as strong as SAS but reasonable.  However each analysis program was
a separate run, so you had to cut and paste your block of setup code
onto the front of each program's instructions.  "Cut and paste" with a
keypunch machine is not quite as simple as with a mouse, if you needed a
listing, some frequencies, 2-3 regressions, ... it got rather tedious.

  Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rgui.exe cannot be set as default program under Vista wtih R2.10.1

2010-02-19 Thread Dieter Menne


-- 
View this message in context: 
http://n4.nabble.com/Rgui-exe-cannot-be-set-as-default-program-under-Vista-wtih-R2-10-1-tp1561598p1561649.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] Rgui.exe cannot be set as default program under Vista wtih R2.10.1

2010-02-19 Thread Dieter Menne


Schmitt, H.  (Heike) wrote:
> 
> ..
> Trying to associate Rgui.exe with the Rdata files via control panel /
> default programs does not work - Rgui is not added to the list of
> recommended programs. 
> ..
> 

When your right-click/Open With on an rdata-file in Explorer, there is a
"Search" (Duchsuchen in German) button in the lower right. Select RGui
there.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/Rgui-exe-cannot-be-set-as-default-program-under-Vista-wtih-R2-10-1-tp1561598p1561653.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] eha aftreg performance

2010-02-19 Thread Philipp Rappold

Göran, thanks for the update, I'm just about to install it!

Just wanted to drop you a short line about performance (as you once
requested):

aftreg takes ages on my windows machine to calculate a small set of
7 observations which are not even grouped together by "id". To be a
bit more precise, it takes 2:40 mins on my Intel T9300 Core2 Duo @
2.5 GHz. Bigger samples with about 700 observations and 6 dependent
variables are in the 10 minutes range.

I just fired up my linux console (ubuntu) and calculation takes not
even 2 seconds here.

I've attached a screenshot of my system performance during
calculation, maybe that could already be a first hint (interestingly
I'm seeing some kind of sawtooth profile on physical memory history).

Generally it's not a problem for me as I can use the linux version,
but maybe you have an idea what makes it so slow. If I can provide
you with more details or help on fixing it, let me know.

Here's the dump for reconstruction:


library(eha)



testdata

  start stop censor groupvar   var1  var2
1 01  01 0.91663902 0.0847912
2 12  01 0.60470753 0.6487798
3 23  01 0.09599891 0.2195178
4 34  11 0.86384189 0.6667897
5 01  02 0.07747445 0.8782836
6 12  02 0.44608030 0.2218685
7 23  12 0.77317152 0.3813840


fit1 <- aftreg(Surv(start, stop, censor)~var1, data=testdata)



sessionInfo()

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

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

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

other attached packages:
[1] eha_1.2-13  survival_2.35-8 rcom_2.2-1  rscproxy_1.3-1

loaded via a namespace (and not attached):
[1] tools_2.9.2


All the best
Philipp

<>__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Update RMySQL and ... it's no more running

2010-02-19 Thread PtitBleu

Hello again,

After 'googling', I set the environment variable MYSQL_HOME value to the
path to MYSQL with the command below.
I get a warning (is it a problem or not ???) but I managed to connect to my
databases.

But when I close and open again R, the connection is lost. I have to run the
command each time.
Is there a way to definitively set the variable value ?

Thank in advance,
Have a nice week-end,
Ptit Bleu.


> Sys.setenv("MYSQL_HOME"="C:/MySQL/MySQL Server 5.1")
> Sys.getenv('MYSQL_HOME')
 MYSQL_HOME 
"C:/MySQL/MySQL Server 5.1" 

> library(DBI)
Warning message:
le package 'DBI' a été compilé avec la version R 2.9.2 

> library(RMySQL)
Warning messages:
1: le package 'RMySQL' a été compilé avec la version R 2.9.2 
2: In inDL(x, as.logical(local), as.logical(now), ...) : 

   RMySQL was compiled with MySQL 5.0.67 but loading MySQL 5.1.44 instead!
   This may cause problems with your database connections.

   Please install MySQL 5.0.67.

   If you have already done so, you may need to set your environment
   variable MYSQL_HOME to the proper install directory.

-- 
View this message in context: 
http://n4.nabble.com/Update-RMySQL-and-it-s-no-more-running-tp1561401p1561677.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] Bind field of a list

2010-02-19 Thread statquant

Hello all
I am new in R and so easy stuff are difficult...
let say that I have a list 
test <- list(a=c("x","v"),b=c("n","m"))
how can I without a loop get test$a bind with test$b (obviously in real life
their would be many fields)

Cheers and thanks
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561676.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] lty dots pdf issue

2010-02-19 Thread Roger Koenker
I'm trying to redo an old plot with:

>  sessionInfo()
R version 2.11.0 Under development (unstable) (2010-02-09 r51113) 
x86_64-apple-darwin9.8.0 

When I do:


pdf("lty.pdf",height = 6, width = 8)
u <- 1:100/100
y <- matrix(rep(1:10,each = 100),100)
matplot(u,y,lwd = 2,type ="l")
dev.off()

the line types that have dots are difficult to distinguish because the "dots"
that should appear are rendered as very thin vertical lines and it appears
that the dashes are rendered without the lend "round" feature even though
par() reports that that is the setting.  I'm viewing all this with Acrobat 9 
pro,
but my printer produces something quite consistent with what is viewable
on the screen.  

Apologies in advance if this has an obvious resolution, I didn't see anything
in the r-help archive.

Roger


url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

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

2010-02-19 Thread Philipp Rappold

is this what you're looking for?

test <- data.frame(a=c("x","v"),b=c("n","m"))
test

statquant wrote:

Hello all
I am new in R and so easy stuff are difficult...
let say that I have a list 
test <- list(a=c("x","v"),b=c("n","m"))

how can I without a loop get test$a bind with test$b (obviously in real life
their would be many fields)

Cheers and thanks


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


Re: [R] Confused about appending to list behavior...

2010-02-19 Thread Dieter Menne


JustADude wrote:
> 
> 
> ...
> 
> By any chance is there more documentation out there on lists and this
> behavior, as I would like to try to better understand what is really going
> on and why one approach works and another doesn't.   
> 
> ...
>  Example reproduced below
> 

You forgot an assign. 

Dieter

example_list<-list(tracking<-c("house"), 
house_type<-c("brick", "wood"), sizes<-c(1600, 1800, 2000, 2400))
example_list
cost_limits<-c(20.25, 350010.15)
example_list[[4]]<-cost_limits
example_list
# you forgot the left side here
# c(example_list,list(CostStuff=cost_limits))
# Should be
example_list <- c(example_list,list(CostStuff=cost_limits))
example_list$CostStuff
example_list[[5]]




-- 
View this message in context: 
http://n4.nabble.com/Confused-about-appending-to-list-behavior-tp1561547p1561723.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] Update RMySQL and ... it's no more running

2010-02-19 Thread PtitBleu

Just to say that I found the place to set the environment variables
(Computer/Properties/Advanced/Environment variables). The warning is still
there but the connection seems ok.

Concerning the warning, do you think I have to install an older version of
mysql ?

By the way, I also copied RMySQL.dll and libMySQL.dll in the windows/system
directory (seen somewhere on the web, don't know if it helps).


Have a nice week-end,
Ptit Bleu.

-- 
View this message in context: 
http://n4.nabble.com/Update-RMySQL-and-it-s-no-more-running-tp1561401p1561698.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] lty dots pdf issue

2010-02-19 Thread Ken Knoblauch
Roger Koenker  uiuc.edu> writes:
> I'm trying to redo an old plot with:
> >  sessionInfo()
> R version 2.11.0 Under development (unstable) (2010-02-09 r51113) 
> x86_64-apple-darwin9.8.0 
> When I do:
> 
> pdf("lty.pdf",height = 6, width = 8)
> u <- 1:100/100
> y <- matrix(rep(1:10,each = 100),100)
> matplot(u,y,lwd = 2,type ="l")
> dev.off()
> 
> the line types that have dots are difficult to distinguish 
because the "dots"
> that should appear are rendered as very thin vertical l
ines and it appears
> that the dashes are rendered without the lend "round"
 feature even though
> par() reports that that is the setting.  I'm viewing all 
this with Acrobat 9 pro,
> but my printer produces something quite consistent 
with what is viewable
> on the screen.  

Hi,

Could this be related to the problem that was driving me crazy last week

https://www.stat.math.ethz.ch/pipermail/r-sig-mac/2010-February/007123.html

but resolved in the latest patched version?

HTH,

Ken


> Apologies in advance if this has an obvious resolution, I didn't see anything
> in the r-help archive.
> 
> Roger
> 
> url:www.econ.uiuc.edu/~rogerRoger Koenker
> emailrkoenker  uiuc.eduDepartment of Economics
> vox: 217-333-4558University of Illinois
> fax:   217-244-6678Urbana, IL 61801
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Date label lost while inverting y axis.

2010-02-19 Thread David Winsemius


On Feb 19, 2010, at 2:20 AM, Jeremie Smaga wrote:


Good morning,

I am currently displaying a time series with the time on the Y axis,  
and the

values on the X axis.
The problem is that I wanted to reverse the Y axis (that is, to have  
the

latest date the closest to the X axis).
So I looked for a way to do this on this mailing list and I found a
response: inverting the ylim parameter of the plot.
I did it, the data are displayed correctly, but now the problem is  
that

there is no more labels on the Y axis.
How should I proceed to have it back?


Here is my code:

***
 sMin=min(series[,2:3])
 sMax=max(series[,2:3])
 plot(series[, 
2 
],dates 
,xlim 
= 
c 
(sMin 
,sMax 
),ylim 
=c(max(dates),min(dates)),col="green",main="",type="l",xlab="Value")

***



Offhand I would guess:

 ..., xlim = rev (range( series([, 2:3] ) ), ...

And I suppose you have your own reasons for not offering the data to  
test possible solutions.


--
David.



Thanks,

--
Jeremie

[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Bind field of a list

2010-02-19 Thread statquant

Hello,
Thank you but I think not what I would like to get as an answer is the list
("x","v","n","m") + what you gave me could work for 2 fields but if I have
200...


What I want is a vectorize way to do 
bindlists <- function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}

Regards
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.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] Bind field of a list

2010-02-19 Thread baptiste auguie
Hi,

Try this,

unlist(test)

or

do.call(c, test)

HTH,

baptiste

On 19 February 2010 15:19, statquant  wrote:
>
> Hello all
> I am new in R and so easy stuff are difficult...
> let say that I have a list
> test <- list(a=c("x","v"),b=c("n","m"))
> how can I without a loop get test$a bind with test$b (obviously in real life
> their would be many fields)
>
> Cheers and thanks
> --
> View this message in context: 
> http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561676.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Bind field of a list

2010-02-19 Thread David Winsemius


On Feb 19, 2010, at 9:49 AM, statquant wrote:



Hello,
Thank you but I think not what I would like to get as an answer is  
the list
("x","v","n","m") + what you gave me could work for 2 fields but if  
I have

200...


What I want is a vectorize way to do
bindlists <- function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}


Instead try:

c( sapply(test, "[") )

The inner (implicit) loop gets you a matrix and the outer c() turns it  
into the requested vector. You could have coerced the matrix to vector  
with as.vector, too.


Regards
--
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.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.


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] Set Colour of Histogram Bars (lattice)

2010-02-19 Thread Dieter Menne


DarioAustralia wrote:
> 
> 
> I have a bunch of histogram bars that I'd like the first to be a certain
> colour, second to be another colour, third to be a third colour, and
> repeat for all my 39 bars.
> 
>> levels(forPlot$type)
> [1] "Blah" "Blah 2" "Blah 3" 
> 
> trellis.par.set("plot.polygon$col", c("red", "green", "blue"))
> histogram( ~ cpgBin:type, data = forPlot, scales = list(x = list(rot =
> 90)), main = "CpG Density vs. 

Please provide a self-contained example, not some mysterious data on your
disk.

Dieter


library(lattice) 
df = data.frame(type=sample(letters[1:9],1000,TRUE))
histogram(~type,data=df,col=c("red","green","blue"))




-- 
View this message in context: 
http://n4.nabble.com/Set-Colour-of-Histogram-Bars-lattice-tp1561123p1561766.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] Bind field of a list

2010-02-19 Thread statquant

Bravo baptiste it works
what does do.call do exactly ??
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561745.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] Bind field of a list

2010-02-19 Thread Colin.Umansky
Hello, 
Thank you but I think not what I would like to get as an answer is the list 
("x","v","n","m") + what you gave me could work for 2 fields but if I have 
200...


What I want is a vectorize way to do 
bindlists <- function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}

Regards

-Original Message-
From: Philipp Rappold [mailto:philipp.rapp...@gmail.com] 
Sent: 19 February 2010 14:31
To: Umansky, Colin: EDG (LDN)
Cc: r-help@r-project.org
Subject: Re: [R] Bind field of a list

is this what you're looking for?

test <- data.frame(a=c("x","v"),b=c("n","m"))
test

statquant wrote:
> Hello all
> I am new in R and so easy stuff are difficult...
> let say that I have a list 
> test <- list(a=c("x","v"),b=c("n","m"))
> how can I without a loop get test$a bind with test$b (obviously in real life
> their would be many fields)
> 
> Cheers and thanks
___

This e-mail may contain information that is confidential, privileged or 
otherwise protected from disclosure. If you are not an intended recipient of 
this e-mail, do not duplicate or redistribute it by any means. Please delete it 
and any attachments and notify the sender that you have received it in error. 
Unless specifically indicated, this e-mail is not an offer to buy or sell or a 
solicitation to buy or sell any securities, investment products or other 
financial product or service, an official confirmation of any transaction, or 
an official statement of Barclays. Any views or opinions presented are solely 
those of the author and do not necessarily represent those of Barclays. This 
e-mail is subject to terms available at the following link: 
www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the 
foregoing.  Barclays Capital is the investment banking division of Barclays 
Bank PLC, a company registered in England (number 1026167) with its registered 
offi!
 ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent 
from other members of the Barclays Group.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 two dataframes by an integer column from either data frame

2010-02-19 Thread Paul Rigor (ucla)
Hi,

I'm an R nooob! So please pardon this easy question!

I have two data frames that share a common column, data1.name and data2.name.
 How would I be able to order the other based on an integer column from
either data frame?

For example, how do I order data2 based on data1.age?  Or data1 based on
data2.salary?

Thanks!
Paul

-- 
Paul Rigor
Pre-doctoral BIT Fellow and Graduate Student
Institute for Genomics and Bioinformatics
Donald Bren School of Information and Computer Sciences
University of California, Irvine
http://www.ics.uci.edu/~prigor

[[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] order two dataframes by an integer column from either data frame

2010-02-19 Thread Dieter Menne


Paul Rigor (ucla) wrote:
> 
> I have two data frames that share a common column, data1.name and
> data2.name.
>  How would I be able to order the other based on an integer column from
> either data frame?
> 
> For example, how do I order data2 based on data1.age?  Or data1 based on
> data2.salary?
> 
> 

I would ?merge the two on the common columns, and sort the merged. You could
get around the merge, but it's easier to understand that way.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/order-two-dataframes-by-an-integer-column-from-either-data-frame-tp1561815p1561827.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] Generate Univariate Normal Mixtures???

2010-02-19 Thread vaibhav dua


Hi,

I'm trying to generate a mixture from 2 univariate normal distributions and 
would like to put a constrained on the means (Equal) of the two distributions. 
Here is my shot at the code:

library(nor1mix)

X <- norMix(mu=c(50, 60 ), sig2=c(5,10), w=c(0.5, 0.5))

mixData <- rnorMix(1000, X)

plot(mixData, type="l")


I did get the 1000 random numbers in equal proportion but how can I confirm if 
the means was constrained or not in the data generation process?

Any help will be highly appreciated

VD



  
[[alternative HTML version deleted]]

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



  
[[alternative HTML version deleted]]

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


Re: [R] order two dataframes by an integer column from either data frame

2010-02-19 Thread Paul Rigor (gmail)
Thanks,
I ended up using that method!

On Fri, Feb 19, 2010 at 7:53 AM, Dieter Menne
wrote:

>
>
> Paul Rigor (ucla) wrote:
> >
> > I have two data frames that share a common column, data1.name and
> > data2.name.
> >  How would I be able to order the other based on an integer column from
> > either data frame?
> >
> > For example, how do I order data2 based on data1.age?  Or data1 based on
> > data2.salary?
> >
> >
>
> I would ?merge the two on the common columns, and sort the merged. You
> could
> get around the merge, but it's easier to understand that way.
>
> Dieter
>
>
> --
> View this message in context:
> http://n4.nabble.com/order-two-dataframes-by-an-integer-column-from-either-data-frame-tp1561815p1561827.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.
>



-- 
Paul Rigor
Pre-doctoral BIT Fellow and Graduate Student
Institute for Genomics and Bioinformatics
Donald Bren School of Information and Computer Sciences
University of California, Irvine
http://www.ics.uci.edu/~prigor

[[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] lty dots pdf issue

2010-02-19 Thread RKoenker

Thanks Ken,  that was it. 
I've updated to R version 2.11.0 Under development (unstable) (2010-02-18
r51149) 
x86_64-apple-darwin9.8.0 
and everything looks fine now.  Thanks too to Simon for sorting this out!

Roger
-- 
View this message in context: 
http://n4.nabble.com/lty-dots-pdf-issue-tp1561703p1561864.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] popbio and stochastic lambda calculation

2010-02-19 Thread Shawn Morrison
That is a big help Chris - thank you very much for your assistance. I 
also ran your code (below) for the example in Caswell (2001, ~p300) and 
got matching results.


I'd like to add my vote for including this method in the next version of 
popbio - I think it would be a very useful addition.


Thanks again,
Shawn


Chris Stubben wrote:

Shawn Morrison-2 wrote:
  

# The paper reports a 95% CI of 0.79 - 1.10
# "My" reproduced result for the CIs is much larger, especially on the 
upper end. Why would this be?
# The authors report using the 'delta' method (Caswell, 2001) to 
calculate the CI in which the






Shawn,

I probably can't help much with the vitalsim example, but I would check Box
8.10 in Morris and Doak (2002).

I do have a few ideas about the delta method below.

# List the vital rates

vr<-list(cub= 0.64, yly = 0.67, sub=0.765, adt=0.835, mx=0.467)

# and the matrix using an expression in R

el<- expression(
 0,  0,  0,  0,  adt*mx, 
 cub,0,  0,  0,  0, 
 0,  yly,0,  0,  0, 
 0,  0,  sub,0,  0, 
 0,  0,  0,  sub,adt)


# this should get the projection matrix

A<-matrix( sapply( el, eval, vr), nrow=5, byrow=TRUE)

lambda(A)
[1] 0.9534346

# use the vitalsens function to get the vital rate sensitivites and
  save the second column

vitalsens(el, vr)
estimate sensitivity elasticity
cub0.640   0.1236186 0.08298088
yly0.670   0.1180835 0.08298088
sub0.765   0.2068390 0.16596176
adt0.835   0.7628261 0.66807647
mx 0.467   0.1694131 0.08298088

sens<-vitalsens(el, vr)[,2]


# I'm not sure about the covariance matrix next.  In Step 7 in Slakski et al
2007 ("Calculating the variance of the finite rate of population change from
a matrix model in Mathematica") they just use the square of the standard
errors, so I'll do the same...

se<-list(cub= 0.107, yly = 0.142, sub=0.149, adult=0.106, mx=0.09)
cov<-diag(unlist(se)^2)

## and then the variance of lambda from step 8
var<-t(sens) %*% ( cov%*%sens)
[,1]
[1,] 0.008176676

# and the confidence intervals

lambda(A) - 1.96*sqrt(var)
lambda(A) + 1.96*sqrt(var)

CI of 0.78 and 1.13 is close to paper

Hope that helps,

Chris







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Update RMySQL and ... it's no more running

2010-02-19 Thread Gabor Grothendieck
If you only need it while in R you can use the RENVIRON file or the
.Rprofile or Rprofile.site file.  Use help in R to find more on this.

environment variables can also be set through the control panel.
Google to get instructions.

Another possibility is the free command line Windows utility setenv.exe .

On Fri, Feb 19, 2010 at 9:19 AM, PtitBleu  wrote:
>
> Hello again,
>
> After 'googling', I set the environment variable MYSQL_HOME value to the
> path to MYSQL with the command below.
> I get a warning (is it a problem or not ???) but I managed to connect to my
> databases.
>
> But when I close and open again R, the connection is lost. I have to run the
> command each time.
> Is there a way to definitively set the variable value ?
>
> Thank in advance,
> Have a nice week-end,
> Ptit Bleu.
>
>
>> Sys.setenv("MYSQL_HOME"="C:/MySQL/MySQL Server 5.1")
>> Sys.getenv('MYSQL_HOME')
>                 MYSQL_HOME
> "C:/MySQL/MySQL Server 5.1"
>
>> library(DBI)
> Warning message:
> le package 'DBI' a été compilé avec la version R 2.9.2
>
>> library(RMySQL)
> Warning messages:
> 1: le package 'RMySQL' a été compilé avec la version R 2.9.2
> 2: In inDL(x, as.logical(local), as.logical(now), ...) :
>
>   RMySQL was compiled with MySQL 5.0.67 but loading MySQL 5.1.44 instead!
>   This may cause problems with your database connections.
>
>   Please install MySQL 5.0.67.
>
>   If you have already done so, you may need to set your environment
>   variable MYSQL_HOME to the proper install directory.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tiff() and antialias option

2010-02-19 Thread Andrew Yee
I was wondering if someone could help with the antialias option in tiff().
 I'm running R 2.9.2 on a Linux machine.

I'm working on creating a tiff file and have tried different antialias
parameters, e.g. default, none, gray, and subpixel, but don't seem to be
seeing a difference in the output.  Or perhaps I'm missing something
obvious?

Thanks,
Andrew

[[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] svm and RMSE

2010-02-19 Thread Uwe Ligges



On 19.02.2010 01:29, Amy Hessen wrote:


Hi
Thank you very much for your reply.

I meant I got different RMSE with different runs to the same program without 
any change for the dataset or the parameters of SVM.

This is my code:

library(e1071)
readingmydata<- as.matrix(read.delim("mydataset.txt"))
train.x<- readingmydata[,-1]
train.y<- readingmydata[,1]

mymodel<- svm(train.x, train.y, cross=10)
summary(mymodel)

>

can you please tell me how I can fix that error?


No error at all, it is expected: You get different partitions of the 
data for cross validation since they are samples "at random". If you 
want to get the exactly same results, use a seed for the random number 
generator such as:


set.seed(123)
mymodel<- svm(train.x, train.y, cross=10)
summary(mymodel)

Uwe Ligges




Cheers,
Amy



Date: Tue, 16 Feb 2010 10:33:19 -0500
Subject: Re: [R] svm and RMSE
From: mailinglist.honey...@gmail.com
To: amy_4_5...@hotmail.com
CC: r-help@r-project.org

Hi,

On Fri, Feb 12, 2010 at 3:00 PM, Amy Hessen  wrote:


Hi,
Every time I run a svm regression program, I got different RMSE value.
Could you please tell me what the reason for that?


Sorry, your question is a bit vague.

Can you provide an example/code that shows this behavior? Is the
different RMSE over different folds of cross validation. Over the same
data? With the same parameters? Is the RMSE significantly different?

Providing an example that shows this behavior would help.

Thanks,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


_
Link all your email accounts and social updates with Hotmail. Find out now

[[alternative HTML version deleted]]

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


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


Re: [R] R-commands for MDS

2010-02-19 Thread Uwe Ligges



On 18.02.2010 11:24, Oduor Olande wrote:




Hello
I am using the following command but not able to text the values on the graph 
can
someone please make suggestions for improvement


Perhaps dist.r does not have row.names(dist.r) nor colnames(dist.r)?
We cannot know since we do not have dist.r.

Uwe Ligges





  #here is the command
loc_mds<- cmdscale(dist.r, k = 7, eig = TRUE)
  loc_mds$eig

sum(abs(loc_mds$eig[1:2]))/sum(abs(loc_mds$eig))
sum((loc_mds$eig[1:2])^2)/sum((loc_mds$eig)^2)
x<-loc_mds$points[,1]
y<-loc_mds$points[,2]
plot(x, y, xlab="Coordinate 1",
ylab="Coordinate 2",
main="Metric MDS", type="n")

text(x, y, labels = row.names(dist.r), cex=.7)#the same as the last code
text(x, y, labels = colnames(dist.r))# I am not getting the drawing why?

With Kind regards   
_


[[alternative HTML version deleted]]

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


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


Re: [R] tiff() and antialias option

2010-02-19 Thread Uwe Ligges



On 19.02.2010 17:44, Andrew Yee wrote:

I was wondering if someone could help with the antialias option in tiff().
  I'm running R 2.9.2 on a Linux machine.

I'm working on creating a tiff file and have tried different antialias
parameters, e.g. default, none, gray, and subpixel, but don't seem to be
seeing a difference in the output.  Or perhaps I'm missing something
obvious?


Perhaps you are not using type="cairo" ?

Uwe Ligges



Thanks,
Andrew

[[alternative HTML version deleted]]

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


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


Re: [R] crhon compile directive faul in version x64, in Intel i7?

2010-02-19 Thread Uwe Ligges



On 17.02.2010 22:13, Juan Santiago Ramseyer wrote:

==>  CRASH INSTALLING PACKAGES CHRON IN:

Intel(R) Core(TM) i7 CPU 860 @ 2800GHz

==>  IT'S COMPILED DIRECTIVE WRONG? REGARD YOUR ATENTION

==>  I RUN:

SO:Linux 2.6.31.12-174.2.19.fc12.x86_64 x86_64 Fedora release 12
(Constantine)

==>  AND RECEIVE NEXT MESSAGENS IN INSTALLING:


install.packages()

Loading Tcl/Tk interface ... done
--- Please select a CRAN mirror for use in this session ---
Warning in install.packages() :
argument 'lib' is missing: using '/usr/lib64/R/library'
tentando a URL
'http://www.vps.fmvz.usp.br/CRAN/src/contrib/chron_2.3-33.tar.gz'
Content type 'application/x-gzip' length 34234 bytes (33 Kb)
URL aberta
==
downloaded 33 Kb

* installing *source* package ‘chron’ ...
** libs
Warning: R include directory is empty -- perhaps need to install
R-devel.rpm or similar



Have you read the warning above? It is really meaningful 

Uwe Ligges





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 chron_strs.c -o
chron_strs.o
chron_strs.c:2:15: error: R.h: Arquivo ou diretório não encontrado
chron_strs.c:7: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c:7: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c:8: error: expected declaration specifiers or ‘...’ before
‘Sint’
chron_strs.c: In function ‘cnt_flds_str’:
chron_strs.c:10: error: ‘Sint’ undeclared (first use in this function)
chron_strs.c:10: error: (Each undeclared identifier is reported only
once
chron_strs.c:10: error: for each function it appears in.)
chron_strs.c:10: error: expected ‘;’ before ‘n’
chron_strs.c:11: error: expected ‘;’ before ‘i’
chron_strs.c:15: error: ‘whitespace’ undeclared (first use in this
function)
chron_strs.c:17: error: ‘i’ undeclared (first use in this function)
chron_strs.c:17: error: ‘n’ undeclared (first use in this function)
chron_strs.c:21: error: ‘nsep’ undeclared (first use in this function)
chron_strs.c:25: error: ‘counts’ undeclared (first use in this function)
make: ** [chron_strs.o] Erro 1
ERROR: compilation failed for package ‘chron’
* removing ‘/usr/lib64/R/library/chron’

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

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

2010-02-19 Thread Evgenia

Dear users,

I have a matrix b as 

 [,1] [,2] [,3] [,4]
[1,]0000
[2,]0011
[3,]0101
[4,]0112
[5,]1001
[6,]1012
[7,]1102
[8,]1113


with last column the rowSums(b)
I want for each value of last column of b separately (b:0,1,2,3,  to sort
the above table  by reverse lexicographical order.
For the above table the result should be

1  0  0  0
2  1  0  0
3  0  1  0
4  0  0  1
5  1  1  0
6  1  0  1
7  0  1  1
8  1  1  1

Could anyone help me with this?
Thanks alot

Evgenia

-- 
View this message in context: 
http://n4.nabble.com/inverse-lexicographical-ordering-tp1561930p1561930.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] retrieve from function

2010-02-19 Thread threshold

Hi, say I got the function:
> x=function(nbr){y<-rnorm(nbr);y1 <- mean(y);plot(y)}

how can I retrieve value of y1, when I need it. 

I don't want:
> x=function(nbr){y<-rnorm(nbr);y1 <<- mean(y);plot(y)}
> y1

I want someting like:
"x$y1" and then I get the value

Many thanks, robert





-- 
View this message in context: 
http://n4.nabble.com/retrieve-from-function-tp1561972p1561972.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] What is the difference between expression and quote when used with eval()?

2010-02-19 Thread blue sky
I made the following example to see what are the difference between
expression and quote. But I don't see any difference when they are
used with eval()? Could somebody let me know what the difference is
between expression and quote?


expr=expression(2*3)
quo=quote(2*3)

eval(expr)
str(expr)
class(expr)
typeof(expr)
mode(expr)
attributes(expr)

eval(quo)
str(quo)
class(quo)
typeof(quo)
mode(quo)
attributes(quo)

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

2010-02-19 Thread Daniel Malter
Hi, see the code below. Next time, please provide self-contained code to
generate the matrix (read the posting guide) so that we can just copy-paste
it into R to get the matrix.


x=rep(c(0,1),4)
y=rep(c(0,0,1,1),2)
z=rep(c(0,1),each=4)

m=cbind(z,y,x)

w=rowSums(m)

m=cbind(m,w)
m

m[order(w,x,y,z),]



HTH,
Daniel

-
cuncta stricte discussurus
-
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Evgenia
Sent: Friday, February 19, 2010 12:10 PM
To: r-help@r-project.org
Subject: [R] inverse lexicographical ordering


Dear users,

I have a matrix b as 

 [,1] [,2] [,3] [,4]
[1,]0000
[2,]0011
[3,]0101
[4,]0112
[5,]1001
[6,]1012
[7,]1102
[8,]1113


with last column the rowSums(b)
I want for each value of last column of b separately (b:0,1,2,3,  to sort
the above table  by reverse lexicographical order.
For the above table the result should be

1  0  0  0
2  1  0  0
3  0  1  0
4  0  0  1
5  1  1  0
6  1  0  1
7  0  1  1
8  1  1  1

Could anyone help me with this?
Thanks alot

Evgenia

-- 
View this message in context:
http://n4.nabble.com/inverse-lexicographical-ordering-tp1561930p1561930.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] retrieve from function

2010-02-19 Thread Ista Zahn

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

2010-02-19 Thread Ista Zahn
Hi Robert,

You need to modify your function to return a value. Something like

 x <- function(nbr){
   y<-rnorm(nbr)
   y1 <- mean(y)
   plot(y)
   return(y1)
 }


-Ista

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

2010-02-19 Thread Marc Schwartz
On Feb 19, 2010, at 6:56 AM, John Sorkin wrote:

> Bert,
> There is a lesson here. Just as intolerance of any statistical analysis 
> program (or system) other than SAS should lead to our being drive crazy, so 
> to should intolerance of
> any statistical analysis program (or system) other than R. 
> John  
> 
 Dieter Menne  2/19/2010 3:46 AM >>>
> 
> Bert,
> 
> I like your comments. There is one issue, however, that drives me crazy
> whenever I meet a customer asking "You are not using SAS? Too bad, we need
> validated results."
> 
> 
> Bert Gunter wrote:
>> 
>> ...
>> Also to reiterate, it's not only
>> statistical/reporting functionality but even more the integration into the
>> existing clinical database systems that would have to be rewritten **and
>> validated**. 
>> 
>> 
> 
> Implicitly: Even if you let your cat enter SAS code, the results are
> correct, because they SAS is validated.
> 
> Dieter


If I may, let me offer some comments, which in part, are supportive of Bert's 
perspective.

First, the notion of validation that Bert raised should not be interpreted as 
indicating that SAS in a vacuum "out of the box" is validated, as if there was 
a parallel to a Good Housekeeping Seal of Approval for statistical software. 
There is no such thing for any software in this domain. 

Validation, in the context of regulated clinical trials (which we address in 
the R-FDA document available at http://www.r-project.org/doc/R-FDA.pdf) is 
defined by the FDA as: "Establishing documented evidence which provides a high 
degree of assurance that a specific process will consistently produce a product 
meeting its predetermined specifications and quality attributes." That is not 
something that can be provided by the vendor, it can only be done by the end 
user and their organization.

Now, that language is of course subject to interpretation, as FDA guidance is 
just that, "guidance". It is not prescriptive. One takes a risk mitigation 
based approach to implementing internal procedures and policies.

Internal validation is done via written Standard Operating Procedures (SOPs) 
that have been created, reviewed and approved by the end user's organization. 
The entire data path from the source data base to final report output and data 
sets must be tested to assure reliability and reproducibility. Thus, there is a 
significant amount of time and cost involved with this process and this is what 
Bert was referring to, which goes above and beyond the initial cost of the 
software and any annual licensing and support costs. It needs to be done 
irrespective of the software tool chain that one is using.

The scope (therefore the cost) of the validation testing will be heavily 
impacted upon by the nature of one's environment (eg. "big pharma" versus a 
"boutique drug house" versus a medical device company versus an independent 
contract research organization) and the level of risk mitigation (defined by 
lawyers) required by the organization.

These procedures and the associated documentation are also subject to on-site 
inspection by the FDA, which can shut you down if these are lacking.

It is not that one trusts SAS' output implicitly or by default. It is that one 
has documented through extensive testing that data manipulation and output is 
reliable, reproducible and importantly, that one has also documented known 
problems (bugs, incorrect results) and workarounds, if any. 

The same applies to R. Thus, while R may be "free" in all senses of that word, 
the actual monetary cost differential relative to software purchase and support 
is only one part of the equation and therefore the "value proposition" to the 
organization.

If one is to transition from SAS to R, then one's organization has to evaluate 
the total costs and risks associated with that transition. SOPs have to be 
written, reviewed and approved. Data management, analysis and reporting code 
has to be re-written, tested and validated. Interfaces to database servers have 
to be tested. Programmer's have to be re-trained in a new language and 
operating paradigm. Senior management has to be brought along to achieve a high 
level of comfort with anything new that may initially be seen as a risk factor 
in successfully doing business. A clear business case must be made to them that 
the advantages outweigh the potential risks.

Hence, there is a lot of resistance to the use of R in the clinical trial realm 
for these large companies because of those costs and timelines. Add to that the 
normal human behavioral factors of being resistant to change and the hurdle for 
R in these large corporate environments is not trivial.

To make the move from the pre-clinical drug discovery realm that Bert and 
others here work in using R, where some of these issues are not relevant, to 
the human clinical trial realm, we need to overcome that resistance. The 
organizations will need to also get to the point where the financial pressures 
are sufficient that paying 

[R] Accessing values of a matrix

2010-02-19 Thread statquant

hello all,
thank you for taking the time

I have a matrix A that have column names (let say n columns), I want to
reduce the matrix to have just a few of those column (p colums, this is
trivial), but for the lines I want only the lines such that A(i,J) is part
of a list (J is fixed and known)

I am sure it is very easy but I don't find it (I tryed which but it doesn't
seem to work)
Surely I could do a loop but I want to learn how to do things without time
consuming loops.

Thanks
Colin
-- 
View this message in context: 
http://n4.nabble.com/Accessing-values-of-a-matrix-tp1561932p1561932.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] Use of R in clinical trials

2010-02-19 Thread Bert Gunter
Gentlemen:

Thankyou for your comments. I know I promised not to respond, but I just
wanted to clarify something that Dieter mentioned below, not defend my
remarks.

I understand "validate code" per 21 CFR part 11 complance to mean that for
**ANY** code that is written, be it in SAS, R, VB, or whatever, that one
must undertake a rigorous process to demonstrate that the code has been
appropriately tested and documented, and that QC, history, traceability, and
change control processes are in place, and so forth (as per the reg). My
further understanding is that statistical "correctness" of the code is
actually not (much of, anyway) an issue. What is important is that the
documentation enables the code to be reproduced and used by other parties
(e.g. reviewers) so that they can test "correctness" with whatever means
they deem appropriate. So, again, as I understand it, there is no such thing
as SAS, R, STATA, EXCEL or whatever code being a priori "validated" or not.
The process must be undertaken for any corpus of code written in any
language that is part of any FDA submission. 

So my point in my original remarks was only that to replace a body of
already validated code in **any** language with a different body of code --
even in the SAME languaage-- is a time-consuming and costly effort. 

I hope this clarifies my remarks. Again, I appreciate the comments and would
again appreciate even more others more knowledgeable in these issues
correcting my misunderstandings or errors and adding further insight.

Cheers to all,

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of John Sorkin
Sent: Friday, February 19, 2010 4:56 AM
To: Dieter Menne; r-help@r-project.org
Subject: Re: [R] Use of R in clinical trials

Bert,
There is a lesson here. Just as intolerance of any statistical analysis
program (or system) other than SAS should lead to our being drive crazy, so
to should intolerance of
any statistical analysis program (or system) other than R. 
John  

>>> Dieter Menne  2/19/2010 3:46 AM >>>

Bert,

I like your comments. There is one issue, however, that drives me crazy
whenever I meet a customer asking "You are not using SAS? Too bad, we need
validated results."


Bert Gunter wrote:
> 
> ...
> Also to reiterate, it's not only
> statistical/reporting functionality but even more the integration into the
> existing clinical database systems that would have to be rewritten **and
> validated**. 
> 
> 

Implicitly: Even if you let your cat enter SAS code, the results are
correct, because they SAS is validated.

Dieter



-- 
View this message in context:
http://n4.nabble.com/Use-of-R-in-clinical-trials-tp1559402p1561317.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.

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:8}}

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


Re: [R] retrieve from function

2010-02-19 Thread threshold

Thank you for response. The problem is that using return(y1) in my function
formula always returns y1, but what I want is to return it only when I wish,
like p.value in
t.test(rnorm(100),rnorm(100))$p.value

robert
-- 
View this message in context: 
http://n4.nabble.com/retrieve-from-function-tp1561972p1562012.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] Accessing values of a matrix

2010-02-19 Thread Sarah Goslee
Hi Colin,

You'll get a better answer if you provide an actual example, including what
you tried that didn't work. It looks to me like you want to subset a
data frame based
on column names, though I'm not sure what A(i, J) is supposed to be.

if so, then this is one approach:

> A <- data.frame(A = 1:3, B = 4:6, C=7:9)
> A
  A B C
1 1 4 7
2 2 5 8
3 3 6 9
> J <- c("A", "C")
> newA <- A[, colnames(A) %in% J]
> newA
  A C
1 1 7
2 2 8
3 3 9

Sarah

On Fri, Feb 19, 2010 at 12:11 PM, statquant  wrote:
>
> hello all,
> thank you for taking the time
>
> I have a matrix A that have column names (let say n columns), I want to
> reduce the matrix to have just a few of those column (p colums, this is
> trivial), but for the lines I want only the lines such that A(i,J) is part
> of a list (J is fixed and known)
>
> I am sure it is very easy but I don't find it (I tryed which but it doesn't
> seem to work)
> Surely I could do a loop but I want to learn how to do things without time
> consuming loops.
>
> Thanks
> Colin
> --
-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] retrieve from function

2010-02-19 Thread Henrique Dallazuanna
Try this:

nbr <- 30
lapply(body(x), eval)[[grep("y1", body(x))]]

On Fri, Feb 19, 2010 at 3:39 PM, threshold  wrote:
>
> Hi, say I got the function:
>> x=function(nbr){y<-rnorm(nbr);y1 <- mean(y);plot(y)}
>
> how can I retrieve value of y1, when I need it.
>
> I don't want:
>> x=function(nbr){y<-rnorm(nbr);y1 <<- mean(y);plot(y)}
>> y1
>
> I want someting like:
> "x$y1" and then I get the value
>
> Many thanks, robert
>
>
>
>
>
> --
> View this message in context: 
> http://n4.nabble.com/retrieve-from-function-tp1561972p1561972.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

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

2010-02-19 Thread John Sorkin
Marc,
A thoughtful, well reasoned discussion. I welcome this kind of analysis. (I was 
not criticizing Bert, I was using his post as an example of an unreasonable 
statement made to, but not by him, that can serve as an object lesson for all 
of us.)
I feel unhappy about posts which attack SAS, R or any other language just 
because the language is not R or SAS. Thoughtful comments like yours will get 
people to think about their choice of programming language. Many will chose R 
and that is good.
John
John Sorkin
jsor...@grecc.umaryland.edu 
-Original Message-
From: Marc Schwartz 
To: John Sorkin 
To: Gunter Bert 
Cc: Dieter Menne 
Cc:  

Sent: 2/19/2010 12:55:36 PM
Subject: Re: [R] Use of R in clinical trials

On Feb 19, 2010, at 6:56 AM, John Sorkin wrote:

> Bert,
> There is a lesson here. Just as intolerance of any statistical analysis 
> program (or system) other than SAS should lead to our being drive crazy, so 
> to should intolerance of
> any statistical analysis program (or system) other than R. 
> John  
> 
 Dieter Menne  2/19/2010 3:46 AM >>>
> 
> Bert,
> 
> I like your comments. There is one issue, however, that drives me crazy
> whenever I meet a customer asking "You are not using SAS? Too bad, we need
> validated results."
> 
> 
> Bert Gunter wrote:
>> 
>> ...
>> Also to reiterate, it's not only
>> statistical/reporting functionality but even more the integration into the
>> existing clinical database systems that would have to be rewritten **and
>> validated**. 
>> 
>> 
> 
> Implicitly: Even if you let your cat enter SAS code, the results are
> correct, because they SAS is validated.
> 
> Dieter


If I may, let me offer some comments, which in part, are supportive of Bert's 
perspective.

First, the notion of validation that Bert raised should not be interpreted as 
indicating that SAS in a vacuum "out of the box" is validated, as if there was 
a parallel to a Good Housekeeping Seal of Approval for statistical software. 
There is no such thing for any software in this domain. 

Validation, in the context of regulated clinical trials (which we address in 
the R-FDA document available at http://www.r-project.org/doc/R-FDA.pdf) is 
defined by the FDA as: "Establishing documented evidence which provides a high 
degree of assurance that a specific process will consistently produce a product 
meeting its predetermined specifications and quality attributes." That is not 
something that can be provided by the vendor, it can only be done by the end 
user and their organization.

Now, that language is of course subject to interpretation, as FDA guidance is 
just that, "guidance". It is not prescriptive. One takes a risk mitigation 
based approach to implementing internal procedures and policies.

Internal validation is done via written Standard Operating Procedures (SOPs) 
that have been created, reviewed and approved by the end user's organization. 
The entire data path from the source data base to final report output and data 
sets must be tested to assure reliability and reproducibility. Thus, there is a 
significant amount of time and cost involved with this process and this is what 
Bert was referring to, which goes above and beyond the initial cost of the 
software and any annual licensing and support costs. It needs to be done 
irrespective of the software tool chain that one is using.

The scope (therefore the cost) of the validation testing will be heavily 
impacted upon by the nature of one's environment (eg. "big pharma" versus a 
"boutique drug house" versus a medical device company versus an independent 
contract research organization) and the level of risk mitigation (defined by 
lawyers) required by the organization.

These procedures and the associated documentation are also subject to on-site 
inspection by the FDA, which can shut you down if these are lacking.

It is not that one trusts SAS' output implicitly or by default. It is that one 
has documented through extensive testing that data manipulation and output is 
reliable, reproducible and importantly, that one has also documented known 
problems (bugs, incorrect results) and workarounds, if any. 

The same applies to R. Thus, while R may be "free" in all senses of that word, 
the actual monetary cost differential relative to software purchase and support 
is only one part of the equation and therefore the "value proposition" to the 
organization.

If one is to transition from SAS to R, then one's organization has to evaluate 
the total costs and risks associated with that transition. SOPs have to be 
written, reviewed and approved. Data management, analysis and reporting code 
has to be re-written, tested and validated. Interfaces to database servers have 
to be tested. Programmer's have to be re-trained in a new language and 
operating paradigm. Senior management has to be brought along to achieve a high 
level of comfort with anything new that may initially be seen as a risk factor 
in successfully doing business. 

Re: [R] What is the difference between expression and quote when used with eval()?

2010-02-19 Thread Peter Dalgaard

blue sky wrote:

I made the following example to see what are the difference between
expression and quote. But I don't see any difference when they are
used with eval()? Could somebody let me know what the difference is
between expression and quote?


Expressions are vectors of unevaluated expressions, so one difference is 
that expressions can have more than one element.


Another difference is more subtle: objects of mode "expression" are 
better at retaining their identity as an unevaluated expression


> eval(substitute(2+x,list(x=expression(pi
Error in 2 + expression(pi) : non-numeric argument to binary operator
> eval(substitute(2+x,list(x=quote(pi
[1] 5.141593

The really convincing application of this escapes me for the moment, but 
the gist of it is that there are cases where a quoted expression may 
blend in a bit too seemlessly when using computing on the language.


Also, expression objects are more easy to recognize programmeatically, 
quote() may result in objects of mode "call", "name", or one of the base 
classes.


-pd




expr=expression(2*3)
quo=quote(2*3)

eval(expr)
str(expr)
class(expr)
typeof(expr)
mode(expr)
attributes(expr)

eval(quo)
str(quo)
class(quo)
typeof(quo)
mode(quo)
attributes(quo)

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



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

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


[R] how to make R plot under Linux

2010-02-19 Thread xinwei
Hi, I am using R in Linux environment. How can i make plot in Linux just
like in windows?

thanks

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


Re: [R] how to make R plot under Linux

2010-02-19 Thread Ista Zahn
On 02/19/10 xin...@stat.psu.edu wrote:
> Hi, I am using R in Linux environment. How can i make plot in Linux just
> like in windows?

There shouldn't be much difference, but we're going to need a lot more 
information. What version of linux, what version of R, what exactly is the 
problem you are having...

-Ista

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

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


Re: [R] multi-argument returns

2010-02-19 Thread Randall Wrong
Thanks to Patrick Burns, Bert Gunter, Steve Lianoglou, and Professor Brian
Ripley.


2010/2/17 Prof Brian Ripley 

> On Wed, 17 Feb 2010, Randall Wrong wrote:
>
> Dear R users,
>>
>> I have multi-argument returns in a function and I am warned by the program
>> they are deprecated.
>>
>
> Defunct as from the next R release.
>
>
> I have found this in the R-help archives :
>>
>
> in 2001!
>
>
> http://tolstoy.newcastle.edu.au/R/help/01c/0319.html
>> http://tolstoy.newcastle.edu.au/R/help/01c/0356.html
>>
>> Since I am not too good at programming, the list solution seems the better
>> one for me. It is also the one advocated by Kevin Murphy.
>>
>> So rather than writing return(x,y,z), I should write at the end of my
>> function :
>>
>
> return(list(x=x,y=y,z=z)) is the preferred replacement.
> (As the help page for return() has long said.)
>
>
> g=function() {
>>
>>   #...
>>
>>   result=list(x,y,z)
>>   return(result)
>> }
>>
>> Is that correct ?
>>
>> Then shoud l use g[1] or g[[1]] ?
>>
>
> No change is needed (I think you mean g()$x etc) as return(x,y,z) and
> return(list(x=x,y=y,z=z)) are identical in their effects.
>
>
> Thank you for you help.
>>
>> Randall
>>
>
> --
> 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
>

[[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 make R plot under Linux

2010-02-19 Thread Vojtěch Zeisek
On Linux You can use Rkward http://rkward.sourceforge.net/ - very nice and 
good graphical user interface for R.

Dne Pá 19. února 2010 19:39:53 xin...@stat.psu.edu napsal(a):
> Hi, I am using R in Linux environment. How can i make plot in Linux just
> like in windows?
> 
> thanks
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
>  http://www.R-project.org/posting-guide.html and provide commented,
>  minimal, self-contained, reproducible code.
-- 
Vojtěch Zeisek

Komunita openSUSE GNU/Linuxu /
Community of the openSUSE GNU/Linux

http://www.opensuse.org/
http://web.natur.cuni.cz/~zeisek/


signature.asc
Description: This is a digitally signed message part.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replicating output from a function

2010-02-19 Thread Greg Snow
The replicate function will run code multiple times and return the output as a 
list (or possibly something simplified).  You can then use lapply, sapply, or 
other tools to summarize those results.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of AC Del Re
> Sent: Wednesday, February 17, 2010 1:58 PM
> To: r-help@r-project.org
> Subject: [R] Replicating output from a function
> 
> Hi All,
> 
> I have a function that is used with data frames having multiple id's
> per row and it aggregates the data down to 1 id per row. It also
> randomly selects one of the within-id values of a variable (mod),
> which often differ within-id.  Assume this data frame (below) is much
> larger and I want to repeat this function, say 100 times, and then
> derive the mean values of r over those 100 replications. Is there an
> easy way to do this?  What about in more complex situations
> where the output is r, var(r),  wi, etc, and a mean of all output is
> desired,  e.g.:
> 
> id<-c(1,1,1,rep(4:12))
> n<-c(10,20,13,22,28,12,12,36,19,12, 15,8)
> r<-c(.68,.56,.23,.64,.49,-.04,.49,.33,.58,.18, .6,.21)
> mod1<-factor(c(1,2,2, rep(c(1,2,3),3)))
> mod2<-c(1,2,15,rep(3,9))
> datas<-data.frame(id,n,r,mod1,mod2)
> 
> # intermediate level fuction (courtesy of Hadley Wickham):
> 
> pick_one <- function(x) {
>  if (length(x) == 1) return(x)
>  sample(x, 1)
> }
> 
> 
> # Function that I want replicated 100 times:
> 
> cat_sum1 <- function(meta, mod) {
>  m <- meta
>  m$mod <- mod
>  meta <- ddply(m,  .(id),  summarize,  r = mean(r), n=mean(n),  mod =
> pick_one(mod))
>  meta$z  <- 0.5*log((1 + meta$r)/(1-meta$r))
>  meta$var.z <- 1/(meta$n-3)
>  meta$wi <-  1/meta$var.z
>  return(meta)
> }
> 
> # output from 1 run:
> 
>  cat_sum1(datas,datas$mod1)
>   id rn   mod   z  var.z   wi
> 1   1  0.49 14.3   2  0.53606034 0.08823529 11.3
> 2   4  0.64 22.0   1  0.75817374 0.05263158 19.0
> 3   5  0.49 28.0   2  0.53606034 0.0400 25.0
> 4   6 -0.04 12.0   3 -0.04002135 0.  9.0
> 5   7  0.49 12.0   1  0.53606034 0.  9.0
> 6   8  0.33 36.0   2  0.34282825 0.03030303 33.0
> 7   9  0.58 19.0   3  0.66246271 0.0625 16.0
> 8  10  0.18 12.0   1  0.18198269 0.  9.0
> 9  11  0.60 15.0   2  0.69314718 0.0833 12.0
> 10 12  0.21  8.0   3  0.21317135 0.2000  5.0
> 
> Is there a way that I could get this to run multiple times
> (internally) and then output in a similar format as above but with the
> mean values from the multiple runs?
> 
> Any help is much appreciated!
> 
> AC
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] "Legend" question

2010-02-19 Thread Lu Wang
Hi,

I want to get a histogram with the legend for my data. I drew a normal density 
curve and kernel density curve in the histogram, and I also label mean and 
median in the X axis. From the code, I got two legend: One shows "Normal 
Density" and "Kernel Density" and their corresponding lines, the other shows 
"Mean = value" and "Median = value" and their corresponding points. Actually I 
want to put them into one legend. I tried several ways but ended up with 
getting mixed line and point types.My code is as following:

hist(CDR3,xlab="",ylab="",main=NULL, 
xlim=c(min(CDR3),max(CDR3)),freq=FALSE,col="lightgrey")
# draw the overlaying normal curve and kernel curve, draw mean and median on 
X-axis
xfit<-seq(min(CDR3),max(CDR3),length=100)
yfit<-dnorm(xfit,mean=mean(CDR3),sd=sd(CDR3))
lines(xfit, yfit, col="red",lty=1,lwd=1)
lines(density(CDR3,from=min(CDR3),to=max(CDR3)),col="blue",lty=1,lwd=1) 
mean(CDR3)
median(CDR3)
points(x=mean(CDR3),y=0,pch=19,col="red",cex=1)
points(x=median(CDR3),y=0,pch=19,col="black",cex=1)
# here I got two legend
legend(x1,y1 c("Normal density","Kernel 
density"),col=c("red","blue"),lty=1:1,lwd=1:1,bty="n",)
legend(x2,y2 c(paste("Mean =",round(mean(CDR3),1)),paste("Median 
=",median(CDR3))),col=c("red","black"),pch=19:19,bty="n")

I tried the code below to create one legend, but I failed:
legend(x3,y3, c("Normal density","Kernel density","paste("Mean 
=",round(mean(CDR3),1)","paste("Median 
=",median(CDR3))"),c(lty=1,lty=1,pch=19,pch=19),col=c("red","blue","red","black"),bty="n")

Thank you,
Lu


  
[[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] What is the difference between expression and quote when usedwith eval()?

2010-02-19 Thread Bert Gunter
> as.list(expression( 2*3))
[[1]]
2 * 3

> as.list(quote( 2*3))
[[1]]
`*`

[[2]]
[1] 2

[[3]]
[1] 3

> identical(as.list(expression( 2*3))[[1]],quote(2*3))
[1] TRUE

expression() wraps the call into an expression object (as pointed out to me
by Gabor Grothendieck).

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of blue sky
Sent: Friday, February 19, 2010 9:43 AM
To: r-h...@stat.math.ethz.ch
Subject: [R] What is the difference between expression and quote when
usedwith eval()?

I made the following example to see what are the difference between
expression and quote. But I don't see any difference when they are
used with eval()? Could somebody let me know what the difference is
between expression and quote?


expr=expression(2*3)
quo=quote(2*3)

eval(expr)
str(expr)
class(expr)
typeof(expr)
mode(expr)
attributes(expr)

eval(quo)
str(quo)
class(quo)
typeof(quo)
mode(quo)
attributes(quo)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What is the difference between expression and quote whenusedwith eval()?

2010-02-19 Thread William Dunlap
I think of quote(something) as being equivalent
to expression(something)[[1]].

eval() goes through the outermost expression layer
  > eval(expression(expression(noSuchFunction(noSuchValue
  expression(noSuchFunction(noSuchValue))
  > eval(eval(expression(expression(noSuchFunction(noSuchValue)
  Error in eval(expr, envir, enclos) :
could not find function "noSuchFunction"
so I don't think you will ever see a difference between
eval(quote(something)) and eval(expression(something)).
Any low level function other than eval will treat them
differently.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
> Sent: Friday, February 19, 2010 11:10 AM
> To: 'blue sky'; r-h...@stat.math.ethz.ch
> Subject: Re: [R] What is the difference between expression 
> and quote whenusedwith eval()?
> 
> > as.list(expression( 2*3))
> [[1]]
> 2 * 3
> 
> > as.list(quote( 2*3))
> [[1]]
> `*`
> 
> [[2]]
> [1] 2
> 
> [[3]]
> [1] 3
> 
> > identical(as.list(expression( 2*3))[[1]],quote(2*3))
> [1] TRUE
> 
> expression() wraps the call into an expression object (as 
> pointed out to me
> by Gabor Grothendieck).
> 
> Bert Gunter
> Genentech Nonclinical Statistics
> 
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On
> Behalf Of blue sky
> Sent: Friday, February 19, 2010 9:43 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] What is the difference between expression and quote when
> usedwith eval()?
> 
> I made the following example to see what are the difference between
> expression and quote. But I don't see any difference when they are
> used with eval()? Could somebody let me know what the difference is
> between expression and quote?
> 
> 
> expr=expression(2*3)
> quo=quote(2*3)
> 
> eval(expr)
> str(expr)
> class(expr)
> typeof(expr)
> mode(expr)
> attributes(expr)
> 
> eval(quo)
> str(quo)
> class(quo)
> typeof(quo)
> mode(quo)
> attributes(quo)
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] "legend" question

2010-02-19 Thread Lu Wang
Hi,

Sorry to forget providing the data before.

I want to get a histogram with the legend for my data. I
drew a normal density curve and kernel density curve in the histogram,
and I also label mean and median in the X axis. From the code, I got
two legend: One shows "Normal Density" and "Kernel Density" and their
corresponding lines, the other shows "Mean = value" and "Median =
value" and their corresponding points. Actually I want to put them into
one legend. I tried several ways but ended up with getting mixed line
and point types.My code is as following:


CDR3
<- c(16,12, 15, 12, 14, 20, 15, 14, 12, 16, 16, 16, 14, 14, 14, 14,
14, 14, 19, 19, 19, 19, 19, 19, 16, 16, 14, 16, 14, 13, 10, 20, 18, 14,
17, 13, 14, 11, 14, 18,
 17, 20, 22, 19, 13, 21, 19, 22, 11, 14, 22, 17, 17, 21, 11, 11, 20, 18, 13, 
10, 13, 11, 12, 10,  9,  9, 12, 12, 11, 10, 14,
 12, 12, 15, 14, 12, 23, 10, 20, 13, 39, 23, 23, 13, 12, 14, 14, 14, 14, 12, 
12, 10)

par(mar=c(4,4,4,4),oma=c(0,0,0,0))
hist(CDR3,xlab="",ylab="",main=NULL, 
xlim=c(min(CDR3),max(CDR3)),freq=FALSE,col="lightgrey")
xfit<-seq(min(CDR3),max(CDR3),length=100)
yfit<-dnorm(xfit,mean=mean(CDR3),sd=sd(CDR3))
lines(xfit, yfit, col="red",lty=1,lwd=1)
lines(density(CDR3,from=min(CDR3),to=max(CDR3)),col="blue",lty=1,lwd=1) 
CDR3_mean=mean(CDR3)
CDR3_median=median(CDR3)
points(x=mean(CDR3),y=0,pch=19,col="red",cex=1)
points(x=median(CDR3),y=0,pch=19,col="black",cex=1)
legend(30,0.08, c("Normal density","Kernel 
density"),col=c("red","blue"),lty=1:1,lwd=1:1,bty="n")
legend(30,0.06, c(paste("Mean =",round(mean(CDR3),1)),paste("Median 
=",median(CDR3))),col=c("red","black"),pch=19:19,bty="n")

I tried the code below to create one legend, but I failed:
legend(x3,y3,
c("Normal density","Kernel density","paste("Mean
=",round(mean(CDR3),1)","paste("Median
=",median(CDR3))"),c(lty=1,lty=1,pch=19,pch=19),col=c("red","blue","red","black"),bty="n")

Thank you,
Lu


  
[[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] "legend" question

2010-02-19 Thread Sarah Goslee
I still can't tell exactly what you want, but maybe something like this?

> legend(30,0.08, c("Normal density","Kernel 
> density"),col=c("red","blue"),lty=1:1,lwd=1:1,bty="n")
> legend(30,0.06, c(paste("Mean =",round(mean(CDR3),1)),paste("Median 
> =",median(CDR3))),col=c("red","black"),pch=19:19,bty="n")
>
> I tried the code below to create one legend, but I failed:
> legend(x3,y3,
> c("Normal density","Kernel density","paste("Mean
> =",round(mean(CDR3),1)","paste("Median
> =",median(CDR3))"),c(lty=1,lty=1,pch=19,pch=19),col=c("red","blue","red","black"),bty="n")

legend(x3,y3, c("Normal density","Kernel density","paste("Mean
=",round(mean(CDR3),1)","paste("Median =",median(CDR3))"), lty=c(1, 1,
NA, NA), pch=c(NA, NA, 19, 19), col=c("red","blue","red","black"),
bty="n")

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

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


[R] ggplot2 X axis levels

2010-02-19 Thread Felipe Carrillo
Hi all:
I've done this before with factors but can't figure how to do it with
a continuous variable. I am trying to reorder the sequence of my weeks
along the X axis. I want to start with week 27 to 52 and then 1 to 26.
I guess I could use levels along with seq() but doesn't seem to work for me.
Thanks for your help

winter <- structure(list(week = c(27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L), BY_2008 = c(95L, 77L, 124L, 159L, 2376L,
9480L, 17314L, 99574L, 323679L, 198211L, 93630L, 129183L, 111820L,
71260L, 35241L, 14020L, 20778L, 21694L, 15016L, 13400L, 9187L,
3607L, 2804L, 2417L, 5291L, 16216L, 898L, 558L, 709L, 972L, 61L,
372L, 3086L, 10108L, 4295L, 882L, 2593L, 36L, 233L, 243L, 0L,
70L, 272L, 308L, 134L, 40L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("week",
"BY_2008"), class = "data.frame", row.names = c(NA, -52L))
 library(ggplot2)
qplot(week,BY_2008,data=winter,geom="line",colour=I('blue'),size=I(1))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What is the difference between expression and quote when used with eval()?

2010-02-19 Thread blue sky
On Fri, Feb 19, 2010 at 12:39 PM, Peter Dalgaard
 wrote:
> blue sky wrote:
>>
>> I made the following example to see what are the difference between
>> expression and quote. But I don't see any difference when they are
>> used with eval()? Could somebody let me know what the difference is
>> between expression and quote?
>
> Expressions are vectors of unevaluated expressions, so one difference is
> that expressions can have more than one element.
>
> Another difference is more subtle: objects of mode "expression" are better
> at retaining their identity as an unevaluated expression
>
>> eval(substitute(2+x,list(x=expression(pi
> Error in 2 + expression(pi) : non-numeric argument to binary operator
>> eval(substitute(2+x,list(x=quote(pi
> [1] 5.141593
>
> The really convincing application of this escapes me for the moment, but the
> gist of it is that there are cases where a quoted expression may blend in a
> bit too seemlessly when using computing on the language.
>
> Also, expression objects are more easy to recognize programmeatically,
> quote() may result in objects of mode "call", "name", or one of the base
> classes.

I want to see how expression(something) and quote(something) are
represented in R internally. But it seems that str() doesn't go to
that low level. Is there a way to show the internal representation?


>> expr=expression(2*3)
>> quo=quote(2*3)
>>
>> eval(expr)
>> str(expr)
>> class(expr)
>> typeof(expr)
>> mode(expr)
>> attributes(expr)
>>
>> eval(quo)
>> str(quo)
>> class(quo)
>> typeof(quo)
>> mode(quo)
>> attributes(quo)
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
>   O__   Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
> ~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907
>

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


[R] Running R scripts via Java R Interface (JRI)

2010-02-19 Thread Ralf B
Hi R enthusiasts,

I am using JRI which is great to run R commands from Java. (Please let
me know if this is the wrong forum for those questions). Its
straightforward to run single R commands via JRI, but what I really
would like to do is running existing R scripts from that interface.
Does any of you know ways how this can be done? The examples and the
documentation are poor and there seems to be only limited material
about the entire package.

Ralf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Checking the assumptions for a proper GLM model

2010-02-19 Thread Greg Snow
The best validation of assumptions is a good knowledge of the origin of your 
data.  And with 18 bullet points below, if you do all of these every time you 
are going to end up with a lot of false positives when all your assumptions are 
met.  Understanding your data so that you know which assumptions are most 
likely to be violated so you can focus on those is important, also 
understanding which assumptions your technique is robust against is good.

Rather than use the strict tests whose hypotheses may not match exactly what 
you want to test, using the vis.test function from the TeachingDemos package 
may be appropriate.

Specific comments inline below:

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Jay
> Sent: Thursday, February 18, 2010 6:33 AM
> To: r-help@r-project.org
> Subject: Re: [R] Checking the assumptions for a proper GLM model
> 
> So what I'm looking for is readily available tools/packages that could
> produce some of the following:
> 
> 3.6 Summary of Useful Commands (STATA: Source:
> http://www.ats.ucla.edu/stat/Stata/webbooks/logistic/chapter3/statalog3
> .htm)
> 
> * linktest--performs a link test for model specification, in our
> case to check if logit is the right link function to use. This command
> is issued after the logit or logistic command.

The scglm function in the forward package looks like it may do this.


> * lfit--performs goodness-of-fit test, calculates either Pearson
> chi-square goodness-of-fit statistic or Hosmer-Lemeshow chi-square
> goodness-of-fit depending on if the group option is used.

The chisq.test function in stats does goodness of fit tests, there are several 
other functions that show up when doing a search for "goodness" that may help 
(did not see any specific for glm models).  

The book Regression Modeling Strategies (which the rms package supports) talks 
a bit about the Hosmer-Lemeshow test and supports my claim that you really need 
to understand the data before using this test.  It also presents an alternative.

> * fitstat -- is a post-estimation command that computes a variety
> of measures of fit.

It is hard to find equivalents without knowing what the measures are. Many can 
probably be computed from the glm summary information, others may be included 
in the output from lrm (rms package).

> * lsens -- graphs sensitivity and specificity versus probability
> cutoff.

There are a couple of packages that do ROC curves, but I find that they are 
easy to do by hand.

> * lstat -- displays summary statistics, including the
> classification table, sensitivity, and specificity.

These can be computed fairly easy by hand, they are probably also available in 
packages like epicalc or ROC.  There value as diagnostics is another matter.

> * lroc -- graphs and calculates the area under the ROC curve based
> on the model.

I believe that lrm (rms package) computes area under the curve.  It is also an 
easy one to calculate by hand

> * listcoef--lists the estimated coefficients for a variety of
> regression models, including logistic regression.

The coef and summary functions provide the coefficients for glm and other models


> * predict dbeta --  Pregibon delta beta influence statistic

Don't know about this one but see below if this is based on leave one out stats

> * predict deviance -- deviance residual

The resid (residuals) function has an option to return deviance residuals (it 
looks like it is the default).

> * predict dx2 -- Hosmer and Lemeshow change in chi-square
> influence statistic
> * predict dd -- Hosmer and Lemeshow change in deviance statistic
> * predict hat -- Pregibon leverage

Don't know these ones

> * predict residual -- Pearson residuals; adjusted for the
> covariate pattern
> * predict rstandard -- standardized Pearson residuals; adjusted
> for the covariate pattern

See ?residuals.glm to see if any of those options work for you.

> * ldfbeta -- influence of each individual observation on the
> coefficient estimate ( not adjusted for the covariate pattern)

For linear models there is a nice computational shortcut to do leave one out 
statistics, for glms you need to refit the model each time.  But with a fast 
computer this is still fairly quick and easy.  There may be functions existing 
to do this, but it would only take a couple of lines of code to do it manually.

> * graph with [weight=some_variable] option
> * scatlog--produces scatter plot for logistic regression.

Try ?plot.glm

> * boxtid--performs power transformation of independent variables
> and performs nonlinearity test.
> 

If potential non linearity is an issue, splines may work better for this. There 
are some good examples of testing and using the splines in RMS (the book) and 
rms (the package).

> But, since I'm new to GLM, I owuld greatly appreciate how you/others
> go about and test the validity of a GLM mod

Re: [R] Error of Stepwise Regression with number of rows in use has changed: remove missing values?

2010-02-19 Thread Greg Snow
Have you considered the implications of that solution?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Kum-Hoe Hwang
> Sent: Wednesday, February 17, 2010 1:41 AM
> To: r-help@r-project.org
> Subject: Re: [R] Error of Stepwise Regression with number of rows in
> use has changed: remove missing values?
> 
> I thank those who helped to solve a error in stepwise regression with
> missing values.
> 
> 
> Kum
> 
> *
> *
> 
> A good solution that I have tried was Andreas's advice.
> 
> =
> 
> Try
> 
> data<-na.omit(original database) before you run step() or stepAIC()
> 
> On Tue, Feb 16, 2010 at 8:09 PM, Peter Ehlers 
> wrote:
> 
> > On 2010-02-16 1:24, Kum-Hoe Hwang wrote:
> >
> >> Howdy, R Grues
> >>
> >> I have enjoyed R, but I cannot solve one problem easily. Please help
> my
> >> problem.
> >> When I tried the R script, I got the following Error. This error
> >> results from input data file exported through a Excel spreadsheet
> >> software.
> >>
> >>  Error in step(lm(pop.rate ~ as.numeric(year) + as.factor(policy) +
> >> as.numeric(nation.grant) +  :
> >>   number of rows in use has changed: remove missing values?
> >>
> >> Could you direct me to solve the Error?
> >> Thanks in advance,
> >>
> >
> > This is a common situation when you use step() on data where
> > the predictors have missing values.
> >
> > A case (row) is included in the model only if all the
> > predictors for that model are non-missing for the case.
> >
> > As you vary which predictors are to be in the model, the
> > included cases will vary, resulting in models based on
> > different data. (Think of your cases as subjects; you want
> > all your models to be based on the same set of subjects.)
> >
> > Finally: (Re-)read the help page and note the 'warning'.
> >
> >  -Peter Ehlers
> >
> >
> >
> >>
> >>  ### outputs from R console ###
> >>> pop<- step(
> >>>
> >> + lm(pop.rate ~ as.numeric(year) + as.factor(policy) +
> >> as.numeric(nation.grant)
> >> ++ as.numeric(do.grant) + as.numeric(city.grant) +
> >> as.numeric(DMZ.dist) + as.numeric(Seoul.dist), data=borderI.data,
> >> na.action = na.omit)
> >> + )
> >> Start:  AIC=494.27
> >> pop.rate ~ as.numeric(year) + as.factor(policy) +
> as.numeric(nation.grant)
> >> +
> >> as.numeric(do.grant) + as.numeric(city.grant) +
> as.numeric(DMZ.dist) +
> >> as.numeric(Seoul.dist)
> >>Df Sum of SqRSSAIC
> >> - as.numeric(do.grant)  1  0.71 6622.9 492.28
> >> - as.factor(policy) 1  1.21 6623.4 492.29
> >> - as.numeric(DMZ.dist)  1  1.91 6624.1 492.30
> >> - as.numeric(city.grant)1  5.07 6627.3 492.36
> >> - as.numeric(nation.grant)  1 11.51 6633.7 492.47
> >> - as.numeric(year)  1 29.58 6651.8 492.80
> >> 6622.2 494.27
> >> - as.numeric(Seoul.dist)1673.22 7295.4 503.79
> >> Step:  AIC=492.28
> >> pop.rate ~ as.numeric(year) + as.factor(policy) +
> as.numeric(nation.grant)
> >> +
> >> as.numeric(city.grant) + as.numeric(DMZ.dist) +
> as.numeric(Seoul.dist)
> >>Df Sum of SqRSSAIC
> >> - as.factor(policy) 1  1.99 6624.9 490.32
> >> - as.numeric(DMZ.dist)  1  2.09 6625.0 490.32
> >> - as.numeric(city.grant)1  7.18 6630.1 490.41
> >> - as.numeric(nation.grant)  1 20.08 6643.0 490.64
> >> - as.numeric(year)  1 28.89 6651.8 490.80
> >> 6622.9 492.28
> >> - as.numeric(Seoul.dist)1697.46 7320.4 502.20
> >> Step:  AIC=490.32
> >> pop.rate ~ as.numeric(year) + as.numeric(nation.grant) +
> >> as.numeric(city.grant) +
> >> as.numeric(DMZ.dist) + as.numeric(Seoul.dist)
> >>Df Sum of SqRSSAIC
> >> - as.numeric(DMZ.dist)  1  2.08 6627.0 488.35
> >> - as.numeric(city.grant)1 10.65 6635.6 488.51
> >> - as.numeric(nation.grant)  1 31.30 6656.2 488.88
> >> - as.numeric(year)  1 31.44 6656.4 488.88
> >> 6624.9 490.32
> >> - as.numeric(Seoul.dist)1732.88 7357.8 500.80
> >> Step:  AIC=488.35
> >> pop.rate ~ as.numeric(year) + as.numeric(nation.grant) +
> >> as.numeric(city.grant) +
> >> as.numeric(Seoul.dist)
> >>Df Sum of SqRSSAIC
> >> - as.numeric(city.grant)1  9.86 6636.9 486.53
> >> - as.numeric(year)  1 31.42 6658.4 486.92
> >> - as.numeric(nation.grant)  1 33.33 6660.3 486.95
> >> 6627.0 488.35
> >> - as.numeric(Seoul.dist)1754.40 7381.4 499.18
> >>
> >> Error in step(lm(pop.rate ~ as.numeric(year) + as.factor(policy) 

[R] r help date format changes with c() vs. rbind()

2010-02-19 Thread Tim Clark
Dear List,

I am having a problem with dates and I would like to understand what is going 
on.  Below is an example.  I can produce a date/time using as.POSIXct, but I am 
trying to combine two as.POSIXct objects and keep getting strange results.  I 
thought I was using the wrong origin, but according to 
structure(0,class="Date") I am not (see below).  In my example a is a simple 
date/time object, b combines it using rbind(), c converts b to a date/time 
object again using as.POSIXct and gives the incorrect time, and d combines a 
using c() and gives the correct time.  Why doesn't c give me the correct answer?

Thanks,

Tim


> a<-as.POSIXct("2000-01-01 12:00:00")
> a
[1] "2000-01-01 12:00:00 HST"

> b<-rbind(a,a)
> b
   [,1]
a 946764000
a 946764000

> c<-as.POSIXct(b,origin="1970-01-01")
> c
[1] "2000-01-01 22:00:00 HST"
[2] "2000-01-01 22:00:00 HST"

> d<-c(a,a)
> d
[1] "2000-01-01 12:00:00 HST"
[2] "2000-01-01 12:00:00 HST"


> structure(0,class="Date")
[1] "1970-01-01"


Tim Clark
Department of Zoology 
University of Hawaii

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] is GEE2 for continuous outcome implemented in R?

2010-02-19 Thread COURVOISIER Delphine
hi,

surprisingly, I haven't found an implementation of GEE2 in R, except in the 
orth package but only for binary outcome. There was a post in 2004 that asked 
the same question: is there any package in R can do the GEE2?

thanks in advance,

delphine
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What is the difference between expression and quote whenused with eval()?

2010-02-19 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of blue sky
> Sent: Friday, February 19, 2010 12:11 PM
> To: Peter Dalgaard
> Cc: r-h...@stat.math.ethz.ch
> Subject: Re: [R] What is the difference between expression 
> and quote whenused with eval()?
> 
> On Fri, Feb 19, 2010 at 12:39 PM, Peter Dalgaard
>  wrote:
> > blue sky wrote:
> >>
> >> I made the following example to see what are the difference between
> >> expression and quote. But I don't see any difference when they are
> >> used with eval()? Could somebody let me know what the difference is
> >> between expression and quote?
> >
> > Expressions are vectors of unevaluated expressions, so one 
> difference is
> > that expressions can have more than one element.
> >
> > Another difference is more subtle: objects of mode 
> "expression" are better
> > at retaining their identity as an unevaluated expression
> >
> >> eval(substitute(2+x,list(x=expression(pi
> > Error in 2 + expression(pi) : non-numeric argument to 
> binary operator
> >> eval(substitute(2+x,list(x=quote(pi
> > [1] 5.141593
> >
> > The really convincing application of this escapes me for 
> the moment, but the
> > gist of it is that there are cases where a quoted 
> expression may blend in a
> > bit too seemlessly when using computing on the language.
> >
> > Also, expression objects are more easy to recognize 
> programmeatically,
> > quote() may result in objects of mode "call", "name", or 
> one of the base
> > classes.
> 
> I want to see how expression(something) and quote(something) are
> represented in R internally. But it seems that str() doesn't go to
> that low level. Is there a way to show the internal representation?

I use the following, which shows
   `name` class(length)
for each element of a recursive object and
then shows the offspring indented more than
the parent.  It does not go into the attributes,
nor does it try to outwit classes that may
have special methods for as.list(), length(),
or names().  It is handy for checking operator
precedence.

str.language <-
function (object, ..., level=0, name=deparse(substitute(object)))
{
   abbr<-function(string, maxlen=25){
  if(length(string)>1||nchar(string)>maxlen)
 paste(substring(string[1], 1, maxlen), "...", sep="")
  else
 string
   }
   cat(rep("  ", level), sep="")
   if (is.null(name))
  name <- ""
   cat(sprintf("`%s` %s(%d): %s\n", abbr(name),
  class(object), length(object), abbr(deparse(object
   if (is.recursive(object)) {
  object <- as.list(object)
  names <- names(object)
  for(i in seq_along(object)) {
 str.language(object[[i]], ...,
level = level+1, name = names[i])
  }
   }
}

E.g.,

> str.language(function(x,y=log(10))log(x)/y)
`function(x, y = log(10)) ...` function(1): function (x, y = log(10))...
  `x` name(1):
  `y` call(2): log(10)
`` name(1): log
`` numeric(1): 10
  `` call(3): log(x)/y
`` name(1): /
`` call(2): log(x)
  `` name(1): log
  `` name(1): x
`` name(1): y
> str.language(expression(log(1), sqrt(2), trunc(pi)))
`expression(log(1), sqrt(2...` expression(3): expression(log(1), sqrt(2...
  `` call(2): log(1)
`` name(1): log
`` numeric(1): 1
  `` call(2): sqrt(2)
`` name(1): sqrt
`` numeric(1): 2
  `` call(2): trunc(pi)
`` name(1): trunc
`` name(1): pi
> str.language(quote(log(pi)))
`quote(log(pi))` call(2): log(pi)
  `` name(1): log
  `` name(1): pi

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> 
> 
> >> expr=expression(2*3)
> >> quo=quote(2*3)
> >>
> >> eval(expr)
> >> str(expr)
> >> class(expr)
> >> typeof(expr)
> >> mode(expr)
> >> attributes(expr)
> >>
> >> eval(quo)
> >> str(quo)
> >> class(quo)
> >> typeof(quo)
> >> mode(quo)
> >> attributes(quo)
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >
> > --
> >   O__   Peter Dalgaard             Øster Farimagsgade 5, Entr.B
> >  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
> >  (*) \(*) -- University of Copenhagen   Denmark      Ph:  
> (+45) 35327918
> > ~~ - (p.dalga...@biostat.ku.dk)              FAX: 
> (+45) 35327907
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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

[R] Omitting members of a sequence

2010-02-19 Thread Stuart Luppescu
Hello, this is just a point of curiosity with me. I want a sequence of
numbers from 64 to 70, omitting the 2nd and 4th numbers. I can do it
these ways:

> seq(64, 70)[-c(2, 4)]
[1] 64 66 68 69 70

> foo <- 64:70
> foo[-c(2, 4)]
[1] 64 66 68 69 70

But how come this doesn't work?
> 64:70[-c(2, 4)]
[1] 64 65 66 67 68 69 70

Just wondering.
-- 
Stuart Luppescu -=- slu .at. ccsr.uchicago.edu
University of Chicago -=- CCSR 
才文と智奈美の父 -=-Kernel 2.6.30-gentoo-r5
Cordelia: Hi! You having fun? Angel: Sure. This is,
 uh... Cordelia: Your idea of hell. Angel:
 Actually, in hell you tend to know a lot of the
 people

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

2010-02-19 Thread T.D. Rudolph

In conducting studies of animal orientation and displacement, I need to
produce circular histograms of angles (bearings in radians 0-2pi) where the
centre of the circle indicates very few observations for a given bin of
angles and outwardly concentric circles indicate greater frequencies of
observations for a given bin of angles.  I'd like not to have to write the
function myself but I haven't found exactly what I am looking for yet

Tyler
-- 
View this message in context: 
http://n4.nabble.com/plot-circular-histogram-tp1562283p1562283.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] retrieve from function

2010-02-19 Thread Dennis Murphy
Hi:

Perhaps you want this:

f <- function(nbr){
  y<-rnorm(nbr)
  y1 <- mean(y)
  plot(y)
  list(y1 = y1)
 }

f(100)  prints out the mean and executes the plot
w <- f(100)   executes the plot
> w$y1
[1] 0.06965205

returns the mean as a component of the object w.

HTH,
Dennis

On Fri, Feb 19, 2010 at 10:06 AM, threshold  wrote:

>
> Thank you for response. The problem is that using return(y1) in my function
> formula always returns y1, but what I want is to return it only when I
> wish,
> like p.value in
> t.test(rnorm(100),rnorm(100))$p.value
>
> robert
> --
> View this message in context:
> http://n4.nabble.com/retrieve-from-function-tp1561972p1562012.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Omitting members of a sequence

2010-02-19 Thread Sarah Goslee
Order of operations. Since you didn't specify the order you wanted by
using parentheses, R chose, and it wasn't what you wanted.

> 64:70[-c(2, 4)]  # what you said
[1] 64 65 66 67 68 69 70

> (64:70)[-c(2, 4)] # what you thought you said
[1] 64 66 68 69 70
> 64:(70[-c(2, 4)]) # what R thought you said
[1] 64 65 66 67 68 69 70

Sarah

On Fri, Feb 19, 2010 at 4:33 PM, Stuart Luppescu  wrote:
> Hello, this is just a point of curiosity with me. I want a sequence of
> numbers from 64 to 70, omitting the 2nd and 4th numbers. I can do it
> these ways:
>
>> seq(64, 70)[-c(2, 4)]
> [1] 64 66 68 69 70
>
>> foo <- 64:70
>> foo[-c(2, 4)]
> [1] 64 66 68 69 70
>
> But how come this doesn't work?
>> 64:70[-c(2, 4)]
> [1] 64 65 66 67 68 69 70
>
> Just wondering.

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

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


Re: [R] plot circular histogram

2010-02-19 Thread Sarah Goslee
You can probably adapt stars() to give something similar to what you want.

Otherwise, you need to give us examples of what you've tried and how it
diverges from what you need.

Sarah

On Fri, Feb 19, 2010 at 4:34 PM, T.D. Rudolph
 wrote:
>
> In conducting studies of animal orientation and displacement, I need to
> produce circular histograms of angles (bearings in radians 0-2pi) where the
> centre of the circle indicates very few observations for a given bin of
> angles and outwardly concentric circles indicate greater frequencies of
> observations for a given bin of angles.  I'd like not to have to write the
> function myself but I haven't found exactly what I am looking for yet
>
> Tyler
> --


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

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


Re: [R] plot circular histogram

2010-02-19 Thread Greg Snow
Look at the circular and CircStats packages.  Look at the kernel density plots.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of T.D. Rudolph
> Sent: Friday, February 19, 2010 2:34 PM
> To: r-help@r-project.org
> Subject: [R] plot circular histogram
> 
> 
> In conducting studies of animal orientation and displacement, I need to
> produce circular histograms of angles (bearings in radians 0-2pi) where
> the
> centre of the circle indicates very few observations for a given bin of
> angles and outwardly concentric circles indicate greater frequencies of
> observations for a given bin of angles.  I'd like not to have to write
> the
> function myself but I haven't found exactly what I am looking for
> yet
> 
> Tyler
> --
> View this message in context: http://n4.nabble.com/plot-circular-
> histogram-tp1562283p1562283.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Omitting members of a sequence

2010-02-19 Thread Gabor Grothendieck
See ?Syntax noting from the list of operators there that : is of lower
precedence than [.

On Fri, Feb 19, 2010 at 4:33 PM, Stuart Luppescu  wrote:
> Hello, this is just a point of curiosity with me. I want a sequence of
> numbers from 64 to 70, omitting the 2nd and 4th numbers. I can do it
> these ways:
>
>> seq(64, 70)[-c(2, 4)]
> [1] 64 66 68 69 70
>
>> foo <- 64:70
>> foo[-c(2, 4)]
> [1] 64 66 68 69 70
>
> But how come this doesn't work?
>> 64:70[-c(2, 4)]
> [1] 64 65 66 67 68 69 70
>
> Just wondering.
> --
> Stuart Luppescu -=- slu .at. ccsr.uchicago.edu
> University of Chicago -=- CCSR
> 才文と智奈美の父 -=-Kernel 2.6.30-gentoo-r5
> Cordelia: Hi! You having fun? Angel: Sure. This is,
>  uh... Cordelia: Your idea of hell. Angel:
>  Actually, in hell you tend to know a lot of the
>  people
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Print table in lme

2010-02-19 Thread Daniel
Hello, I'm trying to add lme results in a table with lm coef results, but as
I know, estout or xtabel cannot  support lme objects.
I'm a new in R and I'll appreciate some helpful comments.

-- 
Daniel Marcelino
Phone: (647) 8910939

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


  1   2   >