Re: [R] ANCOVA for linear regressions without intercept

2011-04-01 Thread Yusuke Fukuda
Thanks Bert.

I have read ?formula again and again, and I'm still struggling;

lm(body_length ~ head_length-1)

This removes intercept from each individual regression (for male, female, 
unknown).

When they are taken together,

lm(body_length ~ sex*head_length)

This shows differences in slopes and intercepts between the regressions (but I 
want to compare the slopes of the regressions WITHOUT intercepts).

If I put

 lm(body_length ~ sex:head_length-1)

This shows slopes for each sex without intercepts, but NOT differences in the 
slope between the regressions.

I also tried

 lm(body_length ~ sex*head_length-1)
 lm(body_length ~ sex*head_length-sex-1)

But none of them worked.

Would anyone be able to help me? All I want to do is to compare the slopes of 
three linear regressions that go through the origin (0,0) so that I can say if 
their difference is significant or not. 

Thanks for your help.


 

From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: Friday, 1 April 2011 12:56 AM
To: Yusuke Fukuda
Cc: r-help@r-project.org
Subject: Re: [R] ANCOVA for linear regressions without intercept

If you haven't already received an answer, a careful reading of 
 
?formula
 
will provide it.
 
-- Bert
On Wed, Mar 30, 2011 at 11:42 PM, Yusuke Fukuda yusuke.fuk...@nt.gov.au wrote:

Hello R experts

I have two linear regressions for sexes (Male, Female, Unknown). All have a 
good correlation between body length (response variable) and head length 
(explanatory variable). I know it is not recommended, but for a good practical 
reason (the purpose of study is to find a single conversion factor from head 
length to body length), the regressions need to go through the origin (0 
intercept).

Is it possible to do ANCOVA for these regressions without intercepts? When I do

summary(lm(body length ~ sex*head length))

this will include the intercepts as below


Coefficients:
                      Estimate Std. Error t value Pr(|t|)
(Intercept)            -6.49697    1.68497  -3.856 0.000118 ***
sexMale                -9.39340    1.97760  -4.750 2.14e-06 ***
sexUnknown             -1.33791    2.35453  -0.568 0.569927
head_length             7.12307    0.05503 129.443   2e-16 ***
sexMale:head_length     0.31631    0.06246   5.064 4.37e-07 ***
sexUnknown:head_length  0.19937    0.07022   2.839 0.004556 **
---

Is there any way I can remove the intercepts so that I can simply compare the 
slopes with no intercept taken into account?

Thanks for help in advance.

Yusuke Fukuda

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



-- 
Men by nature long to get on to the ultimate truths, and will often be 
impatient with elementary studies or fight shy of them. If it were possible to 
reach the ultimate truths without the elementary studies usually prefixed to 
them, these would not be preparatory studies but superfluous diversions.
 
-- Maimonides (1135-1204)
 
Bert Gunter
Genentech Nonclinical Biostatistics

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

2011-04-01 Thread nuncio m
HI all,
 I am trying to compute the EOF of a matrix using prcomp but unable to get
the expansion co-efficients.
is it possible using prcomp or are there any other methods
thanks
nuncio

-- 
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804

[[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] Simple lattice question

2011-04-01 Thread Rubén Roa
 -Mensaje original-
 De: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
 Enviado el: jueves, 31 de marzo de 2011 18:09
 Para: Rubén Roa
 CC: r-help@r-project.org
 Asunto: Re: [R] Simple lattice question
 
 On 2011-03-31 06:58, Rubén Roa wrote:
  Thanks Peters!
 
  Just a few minor glitches now:
 
  require(lattice)
  data- 
 data.frame(SP=sort(rep(as.factor(c('A','B','C','D','E')),12)),
  x=rpois(60,10),
  y=rep(c(rep(0,4),rep(10,4),rep(20,4)),5),
  z=rep(1:4,15))
  
 xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),pch=1:4,lty=1:4
,col='black',type='b',
  key=list(x = .65, y = .75, corner = c(0, 0), points=TRUE,
 lines=TRUE, pch=1:4, lty=1:4, type='b',
 text=list(lab = as.character(unique(data$z)
 
  I have an extra column of symbols on the legend,
 
  and,
 
  would like to add a title to the legend. Such as 'main' for plots.
 
  Any suggestions?
 
 for key(), make 'lines' into a list:
 
   xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),
  pch=1:4,lty=1:4,col='black',type='b',
  key=list(x = .65, y = .75, corner = c(0, 0),
   title=title here, cex.title=.9, lines.title=3,
   lines=list(pch=1:4, lty=1:4, type='b'),
   text=list(lab = as.character(unique(data$z)
 
 Peter Ehlers

... that works. Thanks Peter (sorry I misspelled your name b4). The clean code 
is now:

require(lattice)
data - data.frame(SP=sort(rep(as.factor(c('A','B','C','D','E')),12)),
   x=rpois(60,10),
   y=rep(c(rep(0,4),rep(10,4),rep(20,4)),5),
   z=rep(1:4,15))
xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),pch=1:4,lty=1:4,col='black',type='b',
   key=list(x = .65, y = .75, corner = c(0, 0),
  lines=list(pch=1:4, lty=1:4, type='b'),
  title=expression(CO^2),
  text=list(lab = as.character(unique(data$z)

David's code works too (thanks to you too!) and is somewhat shorter

xyplot(x~y|SP, data=data,groups=z, layout=c(2,3), 
par.settings=simpleTheme(pch=1:4,lty=1:4,col='black'), type=b, 
   auto.key = list(x = .6, y = .7, lines=TRUE, corner = c(0, 0)))

but the lines and symbols are on different columns, and the line types look as 
if they were in bold.

Rubén



 

Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN

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


Re: [R] Assign Names of columns in data.frame dinamically

2011-04-01 Thread Andreas Borg

Hi Marcos,

I'd be glad to help, but your example is not usable for anyone but 
yourself - I don't have the files that your code reads and I don't have 
any idea what the resulting data frames look like. Please provide 
examples of the data and the result.


Andreas

Marcos Amaris Gonzalez schrieb:

Hello List.

I have many files of ECG, each one with 7 column and I need only the
second column and the name of each ECG. I am doing this but althought
I have various days trying this i haven't gotten, so I ask help with
this, if somebody cans help me I'll be so thankfully.


rm(list=ls())

# loadEcgFiles - function(Dir=.) {
Dir - .;

txtfiles - list.files(paste(Dir),'.txt$');
ecg = data.frame(ncol=1);
len = length(txtfiles);

for (i in 1:5 ) {
# i - 1;
filename = paste(projectDir, / ,
txtfiles[i],sep='');
sample = read.table(filename, nrow=75000);  
   sampleName = filename; sampleName=gsub(./,
,sampleName); sampleName=gsub(.txt, , sampleName);
   temp - sample$V2;
   names(temp) - sampleName;
  ecg = cbind(ecg, temp);
#}

Thanks and sorry for my english.

---
Marcos Amaris González - Linux Counter #462840
--
No al SPAM!
No es más rico el que más tiene, sino el que menos necesita.
--

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

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] TV VECM (formerly: VECM with UNRESTRICTED TREND)

2011-04-01 Thread Pfaff, Bernhard Dr.
Dear Renoir,

are you referring to:

http://econ.la.psu.edu/~hbierens/TVCOINT.PDF 

?
If so, no, but you could up this framework fairly easily and hereby employ the 
functions of urca. But this should already be evident from the package's 
manual. 

Best,
Bernhard 

 -Ursprüngliche Nachricht-
 Von: renoir vieira [mailto:renoirvie...@gmail.com] 
 Gesendet: Donnerstag, 31. März 2011 22:27
 An: Grzegorz Konat
 Cc: Pfaff, Bernhard Dr.; r-help@r-project.org
 Betreff: Re: [R] VECM with UNRESTRICTED TREND
 
 Dear Pfaff,
 
 Would that be possible to fit a Time varying VECM using urca?
 
 Yours,
 Renoir
 
 On Thursday, March 31, 2011, Grzegorz Konat 
 grzegorz.ko...@ibrkk.pl wrote:
  The code you gave me works fine with Finland, but the same 
 for my data 
  - does not!
  I do:
 
  library(urca)
  data(my.data)
  dat1 - my.data[, c(dY, X, dM)]
  trend - matrix(1:nrow(dat1), ncol = 1)
  colnames(trend) - trd
  yxm.vecm - ca.jo(dat1, type = trace, ecdet = const, K 
 = 2, spec = 
  longrun, dumvar = trend)
 
  and the result is again:
 
  Error in r[i1, , drop = FALSE] - r[-nrow(r):-(nrow(r) - lag 
 + 1L), , 
  drop = FALSE] :
    non-numeric argument to binary operator
 
  I attach my dataset in xls format. If you have 5 minutes 
 and wish to 
  check it out, I'd be extremely grateful!
 
  Best,
  Greg
 
 
 
  2011/3/31 Pfaff, Bernhard Dr. bernhard_pf...@fra.invesco.com
 
   Well, without further information, I do not know, but try the 
  following
 
  library(urca)
  example(ca.jo)
  trend - matrix(1:nrow(sjf), ncol = 1)
  colnames(trend) - trd
  ca.jo(sjf, type = trace, ecdet = const, K = 2, spec = 
 longrun, 
  dumvar = trend)
 
  Best,
  Bernhard
 
 
 
   --
  *Von:* Grzegorz Konat [mailto:grzegorz.ko...@ibrkk.pl]
  *Gesendet:* Donnerstag, 31. März 2011 14:40
 
  *An:* Pfaff, Bernhard Dr.; r-help@r-project.org
  *Betreff:* Re: [R] VECM with UNRESTRICTED TREND
 
  'time' was a trend variable from my.data set. Equivalent to the 
  output of the command 'matrix' you just gave me.
 
  So now I did:
 
   library(urca)
  data(my.data)
  names(my.data)
  attach(my.data)
  dat1 - my.data[, c(dY, X, dM)]
  mat1 - matrix(seq(1:nrow(dat1)), ncol = 1)
  args('ca.jo')
  yxm.vecm - ca.jo(dat1, type = trace, ecdet = const, K 
 = 2, spec 
  = longrun, dumvar=mat1)
 
  and the output is:
 
   Error in r[i1, , drop = FALSE] - r[-nrow(r):-(nrow(r) - 
 lag + 1L), , 
  drop = FALSE] :
    non-numeric argument to binary operator In addition: Warning 
  message:
  In ca.jo(dat1, type = trace, ecdet = const, K = 2, spec = 
  longrun,
   :
  No column names in 'dumvar', using prefix 'exo' instead.
 
  What do I do wrong?
 
  Best,
  Greg
 
 
  2011/3/31 Pfaff, Bernhard Dr. bernhard_pf...@fra.invesco.com
 
 
 
 
   Hello Bernhard,
 
  thank You so much one again! Now I (more or less) understand the 
  idea, but still have problem with its practical application.
 
  I do (somewhat following example 8.1 in your textbook):
 
   library(urca)
  data(my.data)
  names(my.data)
  attach(my.data)
  dat1 - my.data[, c(dY, X, dM)]
  dat2 - cbind(time)
 
  What is 'time'? Just employ matrix(seq(1:nrow(dat1)), 
 ncol = 1) for 
  creating the trend variable.
 
  Best,
  Bernhard
 
 
   args('ca.jo')
  yxm.vecm - ca.jo(dat1, type = trace, ecdet = trend, 
 K = 2, spec 
  = longrun, dumvar=dat2)
 
  The above code produces following output:
 
   Error in r[i1, , drop = FALSE] - r[-nrow(r):-(nrow(r) - 
 lag + 1L), 
  , drop = FALSE] :
    non-numeric argument to binary operator
 
  What does that mean? Should I use cbind command to dat1 
 as well? And 
  doesn't it transform the series into series of integer numbers?
 
  Thank you once again (especially for your patience).
 
  Best,
  Greg
 
 
 
  2011/3/31 Pfaff, Bernhard Dr. bernhard_pf...@fra.invesco.com
 
   Hello Greg,
 
  you include your trend as a (Nx1) matrix and use this 
 for 'dumvar'. 
  The matrix 'dumvar' is just added to the VECM as deterministic 
  regressors and while you are referring to case 5, this 
 is basically 
  what you are after, if I am not mistaken. But we aware that this 
  implies a quadratic trend for the levels
 
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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


[R] Using a variable in a covariance structure and as a predictor - is this OK?

2011-04-01 Thread Chris Mcowen
Dear list,

I have the model below which i am using to account for spatial autocorrelation:

exponential -corExp(form = ~ Longitude + Latitude)

explanation_mod_all - 
gls(Lower_PD~Area+Elevation+Temperature+Preceipitation+Agriculture+Urban+Human.footprint+Population,
 correlation = exponential)

I want to see if Latitude and Longitude are significant, is it statistically 
and methodologically correct to add them to the model i.e

explanation_mod_all - 
gls(Lower_PD~Area+Elevation+Temperature+Preceipitation+Agriculture+Urban+Human.footprint+Population+Longitude+Latitude,
 correlation = exponential) ?

Thanks

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.


[R] [R-pkgs] pROC 1.4.3: compare two ROC curves in R

2011-04-01 Thread Xavier Robin
Dear R users,

pROC is a package to compare, visualize, and smooth receiver operating
characteristic (ROC) curves.

The package provides the following features:
* Partial or full area under the curve (AUC) computation
* Comparison of two ROC curves (curves and AUC)
* Calculating and plotting confidence intervals
* Smoothing of the ROC curve
* Coordinates extraction ('coords' function).

The main feature of pROC is the comparison between two ROC curves. Three
methods are currently implemented for both paired and unpaired ROC curves:
* Bootstrap for full and partial AUC and smoothed ROC curves
* DeLong [1] method for full AUC
* Venkatraman [2, 3].

Confidence intervals can be computed with bootstrap for both empirical
or smoothed ROC curves:
* partial or full AUC (also with DeLong [1] method for full AUC)
* ROC coordinates (thresholds, sensitivity or specificity).

You can find more information in our paper [4] and on pROC website:
http://www.expasy.org/tools/pROC/

Hope you'll find it useful!

Xavier Robin

-- 
References:
[1] DeLong ER, DeLong DM, Clarke-Pearson DL (1988) Comparing the areas
under two or more correlated receiver operating characteristic curves: a
nonparametric approach. Biometrics 44, 837–845.
[2] Venkatraman ES,Begg CB (1996) A distribution-free procedure for
comparing receiver operating characteristic curves from a paired
experiment. Biometrika 83, 835–848.
[3] Venkatraman ES (2000) A Permutation Test to Compare Receiver
Operating Characteristic Curves. Biometrics 56, 1134–1138.
[4] Robin X, Turck N, Hainard A, et al. (2011). pROC: an open-source
package for R and S+ to analyze and compare ROC curves. BMC
Bioinformatics, 12, 77. http://dx.doi.org/10.1186/1471-2105-12-77

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


Re: [R] How to update R?

2011-04-01 Thread Kenn Konstabel
On Thu, Mar 31, 2011 at 9:04 PM, Shi, Tao shida...@yahoo.com wrote:
 This question has been asked by many people already.  The easiest way is:

 1) install the new version
 2) copy all or the libraries that you installed later from the library 
 folder
 of older version to the new version
 3) uninstall the old version
 4) do a library update in the new version

On Windows, I've found that it is actually better to uninstall the old
version first. Uninstalling removes file associations for .Rdata and
other files even if a more recent version of R is present (although
perhaps there is a way to tell it not to) but this won't be a problem
if you do it in the following order:

 3) uninstall the old version
 1) install the new version
 2) copy all or the libraries that you installed later from the library 
 folder
 of older version to the new version
 4) do a library update in the new version

Kenn

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

2011-04-01 Thread Henri Mone
Dear R Users,

I use for my data crunching a combination of MySQL and GNU R. I have
to handle huge/ middle seized data which is stored in a MySql
database, R executes a SQL command to fetch the data and does the
plotting with the build in R plotting functions.

The (low level) calculations like summing, dividing, grouping, sorting
etc. can be done either with the sql command on the MySQL side or on
the R side.
My question is what is faster for this low level calculations / data
rearrangement MySQL or R? Is there a general rule of thumb what to
shift to the MySql side and what to the R side?

Thanks
Henri

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


Re: [R] MySql Versus R

2011-04-01 Thread Allan Kamau
On Fri, Apr 1, 2011 at 1:46 PM, Henri Mone henrim...@gmail.com wrote:
 Dear R Users,

 I use for my data crunching a combination of MySQL and GNU R. I have
 to handle huge/ middle seized data which is stored in a MySql
 database, R executes a SQL command to fetch the data and does the
 plotting with the build in R plotting functions.

 The (low level) calculations like summing, dividing, grouping, sorting
 etc. can be done either with the sql command on the MySQL side or on
 the R side.
 My question is what is faster for this low level calculations / data
 rearrangement MySQL or R? Is there a general rule of thumb what to
 shift to the MySql side and what to the R side?

 Thanks
 Henri

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


I would assume RDBMS have advanced memory management capabilities and
are designed for the manipulation and handling of large amounts of
data. These are primary features for most database management server
software. This way the database management server software should (in
most cases) be used to store, manipulate then return only the
processed and qualifying records to the client or other application
for further specialized processing and/or data visualization.

Allan.

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


[R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
Hi there,

Could someone help me with the following programming problem..?

I have written a function that works for my intended purpose, but it
is quite closely tied to a particular dataframe and the names of the
variables in this dataframe. However, I'd like to use the same
function for different dataframes and variables. My problem is that
I'm not quite sure how to tell my function in which dataframe the
entered variables are located.

Here's some reproducible data and the function:

# create reproducible data
set.seed(124)
xvar - sample(0:3, 1000, replace = T)
yvar - sample(0:1, 1000, replace=T)
zvar - rnorm(100)
lvar - sample(0:1, 1000, replace=T)
Fulldf - as.data.frame(cbind(xvar,yvar,zvar,lvar))
Fulldf$xvar - factor(xvar, labels=c(blue,green,red,yellow))
Fulldf$yvar - factor(yvar, labels=c(area1,area2))
Fulldf$lvar - factor(lvar, labels=c(yes,no))

and here's the function in the form that it currently works: from a
subset of the dataframe Fulldf, a contingency table is created (in my
actual data, several other operations are then performed on that
contingency table, but these are not relevant for the problem in
question, therefore I've deleted it) .

# function as it currently works: tailored to a particular dataframe (Fulldf)

myfunct - function(subgroup){ # enter a particular subgroup for which
the contingency table should be calculated (i.e. a particular value of
the factor lvar)
Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
#restrict dataframe to given subgroup and two columns of the original
dataframe
Data.tmp - na.omit(Data.tmp) # exclude missing values
indextable - table(Data.tmp$xvar, Data.tmp$yvar) # make contingency table
return(indextable)
}

#Since I need to use the function with different dataframes and
variable names, I'd like to be able to tell my function the name of
the dataframe and variables it should use for calculating the index.
This is how I tried to modify the first part of the #function, but it
didn't work:

# function as I would like it to work: independent of any particular
dataframe or variable names (doesn't work)

myfunct.better - function(subgroup, lvarname, yvarname, dataframe){
#enter the subgroup, the variable names to be used and the dataframe
in which they are found
Data.tmp - subset(dataframe, lvarname==subgroup, select=c(xvar,
deparse(substitute(yvarname # trying to subset the given dataframe
for the given subgroup of the given variable. The variable xvar
happens to have the same name in all dataframes) but the variable
yvarname has different names in the different dataframes
Data.tmp - na.omit(Data.tmp)
indextable - table(Data.tmp$xvar, Data.tmp$yvarname) # create the
contingency table on the basis of the entered variables
return(indextable)
}

calling

myfunct.better(yes, lvarname=lvar, yvarname=yvar, dataframe=Fulldf)

results in the following error:

Error in `[.data.frame`(x, r, vars, drop = drop) :
  undefined columns selected

My feeling is that R doesn't know where to look for the entered
variables (lvar, yvar), but I'm not sure how to solve this problem. I
tried using with() and even attach() within the function, but that
didn't work.

Any help is greatly appreciated.

Best,
Esther

P.S.:
Are there books that elaborate programming in R for beginners -- and I
mean things like how to best use vectorization instead of loops and
general best practice tips for programming. Most of the books I've
been looking at focus on applying R for particular statistical
analyses, and only comparably briefly deal with more general
programming aspects. I was wondering if there's any books or tutorials
out there that cover the latter aspects in a more elaborate and
systematic way...?

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


Re: [R] MySql Versus R

2011-04-01 Thread Prof Brian Ripley

On Fri, 1 Apr 2011, Henri Mone wrote:


Dear R Users,

I use for my data crunching a combination of MySQL and GNU R. I have
to handle huge/ middle seized data which is stored in a MySql
database, R executes a SQL command to fetch the data and does the
plotting with the build in R plotting functions.

The (low level) calculations like summing, dividing, grouping, sorting
etc. can be done either with the sql command on the MySQL side or on
the R side.
My question is what is faster for this low level calculations / data
rearrangement MySQL or R? Is there a general rule of thumb what to
shift to the MySql side and what to the R side?


The data transfer costs almost always dominate here: since such 
low-level computations would almost always be a trivial part of the 
total costs, you should do things which can reduce the size (e.g. 
summarizations) in the DBMS.


I do wonder what you think the R-sig-db list is for if not questions 
such as this one.  Please subscribe and use it next time.



Thanks
Henri


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

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


Re: [R] MySql Versus R

2011-04-01 Thread Gabor Grothendieck
On Fri, Apr 1, 2011 at 6:46 AM, Henri Mone henrim...@gmail.com wrote:
 Dear R Users,

 I use for my data crunching a combination of MySQL and GNU R. I have
 to handle huge/ middle seized data which is stored in a MySql
 database, R executes a SQL command to fetch the data and does the
 plotting with the build in R plotting functions.

 The (low level) calculations like summing, dividing, grouping, sorting
 etc. can be done either with the sql command on the MySQL side or on
 the R side.
 My question is what is faster for this low level calculations / data
 rearrangement MySQL or R? Is there a general rule of thumb what to
 shift to the MySql side and what to the R side?

The sqldf package makes it easy to use sqlite, h2 or postgresql from R
to carry out data manipulation tasks and this has facilitated some
benchmarks by users using sqlite's capability of using an in memory
database.   In the cases cited on the sqldf home page sqlite was
faster than R despite the overhead of moving the data into the
database and out again. See http://sqldf.googlecode.com

In general the answer would depend on the database, what has been
cached, the particular query, size of data and how well you had
optimized your sql and R queries.   There are entire books on
optimizing MySQL so this is an extensive subject.  Various comparisons
of different approaches can easily result in different ordering from
fastest to slowest based on what would appear to be relatively minor
aspects of the problem so you would have to benchmark the important
queries to really get an answer that pertains to your situation.
Check out the rbenchmark package for this which makes it relatively
simple to do.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] MySql Versus R

2011-04-01 Thread Barry Rowlingson
On Fri, Apr 1, 2011 at 11:46 AM, Henri Mone henrim...@gmail.com wrote:
 Dear R Users,

 I use for my data crunching a combination of MySQL and GNU R. I have
 to handle huge/ middle seized data which is stored in a MySql
 database, R executes a SQL command to fetch the data and does the
 plotting with the build in R plotting functions.

 The (low level) calculations like summing, dividing, grouping, sorting
 etc. can be done either with the sql command on the MySQL side or on
 the R side.
 My question is what is faster for this low level calculations / data
 rearrangement MySQL or R? Is there a general rule of thumb what to
 shift to the MySql side and what to the R side?

 Given that you are already set up to test this yourself, why don't
you? SELECT everything from a table and add it in R, and then SELECT
sum(everything) from a table and compare the time (obviously your
example might be more complex). Post some benchmark test results
together with your hardware spec. Probably best to the db-flavour R
mailing list.

 Is the MySQl server running locally, ie on the same machine? Maybe
PostgreSQL will be even faster? So many of these questions are
problem-specific and hardware-setup related. You can get massive
speedups by having more RAM, or more disk, or spreading your giant
database onto multiple servers.

 Rules of thumb are rare in this world, since everyone's thumbs are
different sizes and are being stuck into different sized problems.

Barry

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


Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
See the warning in ?subset.
Passing the column name of lvar is not the same as passing the 'contextual
column' (as I coin it in these circumstances).
You can solve it by indeed using [] instead.

For my own comfort, here is the relevant line from your original function:
Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
Which should become something like (untested but should be close):
Data.tmp - Fulldf[Fulldf[,lvar]==subgroup, c(xvar,yvar)]

This should be a lot easier to translate based on column names, as the
column names are now used as such.

HTH,


Nick Sabbe
--
ping: nick.sa...@ugent.be
link: http://biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36

-- Do Not Disapprove




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of E Hofstadler
Sent: vrijdag 1 april 2011 13:09
To: r-help@r-project.org
Subject: [R] programming: telling a function where to look for the entered
variables

Hi there,

Could someone help me with the following programming problem..?

I have written a function that works for my intended purpose, but it
is quite closely tied to a particular dataframe and the names of the
variables in this dataframe. However, I'd like to use the same
function for different dataframes and variables. My problem is that
I'm not quite sure how to tell my function in which dataframe the
entered variables are located.

Here's some reproducible data and the function:

# create reproducible data
set.seed(124)
xvar - sample(0:3, 1000, replace = T)
yvar - sample(0:1, 1000, replace=T)
zvar - rnorm(100)
lvar - sample(0:1, 1000, replace=T)
Fulldf - as.data.frame(cbind(xvar,yvar,zvar,lvar))
Fulldf$xvar - factor(xvar, labels=c(blue,green,red,yellow))
Fulldf$yvar - factor(yvar, labels=c(area1,area2))
Fulldf$lvar - factor(lvar, labels=c(yes,no))

and here's the function in the form that it currently works: from a
subset of the dataframe Fulldf, a contingency table is created (in my
actual data, several other operations are then performed on that
contingency table, but these are not relevant for the problem in
question, therefore I've deleted it) .

# function as it currently works: tailored to a particular dataframe
(Fulldf)

myfunct - function(subgroup){ # enter a particular subgroup for which
the contingency table should be calculated (i.e. a particular value of
the factor lvar)
Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
#restrict dataframe to given subgroup and two columns of the original
dataframe
Data.tmp - na.omit(Data.tmp) # exclude missing values
indextable - table(Data.tmp$xvar, Data.tmp$yvar) # make contingency table
return(indextable)
}

#Since I need to use the function with different dataframes and
variable names, I'd like to be able to tell my function the name of
the dataframe and variables it should use for calculating the index.
This is how I tried to modify the first part of the #function, but it
didn't work:

# function as I would like it to work: independent of any particular
dataframe or variable names (doesn't work)

myfunct.better - function(subgroup, lvarname, yvarname, dataframe){
#enter the subgroup, the variable names to be used and the dataframe
in which they are found
Data.tmp - subset(dataframe, lvarname==subgroup, select=c(xvar,
deparse(substitute(yvarname # trying to subset the given dataframe
for the given subgroup of the given variable. The variable xvar
happens to have the same name in all dataframes) but the variable
yvarname has different names in the different dataframes
Data.tmp - na.omit(Data.tmp)
indextable - table(Data.tmp$xvar, Data.tmp$yvarname) # create the
contingency table on the basis of the entered variables
return(indextable)
}

calling

myfunct.better(yes, lvarname=lvar, yvarname=yvar, dataframe=Fulldf)

results in the following error:

Error in `[.data.frame`(x, r, vars, drop = drop) :
  undefined columns selected

My feeling is that R doesn't know where to look for the entered
variables (lvar, yvar), but I'm not sure how to solve this problem. I
tried using with() and even attach() within the function, but that
didn't work.

Any help is greatly appreciated.

Best,
Esther

P.S.:
Are there books that elaborate programming in R for beginners -- and I
mean things like how to best use vectorization instead of loops and
general best practice tips for programming. Most of the books I've
been looking at focus on applying R for particular statistical
analyses, and only comparably briefly deal with more general
programming aspects. I was wondering if there's any books or tutorials
out there that cover the latter aspects in a more elaborate and
systematic way...?

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


Re: [R] Cox Proportional Hazards model with a time-varying covariate

2011-04-01 Thread Terry Therneau
 The R results I'm getting are similar to the SAS results but not very
 close. For example, my coefficient for TRT is .2913 in R but SAS
 gives .3450. I'd like to be able to run the R Code with method  =
 exact to make it as same as the AS example but I can't seem to get
 it to work

  You need to read the documentation more carefully.  The exact partial
likelihood (Cox's label, not mine), which is appropriate for data on a
discreete time scale, is invoked by the exact option for ties in R and
by using the discrete option in SAS. (In hindsight I actually like
their choice of a label somewhat better, since users more often make the
correct association of method to data.)  This method can take nearly
forever to compute, however, when there are a lot of subjects tied at a
given time. For instance at time 20 your data set has 10 events out of
77 subjects; the term in the exact partial likelihood requires a sum
over all the possible subsets of 10 chosen from 77, approximately 10^12
terms: you might retire before it finishes.
   The exact marginal likelihood proposed by Prentice is invoked in
SAS using ties=exact, it is not implimented in R.  I have never found
any compelling reason to program it.

  Statistical comment: in statistics an exact method means that the
solution can be computed exactly, the label has absolutely no connection
with the question of whether the method is a sensible thing to do.  In
the case of a Cox model, I prefer and strongly recommend using the Efron
approximation for ties,  this is the default in R.  The Breslow
approximation is usually quite good enough, this is the default in SAS.

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] lattice: wireframe eats up points; how to make points on wireframe visible?

2011-04-01 Thread Deepayan Sarkar
On Thu, Mar 31, 2011 at 3:26 AM, Marius Hofert m_hof...@web.de wrote:
 Dear Deepayan,

 thanks for answering. It's never too late to be useful.

 I see your point in the minimal example. I checked the z-axis limits in my
 original problem for the point to be inside and it wasn't there. I can't 
 easily
 reproduce it from the minimal example though. I'll get back to you if I run 
 into
 this problem again.

 In the example below, both points are shown. Although one lies clearly 
 below/under
 the surface, it looks as if it lies above. One would probably have to plot 
 this
 point first so that the wire frame is above the point. But still, this is
 misleading since the eye believes that the wireframe is *not* transparent. 
 This
 happens because the lines connecting (0,1,0)--(1,1,0)--(1,0,0) [dashed ones] 
 are
 not completely visible [also not the one from (1,1,0) to (1,1,1)]. How can I 
 make
 them visible even if they lie behind/under the wireframe? I tried to work with
 col=transparent and with alpha=... but neither did work as I expected.
 My goal is to make the small rectangles between the wire transparent.
 I also use these plots in posters with a certain gradient-like background 
 color
 and so it's a bit annoying that the rectangles are filled with white color.

Yes, that probably needs a new argument; the default computation is a
bit of a hack. You can try the following workaround for now:

wireframe(z~x*y, pts=pts, aspect=1, scales=list(col=1, arrows=FALSE),
  zlim=c(0,1),
  par.settings = list(background = list(col = #ff11)), ## - NEW
  panel.3d.wireframe = function(x,y,z,xlim,ylim,zlim,xlim.scaled,
ylim.scaled,zlim.scaled,pts,...){
  panel.3dwire(x=x, y=y, z=z, xlim=xlim, ylim=ylim, zlim=zlim,
   xlim.scaled=xlim.scaled, ylim.scaled=ylim.scaled,
   zlim.scaled=zlim.scaled, ...)
  panel.3dscatter(x=pts[,1], y=pts[,2], z=pts[,3],
  xlim=xlim, ylim=ylim, zlim=zlim,
  xlim.scaled=xlim.scaled, ylim.scaled=ylim.scaled,
  zlim.scaled=zlim.scaled, type=p, col=c(2,3),
  cex=1.8, pch=c(3,4), .scale=TRUE, ...)
  })

col = #ff00 instead will give you full transparency (but
transparent will not work), and col = #ff77 will be less
transparent and so on.

-Deepayan

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


Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
Thanks Nick and Juan for your replies.

Nick, thanks for pointing out the warning in subset(). I'm not sure
though I understand the example you provided -- because despite using
subset() rather than bracket notation, the original function (myfunct)
does what is expected of it. The problem I have is with the second
function (myfunct.better), where variable names + dataframe are not
fixed within the function but passed to the function when calling it
-- and even with bracket notation I don't quite manage to tell R where
to look for the columns that related to the entered column names.
(but then perhaps I misunderstood you)

This is what I tried (using bracket notation):

myfunct.better(dataframe, subgroup, lvarname,yvarname){
Data.tmp - dataframe[dataframe[,deparse(substitute(lvarname))]==subgroup,
c(xvar,deparse(substitute(yvarname)))]
}

but this creates an empty contingency table only -- perhaps because my
use of deparse() is flawed (I think what is converted into a string is
lvarname and yvarname, rather than the column names that these two
function-variables represent in the dataframe)?


2011/4/1 Nick Sabbe nick.sa...@ugent.be:
 See the warning in ?subset.
 Passing the column name of lvar is not the same as passing the 'contextual
 column' (as I coin it in these circumstances).
 You can solve it by indeed using [] instead.

 For my own comfort, here is the relevant line from your original function:
 Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
 Which should become something like (untested but should be close):
 Data.tmp - Fulldf[Fulldf[,lvar]==subgroup, c(xvar,yvar)]

 This should be a lot easier to translate based on column names, as the
 column names are now used as such.

 HTH,


 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36

 -- Do Not Disapprove




 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of E Hofstadler
 Sent: vrijdag 1 april 2011 13:09
 To: r-help@r-project.org
 Subject: [R] programming: telling a function where to look for the entered
 variables

 Hi there,

 Could someone help me with the following programming problem..?

 I have written a function that works for my intended purpose, but it
 is quite closely tied to a particular dataframe and the names of the
 variables in this dataframe. However, I'd like to use the same
 function for different dataframes and variables. My problem is that
 I'm not quite sure how to tell my function in which dataframe the
 entered variables are located.

 Here's some reproducible data and the function:

 # create reproducible data
 set.seed(124)
 xvar - sample(0:3, 1000, replace = T)
 yvar - sample(0:1, 1000, replace=T)
 zvar - rnorm(100)
 lvar - sample(0:1, 1000, replace=T)
 Fulldf - as.data.frame(cbind(xvar,yvar,zvar,lvar))
 Fulldf$xvar - factor(xvar, labels=c(blue,green,red,yellow))
 Fulldf$yvar - factor(yvar, labels=c(area1,area2))
 Fulldf$lvar - factor(lvar, labels=c(yes,no))

 and here's the function in the form that it currently works: from a
 subset of the dataframe Fulldf, a contingency table is created (in my
 actual data, several other operations are then performed on that
 contingency table, but these are not relevant for the problem in
 question, therefore I've deleted it) .

 # function as it currently works: tailored to a particular dataframe
 (Fulldf)

 myfunct - function(subgroup){ # enter a particular subgroup for which
 the contingency table should be calculated (i.e. a particular value of
 the factor lvar)
 Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
 #restrict dataframe to given subgroup and two columns of the original
 dataframe
 Data.tmp - na.omit(Data.tmp) # exclude missing values
 indextable - table(Data.tmp$xvar, Data.tmp$yvar) # make contingency table
 return(indextable)
 }

 #Since I need to use the function with different dataframes and
 variable names, I'd like to be able to tell my function the name of
 the dataframe and variables it should use for calculating the index.
 This is how I tried to modify the first part of the #function, but it
 didn't work:

 # function as I would like it to work: independent of any particular
 dataframe or variable names (doesn't work)

 myfunct.better - function(subgroup, lvarname, yvarname, dataframe){
 #enter the subgroup, the variable names to be used and the dataframe
 in which they are found
    Data.tmp - subset(dataframe, lvarname==subgroup, select=c(xvar,
 deparse(substitute(yvarname # trying to subset the given dataframe
 for the given subgroup of the given variable. The variable xvar
 happens to have the same name in all dataframes) but the variable
 yvarname has different names in the different dataframes
 Data.tmp - na.omit(Data.tmp)
    indextable - table(Data.tmp$xvar, Data.tmp$yvarname) # create the
 contingency table on the basis of the entered variables
 return(indextable)
 }

 

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
This should be a version that does what you want.
Because you named the variable lvarname, I assumed you were already passing
lvar instead of trying to pass lvar (without the quotes), which is in no
way a 'name'.

myfunct.better - function(subgroup, lvarname, xvarname, yvarname,
dataframe)
{
#enter the subgroup, the variable names to be used and the dataframe
#in which they are found
Data.tmp - Fulldf[Fulldf[,lvarname]==subgroup,
c(xvarname,yvarname)]
Data.tmp -na.omit(Data.tmp)
indextable - table(Data.tmp[,xvarname], Data.tmp[,yvarname]) #
create the contingency 
#table on the basis of the entered variables
#actually, if I remember well, you could simply use
indextable-table(Data.tmp) here
#that would allow for some more simplifications (replace xvarname
and yvarname by
#columnsOfInterest or similar, and pass that instead of c(xvarname,
yvarname) )
return(indextable)
}

myfunct.better(yes, lvarname=lvar, xvarname=xvar, yvarname=yvar,
dataframe=Fulldf)


HTH,


Nick Sabbe
--
ping: nick.sa...@ugent.be
link: http://biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36

-- Do Not Disapprove




-Original Message-
From: irene.p...@googlemail.com [mailto:irene.p...@googlemail.com] On Behalf
Of E Hofstadler
Sent: vrijdag 1 april 2011 14:28
To: Nick Sabbe
Cc: r-help@r-project.org
Subject: Re: [R] programming: telling a function where to look for the
entered variables

Thanks Nick and Juan for your replies.

Nick, thanks for pointing out the warning in subset(). I'm not sure
though I understand the example you provided -- because despite using
subset() rather than bracket notation, the original function (myfunct)
does what is expected of it. The problem I have is with the second
function (myfunct.better), where variable names + dataframe are not
fixed within the function but passed to the function when calling it
-- and even with bracket notation I don't quite manage to tell R where
to look for the columns that related to the entered column names.
(but then perhaps I misunderstood you)

This is what I tried (using bracket notation):

myfunct.better(dataframe, subgroup, lvarname,yvarname){
Data.tmp - dataframe[dataframe[,deparse(substitute(lvarname))]==subgroup,
c(xvar,deparse(substitute(yvarname)))]
}

but this creates an empty contingency table only -- perhaps because my
use of deparse() is flawed (I think what is converted into a string is
lvarname and yvarname, rather than the column names that these two
function-variables represent in the dataframe)?


2011/4/1 Nick Sabbe nick.sa...@ugent.be:
 See the warning in ?subset.
 Passing the column name of lvar is not the same as passing the 'contextual
 column' (as I coin it in these circumstances).
 You can solve it by indeed using [] instead.

 For my own comfort, here is the relevant line from your original function:
 Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
 Which should become something like (untested but should be close):
 Data.tmp - Fulldf[Fulldf[,lvar]==subgroup, c(xvar,yvar)]

 This should be a lot easier to translate based on column names, as the
 column names are now used as such.

 HTH,


 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36

 -- Do Not Disapprove




 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of E Hofstadler
 Sent: vrijdag 1 april 2011 13:09
 To: r-help@r-project.org
 Subject: [R] programming: telling a function where to look for the entered
 variables

 Hi there,

 Could someone help me with the following programming problem..?

 I have written a function that works for my intended purpose, but it
 is quite closely tied to a particular dataframe and the names of the
 variables in this dataframe. However, I'd like to use the same
 function for different dataframes and variables. My problem is that
 I'm not quite sure how to tell my function in which dataframe the
 entered variables are located.

 Here's some reproducible data and the function:

 # create reproducible data
 set.seed(124)
 xvar - sample(0:3, 1000, replace = T)
 yvar - sample(0:1, 1000, replace=T)
 zvar - rnorm(100)
 lvar - sample(0:1, 1000, replace=T)
 Fulldf - as.data.frame(cbind(xvar,yvar,zvar,lvar))
 Fulldf$xvar - factor(xvar, labels=c(blue,green,red,yellow))
 Fulldf$yvar - factor(yvar, labels=c(area1,area2))
 Fulldf$lvar - factor(lvar, labels=c(yes,no))

 and here's the function in the form that it currently works: from a
 subset of the dataframe Fulldf, a contingency table is created (in my
 actual data, several other operations are then performed on that
 contingency table, but these are not relevant for the problem in
 question, therefore I've deleted it) .

 # function as it currently works: tailored to a particular dataframe
 (Fulldf)

 myfunct - function(subgroup){ # 

Re: [R] Linear Model with curve fitting parameter?

2011-04-01 Thread stephen sefick
Setting Z=Q-A would be the incorrect dimensions.  I could Z=Q/A.  Is
fitting a nls model the same as fitting an ols?  These data are
hydraulic data from ~47 sites.  To access predictive ability I am
removing one site fitting a new model and then accessing the fit with
a myriad of model assessment criteria.  I should get the same answer
with ols vs nls?  Thank you for all of your help.

Stephen

On Thu, Mar 31, 2011 at 8:34 PM, Steven McKinney smckin...@bccrc.ca wrote:

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of stephen sefick
 Sent: March-31-11 3:38 PM
 To: R help
 Subject: [R] Linear Model with curve fitting parameter?

 I have a model Q=K*A*(R^r)*(S^s)

 A, R, and S are data I have and K is a curve fitting parameter.  I
 have linearized as

 log(Q)=log(K)+log(A)+r*log(R)+s*log(S)

 I have taken the log of the data that I have and this is the model
 formula without the K part

 lm(Q~offset(A)+R+S, data=x)

 What is the formula that I should use?

 Let Z = Q - A for your logged data.

 Fitting lm(Z ~ R + S, data = x) should yield
 intercept parameter estimate = estimate for log(K)
 R coefficient parameter estimate = estimate for r
 S coefficient parameter estimate = estimate for s



 Steven McKinney

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




 Thanks for all of your help.  I can provide a subset of data if necessary.



 --
 Stephen Sefick
 
 | Auburn University                                         |
 | Biological Sciences                                      |
 | 331 Funchess Hall                                       |
 | Auburn, Alabama                                         |
 | 36849                                                           |
 |___|
 | sas0...@auburn.edu                                  |
 | http://www.auburn.edu/~sas0025                 |
 |___|

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

                                 -K. Mullis

 A big computer, a complex algorithm and a long time does not equal science.

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




-- 
Stephen Sefick

| Auburn University                                         |
| Biological Sciences                                      |
| 331 Funchess Hall                                       |
| Auburn, Alabama                                         |
| 36849                                                           |
|___|
| sas0...@auburn.edu                                  |
| http://www.auburn.edu/~sas0025                 |
|___|

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

                                -K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

                              -Robert Gentleman

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


Re: [R] Simple lattice question

2011-04-01 Thread Peter Ehlers

Ruben,

One more thing you might try is to add a 'size' component to
the lines list. The default is size=5, but since you have
enought space in the plot, try size=8 or 9; the line types
will show up more clearly:

 
 lines=list(pch=1:4, lty=1:4, type='b', size=8),
 

Peter Ehlers

On 2011-03-31 23:28, Rubén Roa wrote:

-Mensaje original-
De: Peter Ehlers [mailto:ehl...@ucalgary.ca]
Enviado el: jueves, 31 de marzo de 2011 18:09
Para: Rubén Roa
CC: r-help@r-project.org
Asunto: Re: [R] Simple lattice question

On 2011-03-31 06:58, Rubén Roa wrote:

Thanks Peters!

Just a few minor glitches now:

require(lattice)
data-

data.frame(SP=sort(rep(as.factor(c('A','B','C','D','E')),12)),

 x=rpois(60,10),
 y=rep(c(rep(0,4),rep(10,4),rep(20,4)),5),
 z=rep(1:4,15))


xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),pch=1:4,lty=1:4

,col='black',type='b',

 key=list(x = .65, y = .75, corner = c(0, 0), points=TRUE,
lines=TRUE, pch=1:4, lty=1:4, type='b',
text=list(lab = as.character(unique(data$z)

I have an extra column of symbols on the legend,

and,

would like to add a title to the legend. Such as 'main' for plots.

Any suggestions?


for key(), make 'lines' into a list:

   xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),
  pch=1:4,lty=1:4,col='black',type='b',
  key=list(x = .65, y = .75, corner = c(0, 0),
   title=title here, cex.title=.9, lines.title=3,
   lines=list(pch=1:4, lty=1:4, type='b'),
   text=list(lab = as.character(unique(data$z)

Peter Ehlers


... that works. Thanks Peter (sorry I misspelled your name b4). The clean code 
is now:

require(lattice)
data- data.frame(SP=sort(rep(as.factor(c('A','B','C','D','E')),12)),
x=rpois(60,10),
y=rep(c(rep(0,4),rep(10,4),rep(20,4)),5),
z=rep(1:4,15))
xyplot(x~y|SP,data=data,groups=z,layout=c(2,3),pch=1:4,lty=1:4,col='black',type='b',
key=list(x = .65, y = .75, corner = c(0, 0),
   lines=list(pch=1:4, lty=1:4, type='b'),
   title=expression(CO^2),
   text=list(lab = as.character(unique(data$z)

David's code works too (thanks to you too!) and is somewhat shorter

xyplot(x~y|SP, data=data,groups=z, layout=c(2,3), 
par.settings=simpleTheme(pch=1:4,lty=1:4,col='black'), type=b,
auto.key = list(x = .6, y = .7, lines=TRUE, corner = c(0, 0)))

but the lines and symbols are on different columns, and the line types look as 
if they were in bold.

Rubén




Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] useR! 2011 abstract deadline extended by 2 days

2011-04-01 Thread David Firth
useR! 2011 Conference, University of Warwick, Coventry, UK
16-18 August, 2011

(International R user conference; see
   http://www.r-project.org/conferences.html
for the history.)

The abstract submission period for this year's useR! conference, which 
was due to end today, is *extended* by 2 days.

The FINAL DEADLINE is: Monday 4 April at 0900 GMT.

For all conference information, including the abstract submission 
details, please see
   http://www.warwick.ac.uk/statsdept/useR-2011/

David Firth
(for the useR! 2011 organisers)

-- 
Professor David Firth
http://go.warwick.ac.uk/dfirth

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


[R] Syntax coloring in R console

2011-04-01 Thread January Weiner
Dear all,

I am a happy user of R console, but I would like to see syntax
coloring. I use R 2.12 in Ubuntu Linux.

I have found the packages xterm256 and highlight, but I was not
able to figure out how to use it to highlight the syntax in console
output.

Also, I tried several GUI interfaces, but I was not able to find
something that suits me better than the default R console. R cmdr is
definitely not for me, as I don't want to fundamentally change the way
I am managing my data in R. Rkwrd seems to be nice (from screenshots),
but its installation requires all the base KDE libraries, which I
don't want to install.

I tried JGR, the GUI for R, but I have found the following problems
with this package:

- I was not able to change the background color from a repulsive grey,
- apparently, GNU readline is not implemented in that package, that
is, there is no functionality similar to ctrl-r (which searches
through the history for matching commands), something I use
frequently, and
- tab expansion is of limited use (e.g. doesn't browse files in the
current directory when expanding quoted arguments e.g. in
read.table).

All in all, I'd be happy to continue using the plain R console, but
syntax highlighting would be nice. Any advice would be extremely
welcome.

Kind regards,

January



 sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 LC_MONETARY=C
 [6] LC_MESSAGES=en_US.utf8LC_PAPER=en_US.utf8   LC_NAME=C
LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


--

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


Re: [R] lattice xscale.components: different ticks on top/bottom axis

2011-04-01 Thread Deepayan Sarkar
On Fri, Mar 11, 2011 at 12:28 AM,  boris.vasil...@forces.gc.ca wrote:
 Good afternoon,

 I am trying to create a plot where the bottom and top axes have the same
 scale but different tick marks.  I tried user-defined xscale.component
 function but it does not produce desired results.  Can anybody suggest
 where my use of xscale.component function is incorrect?

 For example, the code below tries to create a plot where horizontal axes
 limits are c(0,10), top axis has ticks at odd integers, and bottom axis
 has ticks at even integers.

 library(lattice)

 df - data.frame(x=1:10,y=1:10)

 xscale.components.A - function(...,user.value=NULL) {
  # get default axes definition list; print user.value
  ans - xscale.components.default(...)
  print(user.value)

  # start with the same definition of bottom and top axes
  ans$top - ans$bottom

  # - bottom labels
  ans$bottom$labels$at - seq(0,10,by=2)
  ans$bottom$labels$labels - paste(B,seq(0,10,by=2),sep=-)

  # - top labels
  ans$top$labels$at - seq(1,9,by=2)
  ans$top$labels$labels - paste(T,seq(1,9,by=2),sep=-)

  # return axes definition list
  return(ans)
 }

 oltc - xyplot(y~x,data=df,

 scales=list(x=list(limits=c(0,10),at=0:10,alternating=3)),
               xscale.components=xscale.components.A,
               user.value=1)
 print(oltc)

 The code generates a figure with incorrectly placed bottom and top
 labels.  Bottom labels B-0, B-2, ... are at 0, 1, ... and top labels
 T-1, T-3, ... are at 0, 1, ...  When axis-function runs out of
 labels, it replaces labels with NA.

 It appears that lattice uses top$ticks$at to place labels and
 top$labels$labels for labels.  Is there a way to override this behaviour
 (other than to expand the labels$labels vector to be as long as
 ticks$at vector and set necessary elements to )?

Well, top|bottom$ticks$at is used to place the ticks, and $labels$at
is used to place the labels. They should typically be the same, but
you have changed one and not the other. Everything seems to work if
you set $ticks$at to the same values as $labels$at:


##  - bottom labels
+   ans$bottom$ticks$at - seq(0,10,by=2)
ans$bottom$labels$at - seq(0,10,by=2)
ans$bottom$labels$labels - paste(B,seq(0,10,by=2),sep=-)

##  - top labels
+   ans$top$ticks$at - seq(1,9,by=2)
ans$top$labels$at - seq(1,9,by=2)
ans$top$labels$labels - paste(T,seq(1,9,by=2),sep=-)


 Also, can user-parameter be passed into xscale.components() function?
 (For example, locations and labels of ticks on the top axis).  In the
 code above, print(user.value) returns NULL even though in the xyplot()
 call user.value is 1.

No. Unrecognized arguments are passed to the panel function only, not
to any other function. However, you can always define an inline
function:

oltc - xyplot(y~x,data=df,
   scales=list(x=list(limits=c(0,10), at = 0:10, alternating=3)),
   xscale.components = function(...)
xscale.components.A(..., user.value=1))

Hope that helps (and sorry for the late reply).

-Deepayan

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


Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
2011/4/1 Nick Sabbe nick.sa...@ugent.be:
 This should be a version that does what you want.

Indeed it does, thank you very much!

 Because you named the variable lvarname, I assumed you were already passing
 lvar instead of trying to pass lvar (without the quotes), which is in no
 way a 'name'.

Sorry about that, I can see how my variable names were somewhat confusing.

Many thanks once again!




 -Original Message-
 From: irene.p...@googlemail.com [mailto:irene.p...@googlemail.com] On Behalf
 Of E Hofstadler
 Sent: vrijdag 1 april 2011 14:28
 To: Nick Sabbe
 Cc: r-help@r-project.org
 Subject: Re: [R] programming: telling a function where to look for the
 entered variables

 Thanks Nick and Juan for your replies.

 Nick, thanks for pointing out the warning in subset(). I'm not sure
 though I understand the example you provided -- because despite using
 subset() rather than bracket notation, the original function (myfunct)
 does what is expected of it. The problem I have is with the second
 function (myfunct.better), where variable names + dataframe are not
 fixed within the function but passed to the function when calling it
 -- and even with bracket notation I don't quite manage to tell R where
 to look for the columns that related to the entered column names.
 (but then perhaps I misunderstood you)

 This is what I tried (using bracket notation):

 myfunct.better(dataframe, subgroup, lvarname,yvarname){
 Data.tmp - dataframe[dataframe[,deparse(substitute(lvarname))]==subgroup,
 c(xvar,deparse(substitute(yvarname)))]
 }

 but this creates an empty contingency table only -- perhaps because my
 use of deparse() is flawed (I think what is converted into a string is
 lvarname and yvarname, rather than the column names that these two
 function-variables represent in the dataframe)?


 2011/4/1 Nick Sabbe nick.sa...@ugent.be:
 See the warning in ?subset.
 Passing the column name of lvar is not the same as passing the 'contextual
 column' (as I coin it in these circumstances).
 You can solve it by indeed using [] instead.

 For my own comfort, here is the relevant line from your original function:
 Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
 Which should become something like (untested but should be close):
 Data.tmp - Fulldf[Fulldf[,lvar]==subgroup, c(xvar,yvar)]

 This should be a lot easier to translate based on column names, as the
 column names are now used as such.

 HTH,


 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36

 -- Do Not Disapprove




 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of E Hofstadler
 Sent: vrijdag 1 april 2011 13:09
 To: r-help@r-project.org
 Subject: [R] programming: telling a function where to look for the entered
 variables

 Hi there,

 Could someone help me with the following programming problem..?

 I have written a function that works for my intended purpose, but it
 is quite closely tied to a particular dataframe and the names of the
 variables in this dataframe. However, I'd like to use the same
 function for different dataframes and variables. My problem is that
 I'm not quite sure how to tell my function in which dataframe the
 entered variables are located.

 Here's some reproducible data and the function:

 # create reproducible data
 set.seed(124)
 xvar - sample(0:3, 1000, replace = T)
 yvar - sample(0:1, 1000, replace=T)
 zvar - rnorm(100)
 lvar - sample(0:1, 1000, replace=T)
 Fulldf - as.data.frame(cbind(xvar,yvar,zvar,lvar))
 Fulldf$xvar - factor(xvar, labels=c(blue,green,red,yellow))
 Fulldf$yvar - factor(yvar, labels=c(area1,area2))
 Fulldf$lvar - factor(lvar, labels=c(yes,no))

 and here's the function in the form that it currently works: from a
 subset of the dataframe Fulldf, a contingency table is created (in my
 actual data, several other operations are then performed on that
 contingency table, but these are not relevant for the problem in
 question, therefore I've deleted it) .

 # function as it currently works: tailored to a particular dataframe
 (Fulldf)

 myfunct - function(subgroup){ # enter a particular subgroup for which
 the contingency table should be calculated (i.e. a particular value of
 the factor lvar)
 Data.tmp - subset(Fulldf, lvar==subgroup, select=c(xvar,yvar))
 #restrict dataframe to given subgroup and two columns of the original
 dataframe
 Data.tmp - na.omit(Data.tmp) # exclude missing values
 indextable - table(Data.tmp$xvar, Data.tmp$yvar) # make contingency table
 return(indextable)
 }

 #Since I need to use the function with different dataframes and
 variable names, I'd like to be able to tell my function the name of
 the dataframe and variables it should use for calculating the index.
 This is how I tried to modify the first part of the #function, but it
 didn't work:

 # function as I would like it to work: independent of any particular
 

[R] Information theoretic approach in GLS

2011-04-01 Thread Tímea Vincze
Dear R-Users,

Am I right if I say that comparisons among gls models with differing fixed
effects, but same correlation stuctures, fitted by REML is not meaningful? I
need to use ML fit to get comparable AIC, BIC values? And the same is
applied to likelihood ratio statistics?
I don't really know what's the differece between the two fitting methods.
Does anybody have a good documentation for understanding them? Would much
esaier to understand restrictions of REMLfit if I see the mathematical
background of it.


Cheers,
Balazs

[[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] guidelines for using the R logo

2011-04-01 Thread Johannes Hain

   Hello,
   I am writing an R-guide which is addressed especially for students of German
   Universities
   (http://www.rrzn.uni-hannover.de/buch.html?no_cache=1titel=statistik_r).
   For the title page, I want to use the R logo. I found a similar question in
   the R mailing list about the same topic. The answer was that the usage of
   the logo is OK. However, this already a few years ago and I was wondering
   wether this is still up-to-date or wether there are any guidelines I would
   violate when using the logo.
   Thanks
   --
   Johannes Hain
   University of Wuerzburg
   Chair of Mathematics VIII (Statistics)
   +49 931 31-84969

   Empfehlen Sie WEB.DE DSL Ihren Freunden und Bekannten und wir
   belohnen Sie mit bis zu 50,- Euro! [1]https://freundschaftswerbung.web.de

References

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Steve_Friedman
RStudio is a new interface. I just started using it and find it very good.
You might want to check it out.  It does have Ubuntu capabilities, but you
have be sure that your graphic drivers are the same as is specified in the
RStudio system.

Hope this helps

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147


   
 January Weiner
 january.weiner@m 
 piib-berlin.mpg.d  To 
 er-h...@stat.math.ethz.ch  
 Sent by:   cc 
 r-help-bounces@r- 
 project.org   Subject 
   [R] Syntax coloring in R console
   
 04/01/2011 06:32  
 AM
   
   
   




Dear all,

I am a happy user of R console, but I would like to see syntax
coloring. I use R 2.12 in Ubuntu Linux.

I have found the packages xterm256 and highlight, but I was not
able to figure out how to use it to highlight the syntax in console
output.

Also, I tried several GUI interfaces, but I was not able to find
something that suits me better than the default R console. R cmdr is
definitely not for me, as I don't want to fundamentally change the way
I am managing my data in R. Rkwrd seems to be nice (from screenshots),
but its installation requires all the base KDE libraries, which I
don't want to install.

I tried JGR, the GUI for R, but I have found the following problems
with this package:

- I was not able to change the background color from a repulsive grey,
- apparently, GNU readline is not implemented in that package, that
is, there is no functionality similar to ctrl-r (which searches
through the history for matching commands), something I use
frequently, and
- tab expansion is of limited use (e.g. doesn't browse files in the
current directory when expanding quoted arguments e.g. in
read.table).

All in all, I'd be happy to continue using the plain R console, but
syntax highlighting would be nice. Any advice would be extremely
welcome.

Kind regards,

January



 sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 LC_MONETARY=C
 [6] LC_MESSAGES=en_US.utf8LC_PAPER=en_US.utf8   LC_NAME=C
LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


--

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

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Liviu Andronic
Hello


On Fri, Apr 1, 2011 at 12:32 PM, January Weiner
january.wei...@mpiib-berlin.mpg.de wrote:
 I have found the packages xterm256 and highlight, but I was not
 able to figure out how to use it to highlight the syntax in console
 output.

I've been in this position before, without finding a solution for
syntax highlighting in the default R console.


 Also, I tried several GUI interfaces, but I was not able to find
 something that suits me better than the default R console. R cmdr is
 definitely not for me, as I don't want to fundamentally change the way
 I am managing my data in R. Rkwrd seems to be nice (from screenshots),
 but its installation requires all the base KDE libraries, which I
 don't want to install.

Recently RStudio was introduced [1] and, although beta, it received
quasi-unanimous acclaim from the community, so you risk finding it
useful too.
[1] http://alternativeto.net/software/rstudio/about

Regards
Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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


Re: [R] lattice (panel.3dscatter): how to make plot symbol thicker?

2011-04-01 Thread Deepayan Sarkar
On Fri, Mar 11, 2011 at 12:29 PM, Marius Hofert m_hof...@web.de wrote:
 Dear Deepayan,

 many thanks for answering.

 Another thing I am wondering is the following: I know you can have (3d-like) 
 crosses in the wireframe plot. But are there any other 3d-like plot 
 symbols? Of course one can use different colors to distinguish between 
 several points. The problem is that most of the scientific journals do not 
 allow colors [or it's expensive]. I am thus wondering if the plot symbols 
 have equivalent 3d-versions. It looks a bit odd to draw a 2d cross in a 3d 
 wireframe. Or a circle. Concerning the circle, it could be a small ball in 3d 
 for example. Is there anything like this?


No, at least not easily. The 3D crosses are done by mapping each point
into 3 perpendicular line segments, then projecting the endpoints into
the 2D space, and then joining them. This is hardcoded in
panel.3dscatter() -- search for the section inside 'if (cross)'. For
other 3D plotting characters, you need to replicate this process
(which is not really that difficult, but a bit tedious).

If you are going to be doing a lot of fancy 3D graphics, I would
strongly suggest considering rgl, which is a real 3D graphics
system. Proper 3D graphics are difficult in systems based on vector
graphics (like R graphics).

-Deepayan

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

2011-04-01 Thread Samuel Le
Dear all,



I am trying the barplot command but some of the labels are disappearing as 
there is not enough place on the graph to put them all.

Here is an example of code that doesn't show all the labels:



barplot(sort(runif(9,0,0.2),decreasing=TRUE),xlim=c(0,20),width=2,names.arg=c(first
 name,second name,third name,fourth name,fifth name,sixth 
name,seventh name,eigth name,nineth name))



Does someone know a way to control the size of the font in the barplot 
function, or to give them an inclination angle?



Many thanks,



Samuel


[[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] controlling the labels width of a barplot

2011-04-01 Thread Henrique Dallazuanna
Try the cex.names argument in barplot function.

On Fri, Apr 1, 2011 at 10:34 AM, Samuel Le samuel...@srlglobal.com wrote:
 Dear all,



 I am trying the barplot command but some of the labels are disappearing as 
 there is not enough place on the graph to put them all.

 Here is an example of code that doesn't show all the labels:



 barplot(sort(runif(9,0,0.2),decreasing=TRUE),xlim=c(0,20),width=2,names.arg=c(first
  name,second name,third name,fourth name,fifth name,sixth 
 name,seventh name,eigth name,nineth name))



 Does someone know a way to control the size of the font in the barplot 
 function, or to give them an inclination angle?



 Many thanks,



 Samuel


        [[alternative HTML version deleted]]

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




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

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


Re: [R] XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order. -- Resending with corrected .txt file

2011-04-01 Thread Deepayan Sarkar
On Sat, Mar 19, 2011 at 2:53 AM, Guy Jett gj...@itsi.com wrote:
 Due to an error on my part, I have renamed the previously attached file from
  T_5-04b_LTC-SE-SO-Compared.csv to
  T_5-04b_LTC-SE-SO-Compared.txt.
 It remains a comma-delimited file so the extension can be changed and used 
 per the script, or loaded separately.
 My sincere apologies,
 Guy

 -Original Message-
 From: Guy Jett
 Sent: Friday, March 18, 2011 1:13 PM
 To: 'r-help@R-project.org'
 Subject: XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order.

 # I need to create an xyplot() where I control the specific order of #  both 
 my conditioning variables.  The default code below plots the #  data 
 correctly (dispersed across all 14 columns), but fails in two #  ways.  Both 
 the primary conditioning variable (Transect), and the #  secondary 
 conditioning variable (Offset) are in alphanumeric order, #  rather than the 
 specific order I need.

 # Here is a call to the input datafile, which should be attached.  You may 
 rename that .txt file to .csv for processing in the following line.
    df - read.csv(file = T_5-04b_LTC-SE-SO-Compared.csv)

 # Basic default plot (correct data, incorrect layout):
    xyplot((sbd+sed)/2 ~ Result | Offset+Transect, groups = PARLABEL, as.table 
 = TRUE,
    data = df,
    layout = c(14,4), type = b)

 # I attempted to control the order following the method described in #  the 
 thread [R] xyplot() - can you control how the plots are #  ordered?, but I 
 appear to be missing, or misunderstanding #  something.  The modeled code is 
 here.  It does put all the #  individual 'lattices'(?) in the needed order, 
 BUT the graphics #  for the individual sets dump all the measurements into a 
 single #  cell, on the diagonal, as if it's treating the conditioning #  
 variables as an [i,j] index.  Again not what I want.

 #  Draft code (incorrect data, correct layout):
    Transects - c(LNF02, LSF02, LUR01, LURT1, LUR03,
                   LUR05, LUR09, LUR11, LUR12, LUR15,
                   LUR16, LUR21, LURT3, LUR25, LURT4,
                   LUR28, LUR36, LUR38, LUR46, LURT5,
                   LUR48, LLR04, LLR10, LLR11, LLRT1,
                   LLR17, LLRT2, LLR18, LLRT3, LLR19)
    Transects - factor(Transects, levels = Transects)

    Offsets - c(T, U, V, Y, Z, A, B, C, D, E, F, G, 
 H)
    Offsets - factor(Offsets, levels = Offsets)

    xyplot((sbd+sed)/2 ~ Result | Offsets+Transects, groups = PARLABEL, 
 as.table = TRUE,
    data = df,
    layout = c(13,5), type = b)

 # What I am looking for is a combination of the default plot, but ordered in 
 #  the layout of the second code fragment.

You need to specify the order of the levels explicitly (to override
the default). Here is how to do it for one, you can similarly do the
other:

 levels(df$Offset)
 [1] T U V Y Z A B C D E F G H
 df$Offset - factor(df$Offset,
+ levels = c(T, U, V, Y, Z, A,
+B, C, D, E, F, G, H))
 levels(df$Offset)
 [1] T U V Y Z A B C D E F G H

Once you make these changes, your original call should work as desired.

-Deepayan

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


Re: [R] lattice histogram function and groups

2011-04-01 Thread Deepayan Sarkar
On Sat, Mar 19, 2011 at 6:11 AM, Evans, David G (DFG)
david.ev...@alaska.gov wrote:
 Hi,

 From the following code (tweaked from another user):



 variable-sample(rep(1:2,100))

 individual-rep(1:3, length(variable))

 group-rep(LETTERS[1:2],length(variable)/2)

 mydata-data.frame(variable,individual,group)

 individual-as.factor(individual)

 group-as.factor(group)

 histogram(~variable|individual+group)



 I get six panels, one for each of  individuals 1-3 in group A and one
 for each of individuals 1-3 in group B .

 What I want is three panels , one for each individual, but with  A and B
 paired in the same panel.  I think the groups=argument does this sort
 of superposition for other lattice functions.

But not for histogram (intentionally).

See http://tolstoy.newcastle.edu.au/R/e2/help/07/04/14490.html

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Large number of Y and X variables

2011-04-01 Thread Rosario Garcia Gil
Hello

I have two issues

1. I have a linear model with several thousands of Y and X variables, so if I 
do not want to write them down one by one in the lm(Y ~ X) model how should I 
go about it.

2. Also, if I suspect that some of the Y variables could not be independent, 
what function should I apply?

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread January Weiner
 Recently RStudio was introduced [1] and, although beta, it received
 quasi-unanimous acclaim from the community, so you risk finding it
 useful too.

Dear Liviu,

RStudio might be a fine program, but it does not feature syntax
highlighting, which is the only thing I am missing from R Console (it
only colors the commands typed). Moreover, the very idea of squeezing
all R windows into one window-desktop would be counterproductive in
my particular case.

Thank you anyways!

j.



 [1] http://alternativeto.net/software/rstudio/about

 Regards
 Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




-- 
 Dr. January Weiner 3 --
Max Planck Institute for Infection Biology
Charitéplatz 1
D-10117 Berlin, Germany
Web   : www.mpiib-berlin.mpg.de
Tel     : +49-30-28460514

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

2011-04-01 Thread Landes, Ezekiel
I have an Affybatch object called batch :


 batch
AffyBatch object
size of arrays=1050x1050 features (196 kb)
cdf=HuGene-1_0-st-v1 (32321 affyids)
number of samples=384
number of genes=32321
annotation=hugene10stv1
notes=



Is there a way of converting a portion of this data into a matrix? More 
specifically, a matrix where the 384 samples are columns and the 32321 genes 
are rows? The exprs function returns a matrix that has 384 columns but for 
some reason there are 1050^2 rows.

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] read.table question #only need to change column names

2011-04-01 Thread hongsheng wu
Hi all,

I have a huge data set. All I want to do is to change the column names of
the it. So if I use read.table, I can read the data in and change colnames
and then write back, such as,

t - read.table(a.txt, header = T, sep = \t)

colnames(t)

colnames(t) - c() # new column names

write.table(t, a.txt, quote = F, sep = \t, row.names = F, col.names = T)

My question is that is there a better to do this without reading in and
write out data entirely?

Thanks.

Alex

[[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] Syntax coloring in R console

2011-04-01 Thread ONKELINX, Thierry
Dear January,

Have a look at Eclipse with the STAT-ET plugin http://www.walware.de/goto/statet

Best regards,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Namens January Weiner
 Verzonden: vrijdag 1 april 2011 15:48
 Aan: r-h...@stat.math.ethz.ch
 Onderwerp: Re: [R] Syntax coloring in R console
 
  Recently RStudio was introduced [1] and, although beta, it received 
  quasi-unanimous acclaim from the community, so you risk finding it 
  useful too.
 
 Dear Liviu,
 
 RStudio might be a fine program, but it does not feature 
 syntax highlighting, which is the only thing I am missing 
 from R Console (it only colors the commands typed). Moreover, 
 the very idea of squeezing all R windows into one 
 window-desktop would be counterproductive in my particular case.
 
 Thank you anyways!
 
 j.
 
 
 
  [1] http://alternativeto.net/software/rstudio/about
 
  Regards
  Liviu
 
 
  I tried JGR, the GUI for R, but I have found the following 
 problems 
  with this package:
 
  - I was not able to change the background color from a repulsive 
  grey,
  - apparently, GNU readline is not implemented in that 
 package, that 
  is, there is no functionality similar to ctrl-r (which searches 
  through the history for matching commands), something I use 
  frequently, and
  - tab expansion is of limited use (e.g. doesn't browse 
 files in the 
  current directory when expanding quoted arguments e.g. in 
  read.table).
 
  All in all, I'd be happy to continue using the plain R 
 console, but 
  syntax highlighting would be nice. Any advice would be extremely 
  welcome.
 
  Kind regards,
 
  January
 
 
 
  sessionInfo()
  R version 2.12.2 (2011-02-25)
  Platform: i486-pc-linux-gnu (32-bit)
 
  locale:
   [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
  LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
   [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
             LC_ADDRESS=C              LC_TELEPHONE=C [11] 
  LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
 
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  
 methods   base
 
 
  --
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Do you know how to read?
  http://www.alienetworks.com/srtest.cfm
  
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
  Do you know how to write?
  http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
 
 
 
 
 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : www.mpiib-berlin.mpg.de
 Tel     : +49-30-28460514
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Rexcel path problem

2011-04-01 Thread Jorge Nieves

Hi,

I am running a test to call an R script with in excel using VBA. My VBA
code is shown bellow. The middle section of this mail also includes the
content of my Rscript.  The bottom part shows the error message form the
R console.

It seems that Excel is  opening the R console without any problems. 

The problem I am seeing is that Rinterface.RRun  instruction is
interpreting the \T part of the path as an R command. It does not
recognize the X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
models\ as a one single string, or path.


Any ideas how can I fix the problem?

Thanks ,'

Jorge


VB code
Sub tester()

Rinterface.StartRServer
 
 Rinterface.RRun
(source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
models\toto.R'))

Rinterface.StopRServer

End Sub



R cript code toto.R
path = getwd()
setwd(path)
a = 5
b=5
x = matrix(rnorm(a*b),a,b)
a = 5
b=5

y = matrix(rnorm(a*b),a,b)
z = x %*% y
savefile = paste(path,/,testresults.csv,sep=)
write.csv(z, file = savefile)





Rconsole message

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Loading required package: rcom
Loading required package: rscproxy
Error: '\T' is an unrecognized escape in character string starting
source('X:\T
  

Jorge Nieves



[[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] Rexcel path problem

2011-04-01 Thread Richard M. Heiberger
Jorge,

This looks like an R on Windows problem,  it is unrelated to VBA.

You have the statement

(source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
models\toto.R'))

which is invalid R.  You need to use either forward slashes or
double-back-slashes in R commands.
See the R for Windows FAQ 2.16.

Further RCOM questions should be addressed to the rcom list.  You can sign
up at
rcom.univie.ac.at

Rich





On Fri, Apr 1, 2011 at 10:12 AM, Jorge Nieves jorge.nie...@moorecap.comwrote:


 Hi,

 I am running a test to call an R script with in excel using VBA. My VBA
 code is shown bellow. The middle section of this mail also includes the
 content of my Rscript.  The bottom part shows the error message form the
 R console.

 It seems that Excel is  opening the R console without any problems.

 The problem I am seeing is that Rinterface.RRun  instruction is
 interpreting the \T part of the path as an R command. It does not
 recognize the X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\ as a one single string, or path.


 Any ideas how can I fix the problem?

 Thanks ,'

 Jorge


 VB code
 Sub tester()

Rinterface.StartRServer

 Rinterface.RRun
 (source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\toto.R'))

Rinterface.StopRServer

 End Sub



 R cript code toto.R
 path = getwd()
 setwd(path)
 a = 5
 b=5
 x = matrix(rnorm(a*b),a,b)
 a = 5
 b=5

 y = matrix(rnorm(a*b),a,b)
 z = x %*% y
 savefile = paste(path,/,testresults.csv,sep=)
 write.csv(z, file = savefile)





 Rconsole message

 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.

 Loading required package: rcom
 Loading required package: rscproxy
 Error: '\T' is an unrecognized escape in character string starting
 source('X:\T
  

 Jorge Nieves



[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Liviu Andronic
On Fri, Apr 1, 2011 at 3:48 PM, January Weiner
january.wei...@mpiib-berlin.mpg.de wrote:
 RStudio might be a fine program, but it does not feature syntax
 highlighting, which is the only thing I am missing from R Console (it
 only colors the commands typed).

The idea is that you shouldn't use the R console for you main
programming needs, but only for quick and dirty checks. For the bulk
of programming tasks you are invited to use the integrated editor
(File  New  Script). The editor window does feature syntax
highlighting, and a very helpful completion mechanism (via tab).
Sending lines for execution to the terminal is as easy as clicking
'run lines' or ctrl+enter. If you're not a fan of keeping scripts for
your projects you can easily use temporary files that you don't save.


 Moreover, the very idea of squeezing
 all R windows into one window-desktop would be counterproductive in
 my particular case.

Notice that all panes are freely resizable and can be resized to the
point of becoming hidden. Future releases will give more control over
the panes layout (I think).

Regards
Liviu


 Thank you anyways!

 j.



 [1] http://alternativeto.net/software/rstudio/about

 Regards
 Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology
 Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : www.mpiib-berlin.mpg.de
 Tel     : +49-30-28460514

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




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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


Re: [R] Rexcel path problem

2011-04-01 Thread Berend Hasselman

On 01-04-2011, at 16:12, Jorge Nieves wrote:

 
 Hi,
 
 I am running a test to call an R script with in excel using VBA. My VBA
 code is shown bellow. The middle section of this mail also includes the
 content of my Rscript.  The bottom part shows the error message form the
 R console.
 
 It seems that Excel is  opening the R console without any problems. 
 
 The problem I am seeing is that Rinterface.RRun  instruction is
 interpreting the \T part of the path as an R command. It does not
 recognize the X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\ as a one single string, or path.
 
 
 Any ideas how can I fix the problem?
 
 Thanks ,'
 
 Jorge
 
 
 VB code
 Sub tester()
 
Rinterface.StartRServer
 
 Rinterface.RRun
 (source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\toto.R'))
 
Rinterface.StopRServer
 
 End Sub
 
 
 
 R cript code toto.R
 path = getwd()
 setwd(path)
 a = 5
 b=5
 x = matrix(rnorm(a*b),a,b)
 a = 5
 b=5
 
 y = matrix(rnorm(a*b),a,b)
 z = x %*% y
 savefile = paste(path,/,testresults.csv,sep=)
 write.csv(z, file = savefile)
 
 Rconsole message
 
 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.
 
 Loading required package: rcom
 Loading required package: rscproxy
 Error: '\T' is an unrecognized escape in character string starting
 source('X:\T


R is just telling you that it doesn't recognize \T as a valid escape sequence 
in a character string.

See R for Windows FAQ 2.16 and 5.1.

Use \\ instead of a single \ as path separator or use the forward slash /.

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


Re: [R] Colour makes my life; but not my bwplot (panel.violin)

2011-04-01 Thread Deepayan Sarkar
On Fri, Mar 25, 2011 at 3:59 PM, JP jeanpaul.ebe...@inhibox.com wrote:
 Hi there David,

 Many thanks for your time and reply

 I created a small test set, and ran your proposed solution... and this is
 what I get http://i.imgur.com/vlsSQ.png
 This is not what I want - I want separate grp_1 and grp_2 panels and in each
 panel a red violin plot and a blue one.  So like this --
 http://i.imgur.com/NnsE0.png but with red for condition_a and blue for
 condition_b.  You would think that something like this is trivial to
 achieve... I just spent a whole day on this :((  Maybe I am just thick

 I included the test data I am using:

 # some dummy data
 p - rep(c(rep(condition_a, 4), rep(condition_b, 4)), 2)
 q - c(rep(grp_1, 8), rep(grp_2, 8))
 r - rnorm(16)
 test_data - data.frame(p, q, r)

 # your solution
 bwplot(r ~ p,
   groups = q,
   data=test_data,
   col = c(red, blue),
   panel=panel.superpose,
   panel.groups = function(..., box.ratio){
 panel.violin(...,  cut = 1, varwidth = FALSE, box.ratio = box.ratio)
 panel.bwplot(...,  box.ratio = .1)
 },
 par.settings = list(plot.symbol = list(pch = 21, col = gray),
    box.rectangle = list(col = black),   # not sure these are working
 properly
 box.umbrella = list(col = black))
 )

Umm, isn't this slight modification of the above what you want (only
first two lines changed -- your formula with the right 'groups'
variable)?

bwplot(r ~ p | q,
   groups = p,
   data=test_data,
   col = c(red, blue),
   panel=panel.superpose,
   panel.groups = function(..., box.ratio){
   panel.violin(...,  cut = 1, varwidth = FALSE, box.ratio = box.ratio)
   panel.bwplot(...,  box.ratio = .1)
   },
   par.settings = list(plot.symbol = list(pch = 21, col = gray),
   box.rectangle = list(col = black),
   box.umbrella = list(col = black))
   )

Some further modifications will get you closer to David's solution:

bwplot(r ~ p | q,
   groups = p,
   data=test_data,
   col = c(red, blue),
   fill = c(red, blue),
   panel=panel.superpose,
   panel.groups = function(..., box.ratio, col, pch){
   panel.violin(...,  cut = 1, varwidth = FALSE, box.ratio =
box.ratio, col = col)
   panel.bwplot(...,  box.ratio = .1, col = black, pch = 16)
   },
   par.settings = list(plot.symbol = list(pch = 21, col = gray),
   box.rectangle = list(col = black),
   box.umbrella = list(col = black))
   )

-Deepayan

 # my non working one for completeness

 bwplot(r ~ p | q,
 data=test_data,
 col = c(red, blue),
 panel = function(..., box.ratio){
 panel.violin(...,  cut = 1, varwidth = FALSE, box.ratio = box.ratio)
 panel.bwplot(...,  box.ratio = .1)
 },
 par.settings = list(plot.symbol = list(pch = 21, col = gray),
 box.rectangle = list(col = black),   # not sure these are working properly
 box.umbrella = list(col = black))
 )


 On 24 March 2011 21:59, David Winsemius dwinsem...@comcast.net wrote:


 On Mar 24, 2011, at 1:37 PM, JP wrote:

  Using Trellis, am successfully setting up a number of panels (25) in which
 I
 have two box and violin plots.

 I would like to colour - one plot as RED and the other as BLUE (in each
 panel).  I can do that with the box plots, but the violin density areas
 just
 take on one colour.

 My basic call is as follows:


 I took the suggestion of Sarkar's:
 http://finzi.psych.upenn.edu/Rhelp10/2010-April/234191.html

 Identified with a search on:  panel.violin color

  a bit of trial and error with a re-worked copy of the `singer`
 data.frame meant I encountered errors and needed to throw out some of your
 pch arguments, and suggest this reworking of your code:


 bwplot(rmsd ~ file , groups= code,
   data=spread_data.filtered, col = c(red, blue),
    panel=panel.superpose,
     panel.groups = function(..., box.ratio){
       panel.violin(...,  cut = 1, varwidth = FALSE,
                       box.ratio = box.ratio)
       panel.bwplot(...,  box.ratio = .1)

       },
   par.settings = list(plot.symbol = list(pch = 21, col = gray),
   box.rectangle = list(col = black),   # not sure these are working
 properly

   box.umbrella = list(col = black))
 )

 Obviously it cannot be tested without some data, but I did get alternating
 colors to the violin plots. There is an modifyList functionthat you might
 want to look up in the archives for changing par.settings:


 http://search.r-project.org/cgi-bin/namazu.cgi?query=par.settings+modifyListmax=100result=normalsort=scoreidxname=functionsidxname=Rhelp08idxname=Rhelp10idxname=Rhelp02


 --

 David Winsemius, MD
 West Hartford, CT




 --

 Jean-Paul Ebejer
 Early Stage Researcher

 InhibOx Ltd
 Pembroke House
 36-37 Pembroke Street
 Oxford
 OX1 1BP
 UK

 (+44 / 0) 1865 262 034



 This email and any files transmitted with it are confide...{{dropped:22}}

 __
 R-help@r-project.org mailing list
 

Re: [R] Rexcel path problem

2011-04-01 Thread Jeff Newmiller
Use / instead of \ in the path.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Jorge Nieves jorge.nie...@moorecap.com wrote:

Hi, I am running a test to call an R script with in excel using VBA. My VBA 
code is shown bellow. The middle section of this mail also includes the content 
of my Rscript. The bottom part shows the error message form the R console. It 
seems that Excel is opening the R console without any problems. The problem I 
am seeing is that Rinterface.RRun instruction is interpreting the \T part of 
the path as an R command. It does not recognize the 
X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home models\ as a one single 
string, or path. Any ideas how can I fix the problem? Thanks ,' Jorge VB code 
Sub tester() Rinterface.StartRServer Rinterface.RRun 
(source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home models\toto.R')) 
Rinterface.StopRServer End Sub R cript code toto.R path = getwd() setwd(path) 
a = 5 b=5 x = matrix(rnorm(a*b),a,b) a = 5 b=5 y = matrix(rnorm(a*b),a,b) z = x 
%*% y savefile = paste(path,/,testresults.csv,sep=) write.csv(z, file = 
savefile) Rconsole messa
 ge Type
'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an 
HTML browser interface to help. Type 'q()' to quit R. Loading required package: 
rcom Loading required package: rscproxy Error: '\T' is an unrecognized escape 
in character string starting source('X:\T   Jorge Nieves 
[[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] Rexcel path problem

2011-04-01 Thread Felipe Carrillo
Jorge:
You can run save your scripts in the same folder where your wokbook is and run 
it like this:

Sub Scatter()
Call rinterface.StartRServer
'Put the dataframe into R
Call rinterface.PutDataframe(scatter, DownRightFrom(Range(RData!A1)), 
WithRowNames:=False)
Call rinterface.RRun(attach(scatter))
'Run the RScatter script
rinterface.RunRFile ThisWorkbook.Path  \RScatter.r
Call rinterface.StopRServer
End Sub

I

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Jorge Nieves jorge.nie...@moorecap.com
 To: r-h...@stat.math.ethz.ch
 Sent: Fri, April 1, 2011 7:12:39 AM
 Subject: [R] Rexcel path problem
 
 
 Hi,
 
 I am running a test to call an R script with in excel using VBA. My VBA
 code is shown bellow. The middle section of this mail also includes the
 content of my Rscript.  The bottom part shows the error message form the
 R console.
 
 It seems that Excel is  opening the R console without any problems. 
 
 The problem I am seeing is that Rinterface.RRun  instruction is
 interpreting the \T part of the path as an R command. It does not
 recognize the X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\ as a one single string, or path.
 
 
 Any ideas how can I fix the problem?
 
 Thanks ,'
 
 Jorge
 
 
 VB code
 Sub tester()
 
     Rinterface.StartRServer
 
     Rinterface.RRun
 (source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\toto.R'))    
 
     Rinterface.StopRServer
     
 End Sub
 
 
 
 R cript code toto.R
 path = getwd()
 setwd(path)
 a = 5
 b=5
 x = matrix(rnorm(a*b),a,b)
 a = 5
 b=5
 
 y = matrix(rnorm(a*b),a,b)
 z = x %*% y
 savefile = paste(path,/,testresults.csv,sep=)
 write.csv(z, file = savefile)
 
 
 
 
 
 Rconsole message
 
 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.
 
 Loading required package: rcom
 Loading required package: rscproxy
 Error: '\T' is an unrecognized escape in character string starting
 source('X:\T
   
 
 Jorge Nieves
 
 
 
     [[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] choosing best 'match' for given factor

2011-04-01 Thread Murali.Menon
Interesting variety of solutions! Thanks very much.

Murali

-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: 31 March 2011 18:26
To: Menon Murali
Cc: r-help@r-project.org
Subject: Re: [R] choosing best 'match' for given factor

Try this:

bestMatch - function(search, match) {
colnames(match)[pmax(apply(match[,search], 2, which.max) - 1, 1)]
}


On Thu, Mar 31, 2011 at 11:46 AM,  murali.me...@avivainvestors.com wrote:
 Folks,

 I have a 'matching' matrix between variables A, X, L, O:

 a - structure(c(1, 0.41, 0.58, 0.75, 0.41, 1, 0.6, 0.86, 0.58,
 0.6, 1, 0.83, 0.75, 0.86, 0.83, 1), .Dim = c(4L, 4L), .Dimnames = list(
    c(A, X, L, O), c(A, X, L, O)))

 a
      A     X     L     O
 A  1.00  0.41  0.58  0.75
 X  0.41  1.00  0.60  0.86
 L  0.58  0.75  1.00  0.83
 O  0.60  0.86  0.83  1.00

 And I have a search vector of variables

 v - c(X, O)

 I want to write a function bestMatch(searchvector, matchMat) such that for 
 each variable in searchvector, I get the variable that it has the highest 
 match to - but searching only among variables to the left of it in the 
 'matching' matrix, and not matching with any variable in searchvector itself.

 So in the above example, although X has the highest match (0.86) with O, 
 I can't choose O as it's to the right of X (and also because O is in the 
 searchvector v already); I'll have to choose A.

 For O, I will choose L, the variable it's best matched with - as it can't 
 match X already in the search vector.

 My function bestMatch(v, a) will then return c(A, L)

 My matrix a is quite large, and I have a long list of search vectors v, so I 
 need an efficient method.

 I wrote this:

 bestMatch - function(searchvector,  matchMat) {
        sapply(searchvector, function(cc) {
                             y - matchMat[!(rownames(matchMat) %in% 
 searchvector)  (index(rownames(matchMat))  match(cc, rownames(matchMat))), 
 cc, drop = FALSE];
                             rownames(y)[which.max(y)]
        })
 }

 Any advice?

 Thanks,

 Murali

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] bwplot [lattice]: how to get different y-axis scales for each row?

2011-04-01 Thread Deepayan Sarkar
On Sun, Mar 27, 2011 at 8:50 PM, Marius Hofert m_hof...@web.de wrote:
 Dear expeRts,

 I partially managed to obtain what I wanted by using latticeExtra. However, 
 the
 following questions remain:
 1) why do not all x-axis labels appear? [compare bw and bw2]

You have unnecessarily asked for relation=free for the x-axis (even
though they don't change across panels), and then tried to combine
them using combineLimits(), which doesn't know how to handle
categorical axes.

Change to using relation=free for the y-axis only, and you should be fine.

bw - bwplot(error ~ methods | attr * groups, data=df,
as.table=TRUE, notch=TRUE,
scales = list(y = list(alternating = c(1,1), tck=c(1,0),
   relation = free)))


 2) Can I have the y-axis labels on the right margin/side of the plot? Changing
 the alternating argument does not do the job since relation=free

No. (Well, you can provide your own axis() function to do it, in which
case you will need to allocate space too.)

-Deepayan



 Cheers,

 Marius



 library(lattice)
 library(latticeExtra)

 ## build example data set
 dim - c(100, 6, 4, 3) # n, groups, methods, attributes
 dimnames - list(n=paste(n=, seq_len(100), sep=),
                 groups=paste(group=, seq_len(6), sep=),
                 methods=paste(method=, seq_len(4), sep=),
                 attr=paste(attribute=, seq_len(3), sep=))
 set.seed(1)
 data - rexp(prod(dim))
 arr - array(data=data, dim=dim, dimnames=dimnames)
 arr[,2,,] - arr[,2,,]*10
 arr[,4,2,2] - arr[,4,2,2]*10
 z - abs(sweep(arr, 3, 1))
 df - as.data.frame.table(z, responseName=error)

 ## box plot
 bw - bwplot(error ~ methods | attr * groups, data=df,
             as.table=TRUE, notch=TRUE,
             scales=list(y=list(alternating=c(1,1), tck=c(1,0)),
             relation=free))
 (bw2 - useOuterStrips(combineLimits(bw, extend=FALSE



 On 2011-03-26, at 09:34 , Marius Hofert wrote:

 Dear expeRts,

 How can I get ...
 (1) different y-axis scales for each row
 (2) while having the same y-axis scales for different columns?

 I coulnd't manage to do this with relation=free [which gives (1) but not 
 (2)].
 I also tried relation=sliced, but it did not give the same y-axis scales
 within each row (see the fourth row). Further, it separates the panels.

 Cheers,

 Marius

 ## minimal example:

 library(lattice)

 ## build example data set
 dim - c(100, 6, 2, 3) # n, groups, methods, attributes
 dimnames - list(n=paste(n=, seq_len(100), sep=),
                groups=paste(group=, seq_len(6), sep=),
                methods=paste(method=, seq_len(2), sep=),
                attr=paste(attribute=, seq_len(3), sep=))
 set.seed(1)
 data - rexp(prod(dim))
 arr - array(data=data, dim=dim, dimnames=dimnames)
 arr[,2,,] - arr[,2,,]*10
 arr[,4,2,2] - arr[,4,2,2]*10
 z - abs(sweep(arr, 3, 1))
 df - as.data.frame.table(z, responseName=error)

 ## box plot
 bwplot(error ~ methods | attr * groups, data=df,
       as.table=TRUE, notch=TRUE,
       scales=list(alternating=c(1,1), tck=c(1,0)))

 ## with relation=sliced
 bwplot(error ~ methods | attr * groups, data=df,
       as.table=TRUE, notch=TRUE,
       scales=list(alternating=c(1,1), tck=c(1,0), relation=sliced))


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Plotting symbols and colors based upon data values

2011-04-01 Thread David Winsemius
Thanks to Deepayan for sending me the code for the correct approach  
using subscripts.


On Mar 13, 2011, at 9:46 PM, David Winsemius wrote:



On Mar 13, 2011, at 8:51 PM, Mark Linderman wrote:

David, thank you for your quick reply.  I spent a few minutes  
getting your
command to work with some sparse synthetic data, and then spent  
several
hours trying to figure out why my data didn't work (at least for  
symbols,
colors look okay).  I have massaged my data to where it is  
practically
indistinguishable from the synthetic data - yet it still doesn't  
work.

Attached are the two data files that can be plotted as follows:

broken = read.table(broken.table,header=TRUE)
works = read.table(works.table,header=TRUE)
xyplot(Y ~ X | A, data=works, pch=works$C , col=works$B)
xyplot(Y ~ X | A, data=broken, pch=broken$C , col=broken$B)



xyplot(Y ~ X | A, data=works, pch=works$C , col=as.character(works$B),
  panel = function(..., pch, col, subscripts) {
  panel.xyplot(..., pch = pch[subscripts], col =  
col[subscripts])

  })

--
David (for Deepayan Sarkar)


I get the same problem and after experimenting for a while I think I  
can solve it by randomizing the order of the entries:


 broken - broken[sample(417), ]

 xyplot(Y ~ X | A, data=broken, pch=broken$C, col=broken$B)

Why xyplot should fail to properly assign pch values just because  
all 1's are at the beginning seems to me to be a bug.


--
David.

After confirming the the problem recurs when re-order()-ed by broken 
$C, I am appending dput( ordered-broken) for others to experiment


 dput(broken[order(broken$C), ])
structure(list(rown = c(91L, 193L, 128L, 8L, 143L, 46L, 60L,
99L, 112L, 67L, 25L, 15L, 188L, 93L, 115L, 4L, 190L, 64L, 147L,
119L, 82L, 120L, 23L, 139L, 28L, 42L, 180L, 24L, 145L, 71L, 13L,
95L, 94L, 104L, 149L, 74L, 32L, 184L, 11L, 114L, 90L, 70L, 63L,
141L, 192L, 126L, 153L, 172L, 26L, 151L, 109L, 133L, 79L, 35L,
61L, 43L, 52L, 29L, 30L, 80L, 154L, 7L, 121L, 122L, 106L, 182L,
16L, 2L, 175L, 34L, 102L, 174L, 117L, 178L, 100L, 68L, 48L, 31L,
53L, 168L, 59L, 165L, 123L, 69L, 55L, 62L, 163L, 39L, 108L, 96L,
97L, 113L, 87L, 164L, 169L, 33L, 118L, 45L, 148L, 129L, 22L,
116L, 101L, 157L, 191L, 89L, 75L, 156L, 137L, 183L, 98L, 150L,
124L, 144L, 127L, 155L, 57L, 36L, 14L, 161L, 187L, 138L, 111L,
146L, 20L, 107L, 140L, 110L, 125L, 41L, 105L, 159L, 103L, 132L,
44L, 166L, 56L, 171L, 195L, 40L, 135L, 5L, 58L, 37L, 54L, 83L,
17L, 142L, 77L, 162L, 170L, 160L, 78L, 38L, 194L, 21L, 167L,
27L, 81L, 185L, 47L, 66L, 73L, 3L, 134L, 158L, 51L, 173L, 50L,
18L, 12L, 6L, 189L, 72L, 85L, 65L, 92L, 179L, 86L, 49L, 130L,
177L, 152L, 176L, 9L, 10L, 76L, 88L, 131L, 181L, 19L, 186L, 136L,
1L, 84L, 366L, 235L, 196L, 224L, 206L, 288L, 204L, 274L, 199L,
239L, 271L, 295L, 266L, 305L, 284L, 340L, 268L, 296L, 293L, 262L,
300L, 212L, 336L, 208L, 358L, 242L, 221L, 237L, 369L, 292L, 201L,
338L, 233L, 217L, 227L, 225L, 270L, 267L, 345L, 205L, 219L, 278L,
337L, 230L, 380L, 291L, 229L, 367L, 339L, 241L, 228L, 263L, 349L,
348L, 371L, 202L, 207L, 351L, 282L, 222L, 200L, 213L, 285L, 375L,
302L, 231L, 223L, 386L, 352L, 363L, 353L, 357L, 359L, 350L, 283L,
362L, 218L, 198L, 374L, 301L, 286L, 364L, 368L, 220L, 298L, 280L,
214L, 273L, 303L, 382L, 354L, 238L, 373L, 234L, 356L, 216L, 289L,
370L, 381L, 343L, 361L, 306L, 281L, 203L, 341L, 355L, 346L, 272L,
264L, 360L, 334L, 210L, 197L, 342L, 299L, 378L, 236L, 333L, 294L,
347L, 275L, 385L, 365L, 209L, 297L, 240L, 265L, 379L, 304L, 269L,
372L, 384L, 344L, 287L, 332L, 376L, 261L, 377L, 383L, 215L, 232L,
277L, 276L, 211L, 290L, 335L, 226L, 279L, 399L, 307L, 395L, 400L,
411L, 388L, 319L, 403L, 320L, 309L, 318L, 407L, 402L, 308L, 326L,
251L, 260L, 246L, 408L, 331L, 312L, 387L, 414L, 253L, 315L, 413L,
416L, 327L, 393L, 322L, 390L, 317L, 389L, 249L, 325L, 329L, 398L,
397L, 323L, 396L, 255L, 415L, 245L, 391L, 412L, 259L, 417L, 311L,
392L, 409L, 328L, 254L, 248L, 310L, 258L, 405L, 324L, 250L, 406L,
316L, 394L, 257L, 404L, 243L, 252L, 410L, 313L, 256L, 330L, 321L,
244L, 401L, 247L, 314L), X = c(0.701250601327047, 0.164821685524657,
0.606994603062049, 0.863256110809743, 0.956295087235048,  
0.94587846682407,
0.838799783028662, 0.523805776145309, 0.562612239504233,  
0.0359199855010957,
0.142975208582357, 0.459868715610355, 0.579013091977686,  
0.384347806917503,
0.161508617224172, 0.96426909067668, 0.504280025139451,  
0.438289026031271,
0.373645842541009, 0.439572562696412, 0.25889431219548,  
0.0467256724368781,
0.365111395483837, 0.40517632686533, 0.847934616263956,  
0.0139284294564277,
0.228810637025163, 0.976755930809304, 0.537870434345677,  
0.831849699141458,
0.735547028947622, 0.107985522132367, 0.200033176457509,  
0.250281900400296,
0.578671747585759, 0.289995870785788, 0.440369168063626,  
0.364585015457124,
0.905479809269309, 0.446940524037927, 0.658691298449412,  
0.0173427225090563,
0.24269335786812, 0.430798843270168, 0.164247164269909,  
0.357896727975458,
0.381168011575937, 0.466935358708724, 0.598047381266952,  

Re: [R] read.table question #only need to change column names

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 10:00 AM, hongsheng wu wrote:


Hi all,

I have a huge data set. All I want to do is to change the column  
names of
the it. So if I use read.table, I can read the data in and change  
colnames

and then write back, such as,

t - read.table(a.txt, header = T, sep = \t)

colnames(t)

colnames(t) - c() # new column names

write.table(t, a.txt, quote = F, sep = \t, row.names = F,  
col.names = T)


My question is that is there a better to do this without reading in  
and

write out data entirely?



With an editor.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Joshua Wiley
Dear January,

Have you looked at Emacs + ESS?  http://ess.r-project.org/

It highlights in the text editor and the actual R process besides
coming with a rich set of features and a mailing list filled with
helpful Emacs  R users.  I've tried several different interfaces and
ended up being happiest by far with Emacs + ESS.  I also seem to
recall Kate or Kedit at least highlighted .R files, but I am not in a
position to check right now.

Happy hunting,

Josh

On Fri, Apr 1, 2011 at 3:32 AM, January Weiner
january.wei...@mpiib-berlin.mpg.de wrote:
 Dear all,

 I am a happy user of R console, but I would like to see syntax
 coloring. I use R 2.12 in Ubuntu Linux.

 I have found the packages xterm256 and highlight, but I was not
 able to figure out how to use it to highlight the syntax in console
 output.

 Also, I tried several GUI interfaces, but I was not able to find
 something that suits me better than the default R console. R cmdr is
 definitely not for me, as I don't want to fundamentally change the way
 I am managing my data in R. Rkwrd seems to be nice (from screenshots),
 but its installation requires all the base KDE libraries, which I
 don't want to install.

 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] a statistical problem - more statistical strategy for making quality control

2011-04-01 Thread Mao Jianfeng
Dear R-listers,

I would like to have your helps on make a good strategy of quality
control by several quality control variables. This means I need a good
strategy to choose cutoff for each quality control variables, or make
cutoff for all such quality control variables in one time.

For quality control, we employed several values. Each production has
each value of such variables:
(1) concordance, (float, from 0 to 1, but 0.5 is the expected best one).
(2) coverage, (integer, =1, more large more better)
(3) base quality, (integer, 1 to 40, more large more better)

Here, concordance may be the most important variable for quality
control. The best product determined by concordance are those have
values of 0.5. Obviously, smaller ones (0.1) and bigger ones (0.9)
are not good. Coverage may also play an important role, like the
products which have 0.5 vale for concordance and 0.1 coverage may not
be the good calls. While, base quality is the same with converage. The
bigger base quality should be the products which are better.

Here, I want to find a good strategy to set a cutoff to our products
based on these three or just concordance and coverage variables. I
prefer a more statistical way.

Would you please give me any ideas/directions on my problems? Thanks in advance.

###
# as an example, I create a dummy data for my question.

product-1:100
concordance-rnorm(100, mean=0.2)
coverage-sample(1:50, 100, replace = T)
base.quality-sample(1:40, 100, replace = T)

dummy - cbind(product, concordance, coverage, base.quality)

Best,

Jian-Feng, Mao

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Alexander Engelhardt

Am 01.04.2011 17:02, schrieb Joshua Wiley:

Dear January,

Have you looked at Emacs + ESS?  http://ess.r-project.org/

It highlights in the text editor and the actual R process besides
coming with a rich set of features and a mailing list filled with
helpful Emacs  R users.  I've tried several different interfaces and
ended up being happiest by far with Emacs + ESS.  I also seem to
recall Kate or Kedit at least highlighted .R files, but I am not in a
position to check right now.


Another vote for Emacs + ESS here.
I think sooner or later you'll need some kind of editor (with built-in 
syntax highlighing) to save your code. The naked R console won't do it 
forever :)


Although I didn't like Emacs at first because of its steep learning 
curve, after a while you'll love the keyboard shortcuts for everything.


Also, this add-on is very useful. It makes Shift-Enter send your lines 
to R (and a bit more):

http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/

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


Re: [R] Connect observed values by a smooth curve, is there any method to get coordinate value of arbitrary point on the curve?

2011-04-01 Thread Zhipeng Wang
Dear Prof. Murdoch and Dr. Winsemius,

Thank you very much for your suggestion. They were big help.
One of my friends told me another approach by using smooth.spline. Here is
the code:

x - c(1,2,3,4,5,6)
y - c(1,4,9,16,25,36)
sp - smooth.spline(x,y)
x - seq(1, 6, length=100)
pred - predict(sp, x)
real - x^2
err - real - pred$y
cbind(pred$x, pred$y, real, err)
plot(pred)

Thank a lot. Have a nice weekend  :)

Wang Zhipeng

[[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] regression line on boxplots

2011-04-01 Thread Yan Jiao
Dear R users,

I'm trying to add a regression line on my boxplots (something 
like:boxplot(c(1:3),c(4:6),c(5:8)))
But I can't see it.
Please help !!!
It's not a April fool's joke!!!

Yan

[[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] Simple AR(2)

2011-04-01 Thread Fabio Ciotola
Hello list,

we are beginners in R and we are trying to fit the following time series:


  * x - c(1.89, 2.46, 3.23, 3.95, 4.56, 5.07, 5.62, 6.16, 6.26,
6.56, 6.98, 7.36, 7.53, 7.84, 8.09)*


The reason for choosing the present time series is that the we
have previously calculated analytically the autoregressive coefficients
using the direct inversion method as *1.1, 0.765, 0.1173*. Since those
coefficients fits well our time series, we wanted to learn how to do it in R
and check that it would give us the same autoregressive coefficients as the
direct inversion method.

So as first step in R we have initially applied the OLS method and obtained
the following autoregression coefficients:

* ar(x, method=ols, order.max=2, demean=FALSE, intercept=TRUE)*

*Call:**ar(x = x, order.max = 2, method = ols, demean = FALSE,
intercept = TRUE)*
*Coefficients:*
 *1   2  **0.8049  0.0834  *
*Intercept: 1.103 (0.2321) *
*Order selected 2  sigma^2 estimated as  0.009756*


Those are very close to the ones obtained with the direct inversion method
so the fitting is good.

Then we tried to apply the other techniques available in R,
namely Yule/Walker, Burg, MLE, obtaining different coefficients, which do
not give a good fit of the series at all.

* ar(x, method=yw, order.max=2, demean=FALSE, intercept=TRUE)*

*Call:**ar(x = x, order.max = 2, method = yw, demean = FALSE,
intercept = TRUE)*
*Coefficients:*
 *1  **0.9305  *

*Order selected 1 sigma^2 estimated as 5.368*


 Please can anybody help us telling how to get a reasonable good fit with
YW, Burg and MLE, reporting also the code that needs to be used and
commenting the coefficients obtained by comparing those with the ones
obtained with OLS.


 Thanks in advance.
Fabio

[[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] Cox Proportional Hazards model with a time-varying covariate

2011-04-01 Thread Paul Miller
Hi Terry and Kevin,
 
Thanks for your replies to my post. And thanks particularly to Terry for 
pointing out my confusion about the exact partial likelihood vs. the exact 
marginal likelihood. I'm learning and so am likely to be confused about such 
things from time to time. 
 
I had thought that a good way to see if I was replicating the results would be 
to use the Efron approximation in both R and SAS. I tried this just now and 
obtained a similar pattern of differences in the results. Please bear with me. 
I hope I'm not doing something silly.
 
Below are my results in each program. I got the results for R simply by 
running the code I sent earlier. I got the results in SAS by changing TIES 
= EXACT to TIES = EFRON.
 
Should I be getting results as different as these? Or does this suggest that 
there is some problem in how I've set up my data in R? I've looked over my 
data In R and everything looks fine, but maybe I've missed something.
 
Thanks,
 
Paul
 
 summary(model)
Call:
coxph(formula = Surv(START, STOP, STATUS) ~ TRT + DENS + INFCTN, 
    data = vitclear)
  n= 167 
          coef exp(coef) se(coef)      z Pr(|z|)
TRT     0.2913    1.3382   0.1782  1.635    0.102
DENS   -0.1762    0.8384   0.1739 -1.013    0.311
INFCTN  0.1192    1.1266   0.1912  0.624    0.533
       exp(coef) exp(-coef) lower .95 upper .95
TRT       1.3382     0.7473    0.9436     1.898
DENS      0.8384     1.1927    0.5963     1.179
INFCTN    1.1266     0.8876    0.7746     1.639
Rsquare= 0.024   (max possible= 0.999 )
Likelihood ratio test= 4.12  on 3 df,   p=0.2486
Wald test            = 4.12  on 3 df,   p=0.2485
Score (logrank) test = 4.15  on 3 df,   p=0.2460
 
 
Cox Proportional Hazards Model 09:01 Friday, April 1, 2011 1
Example 22.2: Hyalurise in Vitreous Hemorrhage
The PHREG Procedure
Model Information
Data Set WORK.VITCLEAR
Dependent Variable RSPTIM
Censoring Variable CENS
Censoring Value(s) 0
Ties Handling EFRON
 
Number of Observations Read 143
Number of Observations Used 143
 
Summary of the Number of Event and Censored Values
Percent
Stratum CENTER Total Event Censored Censored
1 A 60 45 15 25.00
2 B 37 30 7 18.92
3 C 46 39 7 15.22
---
Total 143 114 29 20.28
 
Convergence Status
Convergence criterion (GCONV=1E-8) satisfied.
 
 
 
Cox Proportional Hazards Model 09:01 Friday, April 1, 2011 2
Example 22.2: Hyalurise in Vitreous Hemorrhage
The PHREG Procedure
Model Fit Statistics
Without With
Criterion Covariates Covariates
-2 LOG L 711.142 706.171
AIC 711.142 712.171
SBC 711.142 720.379
 
Testing Global Null Hypothesis: BETA=0
Test Chi-Square DF Pr  ChiSq
Likelihood Ratio 4.9712 3 0.1739
Score 4.9604 3 0.1747
Wald 4.9151 3 0.1781
 
Analysis of Maximum Likelihood Estimates
Parameter Standard Hazard
Parameter DF Estimate Error Chi-Square Pr  ChiSq Ratio
TRT 1 0.34437 0.19562 3.0988 0.0783 1.411
DENS 1 -0.23832 0.19585 1.4807 0.2237 0.788
INFCTN 1 0.12819 0.27780 0.2129 0.6445 1.137
 
 
[[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] Syntax coloring in R console

2011-04-01 Thread January Weiner
Dear Liviu,

thanks for the programming tip! However, I do all my editing in vim,
which has had syntax highlighting for quite a while, as well as
auto-completion and a number of other goodies. But while I do most of
my programing in vim, I do most of my scientific studies simply using
the R interface and keeping a manually edited lab book apart from
the scripts. Clearly, one can do as much with Rstudio -- I just don't
see any advantages, but I do see a disadvantage in my specific case:
all sub-windows are confined to the desktop. In other words, having
multiple plots on one monitor and a terminal with R command line is
not possible.

A question, though. Given that I have projects assorted in various
directories, how can I start RStudio opening a project stored in
.RData and .Rhistory of a given directory? I.e., how can I make
RStudio open the current directory (like R does), and not $HOME?

Thanks nonetheless,

j.


On Fri, Apr 1, 2011 at 4:20 PM, Liviu Andronic landronim...@gmail.com wrote:
 On Fri, Apr 1, 2011 at 3:48 PM, January Weiner
 january.wei...@mpiib-berlin.mpg.de wrote:
 RStudio might be a fine program, but it does not feature syntax
 highlighting, which is the only thing I am missing from R Console (it
 only colors the commands typed).

 The idea is that you shouldn't use the R console for you main
 programming needs, but only for quick and dirty checks. For the bulk
 of programming tasks you are invited to use the integrated editor
 (File  New  Script). The editor window does feature syntax
 highlighting, and a very helpful completion mechanism (via tab).
 Sending lines for execution to the terminal is as easy as clicking
 'run lines' or ctrl+enter. If you're not a fan of keeping scripts for
 your projects you can easily use temporary files that you don't save.


 Moreover, the very idea of squeezing
 all R windows into one window-desktop would be counterproductive in
 my particular case.

 Notice that all panes are freely resizable and can be resized to the
 point of becoming hidden. Future releases will give more control over
 the panes layout (I think).

 Regards
 Liviu


 Thank you anyways!

 j.



 [1] http://alternativeto.net/software/rstudio/about

 Regards
 Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology
 Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : www.mpiib-berlin.mpg.de
 Tel     : +49-30-28460514

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




-- 
 Dr. January Weiner 3 --
Max Planck Institute for Infection Biology
Charitéplatz 1
D-10117 Berlin, Germany
Web   : www.mpiib-berlin.mpg.de
Tel     : +49-30-28460514

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

Re: [R] regression line on boxplots

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 11:24 AM, Yan Jiao wrote:


boxplot(c(1:3),c(4:6),c(5:8))




 df - structure(list(grp = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3),
  val = c(1L, 2L, 3L, 4L, 5L, 6L, 5L, 6L, 7L, 8L)),
 .Names = c(grp, val),
 row.names = c(NA, -10L),
 class = data.frame)

 boxplot(val~grp,data=df)
 lm(val~grp, data=df)

#Call:
#lm(formula = val ~ grp, data = df)

#Coefficients:
#(Intercept)  grp
#0.04348  2.21739

 ?abline
 abline(reg=lm(val~grp, data=df) )

--

David Winsemius, MD
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] regression line on boxplots

2011-04-01 Thread Bernd Weiss

Am 01.04.2011 11:24, schrieb Yan Jiao:

Dear R users,

I'm trying to add a regression line on my boxplots (something
like:boxplot(c(1:3),c(4:6),c(5:8))) But I can't see it. Please help
!!! It's not a April fool's joke!!!


Your sample data does not make any sense (at least to me). I would do it 
as follows:


set.seed(8)
df - data.frame(y = rnorm(100), x = factor(rep(1:4)))
boxplot(y ~ x, data = df)
regline - lm(y ~ as.numeric(x), data = df)
abline(regline)

HTH,

Bernd

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


Re: [R] Syntax coloring in R console

2011-04-01 Thread Bert Gunter
Please move this thread off r-help. It's about Rstudio, not R.

-- Bert

On Fri, Apr 1, 2011 at 8:05 AM, January Weiner
january.wei...@mpiib-berlin.mpg.de wrote:
 Dear Liviu,

 thanks for the programming tip! However, I do all my editing in vim,
 which has had syntax highlighting for quite a while, as well as
 auto-completion and a number of other goodies. But while I do most of
 my programing in vim, I do most of my scientific studies simply using
 the R interface and keeping a manually edited lab book apart from
 the scripts. Clearly, one can do as much with Rstudio -- I just don't
 see any advantages, but I do see a disadvantage in my specific case:
 all sub-windows are confined to the desktop. In other words, having
 multiple plots on one monitor and a terminal with R command line is
 not possible.

 A question, though. Given that I have projects assorted in various
 directories, how can I start RStudio opening a project stored in
 .RData and .Rhistory of a given directory? I.e., how can I make
 RStudio open the current directory (like R does), and not $HOME?

 Thanks nonetheless,

 j.


 On Fri, Apr 1, 2011 at 4:20 PM, Liviu Andronic landronim...@gmail.com wrote:
 On Fri, Apr 1, 2011 at 3:48 PM, January Weiner
 january.wei...@mpiib-berlin.mpg.de wrote:
 RStudio might be a fine program, but it does not feature syntax
 highlighting, which is the only thing I am missing from R Console (it
 only colors the commands typed).

 The idea is that you shouldn't use the R console for you main
 programming needs, but only for quick and dirty checks. For the bulk
 of programming tasks you are invited to use the integrated editor
 (File  New  Script). The editor window does feature syntax
 highlighting, and a very helpful completion mechanism (via tab).
 Sending lines for execution to the terminal is as easy as clicking
 'run lines' or ctrl+enter. If you're not a fan of keeping scripts for
 your projects you can easily use temporary files that you don't save.


 Moreover, the very idea of squeezing
 all R windows into one window-desktop would be counterproductive in
 my particular case.

 Notice that all panes are freely resizable and can be resized to the
 point of becoming hidden. Future releases will give more control over
 the panes layout (I think).

 Regards
 Liviu


 Thank you anyways!

 j.



 [1] http://alternativeto.net/software/rstudio/about

 Regards
 Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology
 Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : www.mpiib-berlin.mpg.de
 Tel     : +49-30-28460514

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology
 Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : 

Re: [R] Syntax coloring in R console

2011-04-01 Thread Liviu Andronic
On Fri, Apr 1, 2011 at 5:05 PM, January Weiner
january.wei...@mpiib-berlin.mpg.de wrote:
 Dear Liviu,

 thanks for the programming tip! However, I do all my editing in vim,
 which has had syntax highlighting for quite a while, as well as
 auto-completion and a number of other goodies. But while I do most of
 my programing in vim,

For info, vim has plug-in for R.


 I do most of my scientific studies simply using
 the R interface and keeping a manually edited lab book apart from
 the scripts. Clearly, one can do as much with Rstudio -- I just don't
 see any advantages, but I do see a disadvantage in my specific case:
 all sub-windows are confined to the desktop. In other words, having
 multiple plots on one monitor and a terminal with R command line is
 not possible.

I see. This would be more of a hack, but you could use playwith as an
external graphics device. Otherwise, there seems to be an easy hack:

 x11()
 plot(1:10)


 A question, though. Given that I have projects assorted in various
 directories, how can I start RStudio opening a project stored in
 .RData and .Rhistory of a given directory? I.e., how can I make
 RStudio open the current directory (like R does), and not $HOME?

This is a known issue and the RStudio devels plan to address this.
Currently I simply open RStudio in $HOME (and make sure that there is
no existent .RData there), then open the .RData from my project's
directory (by clicking on it in the right-hand Files pane) and then in
the same pane I hit More  Set as working dir. A bit cumbersome, but
seems to work, and a small price to pay for all the available
functionality.

Regards
Liviu


 Thanks nonetheless,

 j.


 On Fri, Apr 1, 2011 at 4:20 PM, Liviu Andronic landronim...@gmail.com wrote:
 On Fri, Apr 1, 2011 at 3:48 PM, January Weiner
 january.wei...@mpiib-berlin.mpg.de wrote:
 RStudio might be a fine program, but it does not feature syntax
 highlighting, which is the only thing I am missing from R Console (it
 only colors the commands typed).

 The idea is that you shouldn't use the R console for you main
 programming needs, but only for quick and dirty checks. For the bulk
 of programming tasks you are invited to use the integrated editor
 (File  New  Script). The editor window does feature syntax
 highlighting, and a very helpful completion mechanism (via tab).
 Sending lines for execution to the terminal is as easy as clicking
 'run lines' or ctrl+enter. If you're not a fan of keeping scripts for
 your projects you can easily use temporary files that you don't save.


 Moreover, the very idea of squeezing
 all R windows into one window-desktop would be counterproductive in
 my particular case.

 Notice that all panes are freely resizable and can be resized to the
 point of becoming hidden. Future releases will give more control over
 the panes layout (I think).

 Regards
 Liviu


 Thank you anyways!

 j.



 [1] http://alternativeto.net/software/rstudio/about

 Regards
 Liviu


 I tried JGR, the GUI for R, but I have found the following problems
 with this package:

 - I was not able to change the background color from a repulsive grey,
 - apparently, GNU readline is not implemented in that package, that
 is, there is no functionality similar to ctrl-r (which searches
 through the history for matching commands), something I use
 frequently, and
 - tab expansion is of limited use (e.g. doesn't browse files in the
 current directory when expanding quoted arguments e.g. in
 read.table).

 All in all, I'd be happy to continue using the plain R console, but
 syntax highlighting would be nice. Any advice would be extremely
 welcome.

 Kind regards,

 January



 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i486-pc-linux-gnu (32-bit)

 locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
  [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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


 --

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




 --
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail




 --
  Dr. January Weiner 3 --
 Max Planck Institute for Infection Biology
 Charitéplatz 1
 D-10117 Berlin, Germany
 Web   : www.mpiib-berlin.mpg.de
 Tel     : +49-30-28460514

 __
 R-help@r-project.org mailing list
 

Re: [R] ANCOVA for linear regressions without intercept

2011-04-01 Thread Peter Ehlers

See inline.

On 2011-03-31 22:22, Yusuke Fukuda wrote:

Thanks Bert.

I have read ?formula again and again, and I'm still struggling;


lm(body_length ~ head_length-1)


This removes intercept from each individual regression (for male, female, 
unknown).

When they are taken together,


lm(body_length ~ sex*head_length)


This shows differences in slopes and intercepts between the regressions (but I 
want to compare the slopes of the regressions WITHOUT intercepts).

If I put


lm(body_length ~ sex:head_length-1)


This shows slopes for each sex without intercepts, but NOT differences in the 
slope between the regressions.


You probably want:

 lm(body_length ~ head_length + sex:head_length-1)

or, in short form:

 lm(body_length ~ head_length/sex-1)

You might then compare the model 'without intercepts'
(i.e. with intercepts forced to zero) with a model that
includes intercepts. If the intercepts turn out to
be significantly nonzero, what will you do?

Peter Ehlers



I also tried


lm(body_length ~ sex*head_length-1)
lm(body_length ~ sex*head_length-sex-1)


But none of them worked.

Would anyone be able to help me? All I want to do is to compare the slopes of 
three linear regressions that go through the origin (0,0) so that I can say if 
their difference is significant or not.

Thanks for your help.




From: Bert Gunter [mailto:gunter.ber...@gene.com]
Sent: Friday, 1 April 2011 12:56 AM
To: Yusuke Fukuda
Cc: r-help@r-project.org
Subject: Re: [R] ANCOVA for linear regressions without intercept

If you haven't already received an answer, a careful reading of

?formula

will provide it.

-- Bert
On Wed, Mar 30, 2011 at 11:42 PM, Yusuke Fukudayusuke.fuk...@nt.gov.au  wrote:

Hello R experts

I have two linear regressions for sexes (Male, Female, Unknown). All have a 
good correlation between body length (response variable) and head length 
(explanatory variable). I know it is not recommended, but for a good practical 
reason (the purpose of study is to find a single conversion factor from head 
length to body length), the regressions need to go through the origin (0 
intercept).

Is it possible to do ANCOVA for these regressions without intercepts? When I do

summary(lm(body length ~ sex*head length))

this will include the intercepts as below


Coefficients:
   Estimate Std. Error t value Pr(|t|)
(Intercept)-6.496971.68497  -3.856 0.000118 ***
sexMale-9.393401.97760  -4.750 2.14e-06 ***
sexUnknown -1.337912.35453  -0.568 0.569927
head_length 7.123070.05503 129.443  2e-16 ***
sexMale:head_length 0.316310.06246   5.064 4.37e-07 ***
sexUnknown:head_length  0.199370.07022   2.839 0.004556 **
---

Is there any way I can remove the intercepts so that I can simply compare the 
slopes with no intercept taken into account?

Thanks for help in advance.

Yusuke Fukuda

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Linear Model with curve fitting parameter?

2011-04-01 Thread Peter Ehlers

On 2011-04-01 05:44, stephen sefick wrote:

Setting Z=Q-A would be the incorrect dimensions.  I could Z=Q/A.  Is
fitting a nls model the same as fitting an ols?  These data are
hydraulic data from ~47 sites.  To access predictive ability I am
removing one site fitting a new model and then accessing the fit with
a myriad of model assessment criteria.  I should get the same answer
with ols vs nls?  Thank you for all of your help.


No, ols and nls won't give the same result.
If you use ols on the logged data, you're assuming
additive errors on the log scale. With nls, you
assume additive errors on the original scale.
But your model looks simple enough - why not run
it through both functions and see what the difference is.
Ultimately, everything depends on what assumptions
you're comfortable with.

Peter Ehlers



Stephen

On Thu, Mar 31, 2011 at 8:34 PM, Steven McKinneysmckin...@bccrc.ca  wrote:



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of stephen sefick
Sent: March-31-11 3:38 PM
To: R help
Subject: [R] Linear Model with curve fitting parameter?

I have a model Q=K*A*(R^r)*(S^s)

A, R, and S are data I have and K is a curve fitting parameter.  I
have linearized as

log(Q)=log(K)+log(A)+r*log(R)+s*log(S)

I have taken the log of the data that I have and this is the model
formula without the K part

lm(Q~offset(A)+R+S, data=x)

What is the formula that I should use?


Let Z = Q - A for your logged data.

Fitting lm(Z ~ R + S, data = x) should yield
intercept parameter estimate = estimate for log(K)
R coefficient parameter estimate = estimate for r
S coefficient parameter estimate = estimate for s



Steven McKinney

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





Thanks for all of your help.  I can provide a subset of data if necessary.



--
Stephen Sefick

| Auburn University |
| Biological Sciences  |
| 331 Funchess Hall   |
| Auburn, Alabama |
| 36849   |
|___|
| sas0...@auburn.edu  |
| http://www.auburn.edu/~sas0025 |
|___|

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

 -K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

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








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


[R] R/Finance 2011 Conference Agenda

2011-04-01 Thread Jeff Ryan
R community:

We're excited to post a preliminary agenda for the upcoming 3rd
conference on R and Applied Finance, to be held in Chicago on April
29th and 30th.

In addition to keynotes from John Bollinger, Mebane Faber, Stefano
Iacus and Louis Kates, we are excited to have 31 additional talks
covering the state of R and applied finance.

This represents a phenomenal opportunity to meet and interact with
some of the leading contributors in the field of finance, all with
relevant contributions using R.  We expect more than 200 participants
from industry, government, and academia for the 2 day event.  In
addition, a conference dinner Friday evening in the heart of the
financial district along Chicago's picturesque river will offer an
unprecedented opportunity to enjoy amazing food, drink and
conversation.

http://www.rinfinance.com/agenda/index.html

Registration is open, though pre-conference workshops are rapidly filling up.

Register now and join your fellow colleagues at R/Finance 2011!
http://www.rinfinance.com/register/



Thanks to our 2011 Co-Sponsors and Sponsors:

  International Center for Futures and Derivatives at UIC
  REvolution Analytics

  OneMarketData
  RStudio
  lemnica

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 paste a vector of expressions and a character vector?

2011-04-01 Thread Marius Hofert
Dear expeRts,

I know I can't paste expressions in the normal way, but I just couldn't figure 
out 
how to get the following (I want to paste a character vector to an expression 
vector)
right with bquote() or substitute.

vec1 - c(a, expression(tilde(b)), c)
vec2 - c(1, 2, 3)
main - as.expression(paste(vec1, vec2))
plot(0,0, main=main[2])

Cheers,

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


Re: [R] regular expression

2011-04-01 Thread array chip
Great. thank you Bernd! Learned a new thing here.

John





From: Bernd Weiss bernd.we...@uni-koeln.de

Cc: r-help@r-project.org
Sent: Thu, March 31, 2011 6:19:25 PM
Subject: Re: [R] regular expression

Am 31.03.2011 21:06, schrieb array chip:
 Ok then this code didn't do what I wanted. I want not including
 'arg' before '.symptom', not individual letters of arg, but rather
 as a word.
 
 Bill Dunlap suggested using invert=T, it works for single 1
 condition, but not for 2 conditions here: not including arg before
 ., but at the same time, does include .symptom.
 
 Any other suggestions would be appreciated

This does work (but I am by no means an expert in regex...). I am using 
'negative lookbehind'[1] to define an expression like 'arg'.

 grep('(?!(arg))\\.symptom',arg.symptom,value=T, perl = T)
character(0)

 grep('(?!(arg))\\.symptom',liver.symptom,value=T, perl = T)
[1] liver.symptom

Bernd

[1] http://www.regular-expressions.info/lookaround.html

[[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] regular expression

2011-04-01 Thread Henrique Dallazuanna
Try this also:

 grep(arg, arg.symptom, value = TRUE, invert = TRUE)
character(0)
 grep(arg, liver.symptom, value = TRUE, invert = TRUE)
[1] liver.symptom



On Fri, Apr 1, 2011 at 1:33 PM, array chip arrayprof...@yahoo.com wrote:
 Great. thank you Bernd! Learned a new thing here.

 John




 
 From: Bernd Weiss bernd.we...@uni-koeln.de

 Cc: r-help@r-project.org
 Sent: Thu, March 31, 2011 6:19:25 PM
 Subject: Re: [R] regular expression

 Am 31.03.2011 21:06, schrieb array chip:
 Ok then this code didn't do what I wanted. I want not including
 'arg' before '.symptom', not individual letters of arg, but rather
 as a word.

 Bill Dunlap suggested using invert=T, it works for single 1
 condition, but not for 2 conditions here: not including arg before
 ., but at the same time, does include .symptom.

 Any other suggestions would be appreciated

 This does work (but I am by no means an expert in regex...). I am using
 'negative lookbehind'[1] to define an expression like 'arg'.

 grep('(?!(arg))\\.symptom',arg.symptom,value=T, perl = T)
 character(0)

 grep('(?!(arg))\\.symptom',liver.symptom,value=T, perl = T)
 [1] liver.symptom

 Bernd

 [1] http://www.regular-expressions.info/lookaround.html

        [[alternative HTML version deleted]]

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




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

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

2011-04-01 Thread Jim Silverton
I have a matrix with 2 columns and I want to do fishers exact test for these
with the totals for each row being 100 say.

The data has the form:
23  12
32  21
12  2

and these represents the tables:

23 12
77 88

32  21
78  79

12   2
88  98


How do I use apply to speed up aclculation of the fisher.exact test?

-- 
Thanks,
Jim.

[[alternative HTML version deleted]]

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


[R] mean in the boxplot

2011-04-01 Thread Yan Jiao
Dear R users,

How to show mean in the boxplot instead of median ?

Many thanks

Yan

[[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 paste a vector of expressions and a character vector?

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:


Dear expeRts,

I know I can't paste expressions in the normal way, but I just  
couldn't figure out
how to get the following (I want to paste a character vector to an  
expression vector)

right with bquote() or substitute.

vec1 - c(a, expression(tilde(b)), c)
vec2 - c(1, 2, 3)
main - as.expression(paste(vec1, vec2))
plot(0,0, main=main[2])


Do not use `paste` ... it coerces your expression to a character  
value ... use `c` instead:


 main - as.expression(c(vec1, vec2))
 plot(1,1, main=main[2])

And then, even the as.expression is superfluous:

 main - c(vec1, vec2)
 plot(1,1, main=main[2])

--

David Winsemius, MD
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] mean in the boxplot

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 1:20 PM, Yan Jiao wrote:


Dear R users,

How to show mean in the boxplot instead of median ?


Read ... help(boxplot)

Use boxplot to create a set of values, substitute th emean for the  
groups then pass the mangled set of values to bxp().


--

David Winsemius, MD
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] How to paste a vector of expressions and a character vector?

2011-04-01 Thread Marius Hofert
Dear David,

thanks for your reply. The paste() meant to paste the vectors vec1 and vec2 
together, so main should be a vector of length 3 of the form
a 1, b 2, c 3 # with b being tilde(b)
However, with c() it is a vector of length 6:
expression(a, tilde(b), c, 1, 2, 3)

Do you know a solution for that?

Cheers,

Marius

On 2011-04-01, at 19:22 , David Winsemius wrote:

 
 On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:
 
 Dear expeRts,
 
 I know I can't paste expressions in the normal way, but I just couldn't 
 figure out
 how to get the following (I want to paste a character vector to an 
 expression vector)
 right with bquote() or substitute.
 
 vec1 - c(a, expression(tilde(b)), c)
 vec2 - c(1, 2, 3)
 main - as.expression(paste(vec1, vec2))
 plot(0,0, main=main[2])
 
 Do not use `paste` ... it coerces your expression to a character value ... 
 use `c` instead:
 
  main - as.expression(c(vec1, vec2))
  plot(1,1, main=main[2])
 
 And then, even the as.expression is superfluous:
 
  main - c(vec1, vec2)
  plot(1,1, main=main[2])
 
 -- 
 
 David Winsemius, MD
 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] How to paste a vector of expressions and a character vector?

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 1:56 PM, Marius Hofert wrote:


Dear David,

thanks for your reply. The paste() meant to paste the vectors vec1  
and vec2 together, so main should be a vector of length 3 of the form

a 1, b 2, c 3 # with b being tilde(b)
However, with c() it is a vector of length 6:
expression(a, tilde(b), c, 1, 2, 3)


 lls -c(a, tilde(b),c)
 mains - bquote(.(parse(text=paste(lls,~,nns,sep=))) )
 mains

#expression(a~1, tilde(b)~2, c~3)
#attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3
#-

 mains[2]
#expression(tilde(b)~2)


plot(0,0, main=mains[2])


This would also work:

 mains2 - as.expression(parse(text=paste(lls,~,nns,sep=)))
 mains2
expression(a~1, tilde(b)~2, c~3)
attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3

I try to avoid using spaces in expressions and instead use ~'s   
because I don't really understand how spaces get parsed in expression  
operations, and I do know how plotmath operations work with ~.




Do you know a solution for that?

Cheers,

Marius

On 2011-04-01, at 19:22 , David Winsemius wrote:



On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:


Dear expeRts,

I know I can't paste expressions in the normal way, but I just  
couldn't figure out
how to get the following (I want to paste a character vector to an  
expression vector)

right with bquote() or substitute.

vec1 - c(a, expression(tilde(b)), c)
vec2 - c(1, 2, 3)
main - as.expression(paste(vec1, vec2))
plot(0,0, main=main[2])


Do not use `paste` ... it coerces your expression to a character  
value ... use `c` instead:



main - as.expression(c(vec1, vec2))
plot(1,1, main=main[2])


And then, even the as.expression is superfluous:


main - c(vec1, vec2)
plot(1,1, main=main[2])


--

David Winsemius, MD
West Hartford, CT





David Winsemius, MD
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] How to paste a vector of expressions and a character vector?

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 2:34 PM, David Winsemius wrote:



On Apr 1, 2011, at 1:56 PM, Marius Hofert wrote:


Dear David,

thanks for your reply. The paste() meant to paste the vectors vec1  
and vec2 together, so main should be a vector of length 3 of the form

a 1, b 2, c 3 # with b being tilde(b)
However, with c() it is a vector of length 6:
expression(a, tilde(b), c, 1, 2, 3)




Forgot one variable, nns:


lls -c(a, tilde(b),c)

nns -1:3

mains - bquote(.(parse(text=paste(lls,~,nns,sep=))) )
mains

#expression(a~1, tilde(b)~2, c~3)
#attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3
#-

 mains[2]
#expression(tilde(b)~2)


plot(0,0, main=mains[2])


This would also work:

 mains2 - as.expression(parse(text=paste(lls,~,nns,sep=)))
 mains2
expression(a~1, tilde(b)~2, c~3)
attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3

I try to avoid using spaces in expressions and instead use ~'s   
because I don't really understand how spaces get parsed in  
expression operations, and I do know how plotmath operations work  
with ~.




Do you know a solution for that?

Cheers,

Marius

On 2011-04-01, at 19:22 , David Winsemius wrote:



On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:


Dear expeRts,

I know I can't paste expressions in the normal way, but I just  
couldn't figure out
how to get the following (I want to paste a character vector to  
an expression vector)

right with bquote() or substitute.

vec1 - c(a, expression(tilde(b)), c)
vec2 - c(1, 2, 3)
main - as.expression(paste(vec1, vec2))
plot(0,0, main=main[2])


Do not use `paste` ... it coerces your expression to a character  
value ... use `c` instead:



main - as.expression(c(vec1, vec2))
plot(1,1, main=main[2])


And then, even the as.expression is superfluous:


main - c(vec1, vec2)
plot(1,1, main=main[2])


--

David Winsemius, MD
West Hartford, CT





David Winsemius, MD
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.


David Winsemius, MD
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] How to paste a vector of expressions and a character vector?

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 2:34 PM, David Winsemius wrote:



On Apr 1, 2011, at 1:56 PM, Marius Hofert wrote:


Dear David,

thanks for your reply. The paste() meant to paste the vectors vec1  
and vec2 together, so main should be a vector of length 3 of the form

a 1, b 2, c 3 # with b being tilde(b)
However, with c() it is a vector of length 6:
expression(a, tilde(b), c, 1, 2, 3)


lls -c(a, tilde(b),c)

nns - 1:3

#Even easier would be:

 mains3 - parse(text=paste(lls,~,nns,sep=))
 mains3
expression(a~1, tilde(b)~2, c~3)
attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3





 mains - bquote(.(parse(text=paste(lls,~,nns,sep=))) )
mains

#expression(a~1, tilde(b)~2, c~3)
#attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3
#-

 mains[2]
#expression(tilde(b)~2)


plot(0,0, main=mains[2])


This would also work:

 mains2 - as.expression(parse(text=paste(lls,~,nns,sep=)))
 mains2
expression(a~1, tilde(b)~2, c~3)
attr(,srcfile)
text
attr(,wholeSrcref)
a~1
tilde(b)~2
c~3

I try to avoid using spaces in expressions and instead use ~'s   
because I don't really understand how spaces get parsed in  
expression operations, and I do know how plotmath operations work  
with ~.




Do you know a solution for that?

Cheers,

Marius

On 2011-04-01, at 19:22 , David Winsemius wrote:



On Apr 1, 2011, at 12:32 PM, Marius Hofert wrote:


Dear expeRts,

I know I can't paste expressions in the normal way, but I just  
couldn't figure out
how to get the following (I want to paste a character vector to  
an expression vector)

right with bquote() or substitute.

vec1 - c(a, expression(tilde(b)), c)
vec2 - c(1, 2, 3)
main - as.expression(paste(vec1, vec2))
plot(0,0, main=main[2])


Do not use `paste` ... it coerces your expression to a character  
value ... use `c` instead:



main - as.expression(c(vec1, vec2))
plot(1,1, main=main[2])


And then, even the as.expression is superfluous:


main - c(vec1, vec2)
plot(1,1, main=main[2])


--

David Winsemius, MD
West Hartford, CT





David Winsemius, MD
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.


David Winsemius, MD
West Hartford, CT

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


[R] filled contour plot with contour lines

2011-04-01 Thread Steve_Friedman

I'm stumped,  can anyone find my error in this sequence.

 for(j in 1:(varsize[4]-1))
  temp - get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
 filled.contour(x, y, temp, color = terrain.colors,
 plot.title = title(main = paste(Everglades Wood Stork
Foraging Potential \nYear, (2000+j)),
 xlab = UTM East, ylab = UTM North) ,
 plot.axes = { contour(temp, add=T)
axis(1, seq(45 , 58, by = 1))
axis(2, seq(280,400, by = 1)) },
 key.title = title(main=Probability) ,
 key.axes = axis(4, seq(0 , 1 , by = 0.1))


The routine will work in a modified form without adding the coordinates
(the axis lines) but when I include these the routine produces various
errors, such as dimension mismatch, or unexpected end encountered.

I tried to follow the example on filled.contour help page.

Thanks in advance
   Steve

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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


Re: [R] Linear Model with curve fitting parameter?

2011-04-01 Thread Steven McKinney

 -Original Message-
 From: stephen sefick [mailto:ssef...@gmail.com]
 Sent: April-01-11 5:44 AM
 To: Steven McKinney
 Cc: R help
 Subject: Re: [R] Linear Model with curve fitting parameter?
 
 Setting Z=Q-A would be the incorrect dimensions.  I could Z=Q/A.  

I suspect this is confusion about what Q is.  I was presuming that
the Q in this following formula was log(Q) with Q from the original data.

  I have taken the log of the data that I have and this is the model
  formula without the K part
 
  lm(Q~offset(A)+R+S, data=x)

If the model is 
  
   Q=K*A*(R^r)*(S^s)

then

   log(Q) = log(K) + log(A) + r*log(R) + s*log(S)

Rearranging yields

   log(Q) - log(A) = log(K) + r*log(R) + s*log(S)

so what I labeled 'Z' below is

   Z = log(Q) - log(A) = log(Q/A)

so

   Z = log(K) + r*log(R) + s*log(S)

and a linear model fit of
   
   Z ~ log(R) + log(S)

will yield parameter estimates for the linear equation

   E(Z) = B0 + B1*log(R) + B2*log(S)

(E(Z) = expected value of Z)

so B0 estimate is an estimate of log(K)
   B1 estimate is an estimate of r
   B2 estimate is an estimate of s

More details and careful notation will eventually lead
to a reasonable description and analysis strategy.


Best

Steve McKinney



 Is fitting a nls model the same as fitting an ols?  These data are
 hydraulic data from ~47 sites.  To access predictive ability I am
 removing one site fitting a new model and then accessing the fit with
 a myriad of model assessment criteria.  I should get the same answer
 with ols vs nls?  Thank you for all of your help.
 
 Stephen
 
 On Thu, Mar 31, 2011 at 8:34 PM, Steven McKinney smckin...@bccrc.ca wrote:
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
  On Behalf Of stephen
 sefick
  Sent: March-31-11 3:38 PM
  To: R help
  Subject: [R] Linear Model with curve fitting parameter?
 
  I have a model Q=K*A*(R^r)*(S^s)
 
  A, R, and S are data I have and K is a curve fitting parameter.  I
  have linearized as
 
  log(Q)=log(K)+log(A)+r*log(R)+s*log(S)
 
  I have taken the log of the data that I have and this is the model
  formula without the K part
 
  lm(Q~offset(A)+R+S, data=x)
 
  What is the formula that I should use?
 
  Let Z = Q - A for your logged data.
 
  Fitting lm(Z ~ R + S, data = x) should yield
  intercept parameter estimate = estimate for log(K)
  R coefficient parameter estimate = estimate for r
  S coefficient parameter estimate = estimate for s
 
 
 
  Steven McKinney
 
  Statistician
  Molecular Oncology and Breast Cancer Program
  British Columbia Cancer Research Centre
 
 
 
 
  Thanks for all of your help.  I can provide a subset of data if necessary.
 
 
 
  --
  Stephen Sefick
  
  | Auburn University                                         |
  | Biological Sciences                                      |
  | 331 Funchess Hall                                       |
  | Auburn, Alabama                                         |
  | 36849                                                           |
  |___|
  | sas0...@auburn.edu                                  |
  | http://www.auburn.edu/~sas0025                 |
  |___|
 
  Let's not spend our time and resources thinking about things that are
  so little or so large that all they really do for us is puff us up and
  make us feel like gods.  We are mammals, and have not exhausted the
  annoying little problems of being mammals.
 
                                  -K. Mullis
 
  A big computer, a complex algorithm and a long time does not equal 
  science.
 
                                -Robert Gentleman
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 --
 Stephen Sefick
 
 | Auburn University                                         |
 | Biological Sciences                                      |
 | 331 Funchess Hall                                       |
 | Auburn, Alabama                                         |
 | 36849                                                           |
 |___|
 | sas0...@auburn.edu                                  |
 | http://www.auburn.edu/~sas0025                 |
 |___|
 
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 
                                 -K. Mullis
 
 A big computer, a complex algorithm and a long time does not equal science.
 
                               

Re: [R] Fisher's test

2011-04-01 Thread Peter Ehlers

On 2011-04-01 10:19, Jim Silverton wrote:

I have a matrix with 2 columns and I want to do fishers exact test for these
with the totals for each row being 100 say.

The data has the form:
23  12
32  21
12  2

and these represents the tables:

23 12
77 88

32  21
78  79

12   2
88  98


How do I use apply to speed up aclculation of the fisher.exact test?



 apply(yourMatrix, 1, function(x) fisher.test(cbind(x, 100 - x)))

or, if you only want the P-value:

 apply(yourMatrix, 1,
   function(x) fisher.test(cbind(x, 100 - x))$p.value)

Peter Ehlers

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


Re: [R] lattice xscale.components: different ticks on top/bottom axis

2011-04-01 Thread Boris.Vasiliev

 On Fri, Mar 11, 2011 at 12:28 AM,  
 boris.vasil...@forces.gc.ca wrote:
  Good afternoon,
 
  I am trying to create a plot where the bottom and top axes have the 
  same scale but different tick marks.  I tried user-defined 
  xscale.component function but it does not produce desired results.  
  Can anybody suggest where my use of xscale.component 
  function is incorrect?
 
  For example, the code below tries to create a plot where horizontal 
  axes limits are c(0,10), top axis has ticks at odd integers, and 
  bottom axis has ticks at even integers.
 
  library(lattice)
 
  df - data.frame(x=1:10,y=1:10)
 
  xscale.components.A - function(...,user.value=NULL) {
   # get default axes definition list; print user.value
   ans - xscale.components.default(...)
   print(user.value)
 
   # start with the same definition of bottom and top axes
   ans$top - ans$bottom
 
   # - bottom labels
   ans$bottom$labels$at - seq(0,10,by=2)
   ans$bottom$labels$labels - paste(B,seq(0,10,by=2),sep=-)
 
   # - top labels
   ans$top$labels$at - seq(1,9,by=2)
   ans$top$labels$labels - paste(T,seq(1,9,by=2),sep=-)
 
   # return axes definition list
   return(ans)
  }
 
  oltc - xyplot(y~x,data=df,
 
  scales=list(x=list(limits=c(0,10),at=0:10,alternating=3)),
                xscale.components=xscale.components.A,
                user.value=1)
  print(oltc)
 
  The code generates a figure with incorrectly placed bottom and top 
  labels.  Bottom labels B-0, B-2, ... are at 0, 1, ... and top 
  labels T-1, T-3, ... are at 0, 1, ...  When axis-function runs out 
  of labels, it replaces labels with NA.
 
  It appears that lattice uses top$ticks$at to place labels and 
  top$labels$labels for labels.  Is there a way to override this 
  behaviour (other than to expand the labels$labels vector to be as 
  long as ticks$at vector and set necessary elements to )?
 
 Well, top|bottom$ticks$at is used to place the ticks, and 
 $labels$at is used to place the labels. They should typically 
 be the same, but you have changed one and not the other. 
 Everything seems to work if you set $ticks$at to the same 
 values as $labels$at:
 
 
 ##  - bottom labels
 +   ans$bottom$ticks$at - seq(0,10,by=2)
 ans$bottom$labels$at - seq(0,10,by=2)
 ans$bottom$labels$labels - paste(B,seq(0,10,by=2),sep=-)
 
 ##  - top labels
 +   ans$top$ticks$at - seq(1,9,by=2)
 ans$top$labels$at - seq(1,9,by=2)
 ans$top$labels$labels - paste(T,seq(1,9,by=2),sep=-)
 
 
  Also, can user-parameter be passed into xscale.components() 
  function? (For example, locations and labels of ticks on the top 
  axis).  In the  code above, print(user.value) returns NULL even 
  though in the xyplot() call user.value is 1.
 
 No. Unrecognized arguments are passed to the panel function 
 only, not to any other function. However, you can always 
 define an inline
 function:
 
 oltc - xyplot(y~x,data=df,
scales=list(x=list(limits=c(0,10), at = 0:10, 
alternating=3)),
xscale.components = function(...) 
xscale.components.A(..., user.value=1))
 
 Hope that helps (and sorry for the late reply).
 
 -Deepayan
 

Deepyan,

Thank you very much for your reply.  It makes things a bit clearer.  

It other words in the list prepared by xscale.components(), vectors 
top|bottom$ticks$at and top|bottom$labels$at must be the same.  If only 
every second tick is to be labelled then every second label should be set 
explicitly to empty strings:

  ans$bottom$ticks$at - seq(0,10,by=1)
  ans$bottom$labels$at - seq(0,10,by=1)
  ans$bottom$labels$labels - paste(B,seq(0,10,by=1),sep=-)
  # replace  B-1, B-3, ... with 
  ans$bottom$labels$labels[seq(2,11,by=2)] - 

Sincerely,
Boris.

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


Re: [R] mean in the boxplot

2011-04-01 Thread Peter Ehlers

On 2011-04-01 10:28, David Winsemius wrote:


On Apr 1, 2011, at 1:20 PM, Yan Jiao wrote:


Dear R users,

How to show mean in the boxplot instead of median ?


Read ... help(boxplot)

Use boxplot to create a set of values, substitute th emean for the
groups then pass the mangled set of values to bxp().



Another option is to add the means as points after
plotting the boxplot with:

  boxplot()
  points(1:n, Means)

This is particularly useful if you want both the
medians and the means on the plot. If you don't
want the median line, you can get rid of it by
setting medcol=transparent in the boxplot() call.

But then again, the whole point of a boxplot is to
represent general distributional shape for which
the median is surely more effective.

Peter Ehlers

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


Re: [R] XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order. -- Resending with corrected .txt file

2011-04-01 Thread Guy Jett
Thank you very much Deepayan.  This does exactly what I needed!
Cheers,
Guy Jett
gj...@itsi.com

-Original Message-
From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com] 
Sent: Friday, April 01, 2011 6:51 AM
To: Guy Jett
Cc: r-help@R-project.org
Subject: Re: [R] XYPlot Conditioning Variable in Specific, Non-Alphanumeric 
Order. -- Resending with corrected .txt file

snip
You need to specify the order of the levels explicitly (to override
the default). Here is how to do it for one, you can similarly do the
other:

 levels(df$Offset)
 [1] T U V Y Z A B C D E F G H
 df$Offset - factor(df$Offset,
+ levels = c(T, U, V, Y, Z, A,
+B, C, D, E, F, G, H))
 levels(df$Offset)
 [1] T U V Y Z A B C D E F G H

Once you make these changes, your original call should work as desired.

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


Re: [R] filled contour plot with contour lines

2011-04-01 Thread Peter Ehlers

Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

 for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:


I'm stumped,  can anyone find my error in this sequence.

  for(j in 1:(varsize[4]-1))
   temp- get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
  filled.contour(x, y, temp, color = terrain.colors,
  plot.title = title(main = paste(Everglades Wood Stork
Foraging Potential \nYear, (2000+j)),
  xlab = UTM East, ylab = UTM North) ,
  plot.axes = { contour(temp, add=T)
 axis(1, seq(45 , 58, by = 1))
 axis(2, seq(280,400, by = 1)) },
  key.title = title(main=Probability) ,
  key.axes = axis(4, seq(0 , 1 , by = 0.1))


The routine will work in a modified form without adding the coordinates
(the axis lines) but when I include these the routine produces various
errors, such as dimension mismatch, or unexpected end encountered.

I tried to follow the example on filled.contour help page.

Thanks in advance
Steve

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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

2011-04-01 Thread Steve_Friedman
Hi Peter,

Thanks for taking the time to consider the problem. I realize the procedure
is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in size to
pull data into this process. Nobody in their right mind should work with
such things. It's a spatial temporal database with 10 years of daily data
in a irregular area spanning 405 x 287 cells.

Anyway, I tried your suggestion adding a { in front of the for loop and a
closing } following the last line.

It did not work.


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147


   
 Peter Ehlers  
 ehlers@ucalgary. 
 caTo 
   steve_fried...@nps.gov
 04/01/2011 05:08  steve_fried...@nps.gov
 PM cc 
   r-help@r-project.org  
   r-help@r-project.org  
   Subject 
   Re: [R] filled contour plot with
   contour lines   
   
   
   
   
   
   




Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

  for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:

 I'm stumped,  can anyone find my error in this sequence.

   for(j in 1:(varsize[4]-1))
temp- get.var.ncdf(nc=input,
 varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
   filled.contour(x, y, temp, color = terrain.colors,
   plot.title = title(main = paste(Everglades Wood Stork
 Foraging Potential \nYear, (2000+j)),
   xlab = UTM East, ylab = UTM North) ,
   plot.axes = { contour(temp, add=T)
  axis(1, seq(45 , 58, by = 1))
  axis(2, seq(280,400, by = 1)) },
   key.title = title(main=Probability) ,
   key.axes = axis(4, seq(0 , 1 , by = 0.1))


 The routine will work in a modified form without adding the coordinates
 (the axis lines) but when I include these the routine produces various
 errors, such as dimension mismatch, or unexpected end encountered.

 I tried to follow the example on filled.contour help page.

 Thanks in advance
 Steve

 Steve Friedman Ph. D.
 Ecologist  / Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax (305) 224 - 4147

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

2011-04-01 Thread array chip
Hi, I tried to pass the function dist() as an argument, but got an error 
message. However, almost the same code with mean() as the function to be 
passed, 
it works ok.

foo-function (x,
xfun = dist) 
{
 xfun(x)
}

foo(matrix(1:100,nrow=5))
Error in foo(matrix(1:100, nrow = 5)) : could not find function xfun


foo-function (x,
 xfun = mean) 
 {
  xfun(x)
 }
 
foo(1:10)
[1] 5.5

what am I missing here?

Thanks

John

[[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] hc2Newick is different than th hclust dendrogram

2011-04-01 Thread Jose Hleap Lozano
Hi R helpers... I am having troubles because of the discrepancy  
between the dendrogram plotted from hclust and what is wrote in the  
hc2Newick file. I've got a matrix C:



hc - hclust(dist(C))
plot(hc)


with the:


write(hc2Newick(hc),file='test.newick')


both things draw completely different trees...

I have also tried with the raw distance matrix D and also the agnes  
function, but the same happens. The hclus and agnes dendrogram is  
logical, whereas the newick tree is not.


Thanks for any help!
--
Jose Sergio Hleap Lozano, M. Sc.
Ph. D. Student, Dalhousie University
Researcher, SQUALUS Foundation

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


Re: [R] filled contour plot with contour lines

2011-04-01 Thread Steve_Friedman
Hi Peter,

Thanks for taking the time to consider the problem. I realize the procedure
is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in size to
pull data into this process. Nobody in their right mind should work with
such things. It's a spatial temporal database with 10 years of daily data
in a irregular area spanning 405 x 287 cells.

Anyway, I tried your suggestion adding a { in front of the for loop and a
closing } following the last line.

It did not work.

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147


   
 Peter Ehlers  
 ehlers@ucalgary. 
 caTo 
   steve_fried...@nps.gov
 04/01/2011 05:08  steve_fried...@nps.gov
 PM cc 
   r-help@r-project.org  
   r-help@r-project.org  
   Subject 
   Re: [R] filled contour plot with
   contour lines   
   
   
   
   
   
   




Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

  for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:

 I'm stumped,  can anyone find my error in this sequence.

   for(j in 1:(varsize[4]-1))
temp- get.var.ncdf(nc=input,
 varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
   filled.contour(x, y, temp, color = terrain.colors,
   plot.title = title(main = paste(Everglades Wood Stork
 Foraging Potential \nYear, (2000+j)),
   xlab = UTM East, ylab = UTM North) ,
   plot.axes = { contour(temp, add=T)
  axis(1, seq(45 , 58, by = 1))
  axis(2, seq(280,400, by = 1)) },
   key.title = title(main=Probability) ,
   key.axes = axis(4, seq(0 , 1 , by = 0.1))


 The routine will work in a modified form without adding the coordinates
 (the axis lines) but when I include these the routine produces various
 errors, such as dimension mismatch, or unexpected end encountered.

 I tried to follow the example on filled.contour help page.

 Thanks in advance
 Steve

 Steve Friedman Ph. D.
 Ecologist  / Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax (305) 224 - 4147

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

2011-04-01 Thread sahin

Hi all,

I have made an overdispersion test for a data set and get the following result

Overdispersion test Obs.Var/Theor.Var Statistic p-value
   poisson data  16.24267  47444.85   0


after deleting the outliers from the data set I get the following result


Overdispersion test Obs.Var/Theor.Var Statistic p-value
   poisson data  16.27106 0   1


The problem is that the overdispersion parameter does not really  
change, but how could the p-value and the statistic change so that the  
null hypothesis is accepted??


I would be very grateful if someone could help me?

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


Re: [R] filled contour plot with contour lines

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 5:38 PM, steve_fried...@nps.gov wrote:


Hi Peter,

Thanks for taking the time to consider the problem. I realize the  
procedure
is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in  
size to
pull data into this process. Nobody in their right mind should work  
with
such things. It's a spatial temporal database with 10 years of daily  
data

in a irregular area spanning 405 x 287 cells.

Anyway, I tried your suggestion adding a { in front of the for loop  
and a

closing } following the last line.


That suggestion was probably intended to get you a more informative  
error message:


for(j in 1:(varsize[4]-1) )
 temp - get.var.ncdf(
   nc=input,
   varid=p_foraging,
   c(1,1,j),
   c(varsize[1],  varsize[2], 1)
)

# I think Peter is correct. That loop will complete before the call to  
filled.contour,

#  so you will only have the last version of temp plot.

filled.contour(x, y, temp, color = terrain.colors,
 plot.title = title( main =
 paste(Everglades Wood Stork Foraging Potential \nYear,  
(2000+j)),


#that double call to title looks incomplete as well. The comma looks  
premature.

# Shouldn't it be something like:
 plot.title = bquote(Everglades Wood Stork Foraging Potential  
\nYear, .(2000+j) )


#(And since the for loop is already complete `j` will not exist.
# Which is probably the source of the error you are getting.)

xlab = UTM East, ylab = UTM North) ,
plot.axes = { contour(temp, add=T)
   axis(1, seq(45 , 58, by = 1))
   axis(2, seq(280,400, by = 1)) },
key.title = title(main=Probability) ,
key.axes = axis(4, seq(0 , 1 , by = 0.1))


It did not work.


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147



Peter Ehlers
ehlers@ucalgary.
 
caTo

  steve_fried...@nps.gov
04/01/2011 05:08  steve_fried...@nps.gov
 
PM cc

  r-help@r-project.org
  r-help@r-project.org
   
Subject

  Re: [R] filled contour plot with
  contour lines










Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

 for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:


I'm stumped,  can anyone find my error in this sequence.

 for(j in 1:(varsize[4]-1))
  temp- get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
 filled.contour(x, y, temp, color = terrain.colors,
 plot.title = title(main = paste(Everglades Wood Stork
Foraging Potential \nYear, (2000+j)),
 xlab = UTM East, ylab = UTM North) ,
 plot.axes = { contour(temp, add=T)
axis(1, seq(45 , 58, by = 1))
axis(2, seq(280,400, by = 1)) },
 key.title = title(main=Probability) ,
 key.axes = axis(4, seq(0 , 1 , by = 0.1))


The routine will work in a modified form without adding the  
coordinates
(the axis lines) but when I include these the routine produces  
various
errors, such as dimension mismatch, or unexpected end  
encountered.


I tried to follow the example on filled.contour help page.

Thanks in advance
   Steve

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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


David Winsemius, MD
West Hartford, CT

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

Re: [R] filled contour plot with contour lines

2011-04-01 Thread Clint Bowman

Steve,

I use filled.contour but have a semicolon, ;, between the two 
axis calls.  Do you need one after


axis(1, seq(45 , 58, by = 1))

?

Clint

--
Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600


USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274


On Fri, 1 Apr 2011, steve_fried...@nps.gov wrote:


Hi Peter,

Thanks for taking the time to consider the problem. I realize the procedure
is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in size to
pull data into this process. Nobody in their right mind should work with
such things. It's a spatial temporal database with 10 years of daily data
in a irregular area spanning 405 x 287 cells.

Anyway, I tried your suggestion adding a { in front of the for loop and a
closing } following the last line.

It did not work.


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147



Peter Ehlers
ehlers@ucalgary.
caTo
  steve_fried...@nps.gov
04/01/2011 05:08  steve_fried...@nps.gov
PM cc
  r-help@r-project.org
  r-help@r-project.org
  Subject
  Re: [R] filled contour plot with
  contour lines










Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

 for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:


I'm stumped,  can anyone find my error in this sequence.

  for(j in 1:(varsize[4]-1))
   temp- get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
  filled.contour(x, y, temp, color = terrain.colors,
  plot.title = title(main = paste(Everglades Wood Stork
Foraging Potential \nYear, (2000+j)),
  xlab = UTM East, ylab = UTM North) ,
  plot.axes = { contour(temp, add=T)
 axis(1, seq(45 , 58, by = 1))
 axis(2, seq(280,400, by = 1)) },
  key.title = title(main=Probability) ,
  key.axes = axis(4, seq(0 , 1 , by = 0.1))


The routine will work in a modified form without adding the coordinates
(the axis lines) but when I include these the routine produces various
errors, such as dimension mismatch, or unexpected end encountered.

I tried to follow the example on filled.contour help page.

Thanks in advance
Steve

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


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



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


Re: [R] function in argument

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 5:56 PM, array chip wrote:

Hi, I tried to pass the function dist() as an argument, but got an  
error
message. However, almost the same code with mean() as the function  
to be passed,

it works ok.

foo-function (x,
   xfun = dist)
{
xfun(x)
}

foo(matrix(1:100,nrow=5))
Error in foo(matrix(1:100, nrow = 5)) : could not find function xfun



Works on my machine.

 foo(matrix(1:100,nrow=5))
  1 2 3 4
2  4.472136
3  8.944272  4.472136
4 13.416408  8.944272  4.472136
5 17.888544 13.416408  8.944272  4.472136


You have probably overwritten `dist` with a non-functional object.

Try rm(dist) and re-run:




foo-function (x,
xfun = mean)
{
 xfun(x)
}

foo(1:10)
[1] 5.5

what am I missing here?


Thinking about your full workspace, I would guess.

--

David Winsemius, MD
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] function in argument

2011-04-01 Thread array chip
OK, I figured it out, need to add stats::: before dist

foo-function (x,
xfun = stats:::dist) 
{
xfun(x)
}


John




To: r-help@r-project.org
Sent: Fri, April 1, 2011 2:56:06 PM
Subject: [R] function in argument

Hi, I tried to pass the function dist() as an argument, but got an error 
message. However, almost the same code with mean() as the function to be 
passed, 

it works ok.

foo-function (x,
xfun = dist) 
{
xfun(x)
}

foo(matrix(1:100,nrow=5))
Error in foo(matrix(1:100, nrow = 5)) : could not find function xfun


foo-function (x,
 xfun = mean) 
{
  xfun(x)
}

foo(1:10)
[1] 5.5

what am I missing here?

Thanks

John

[[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] function in argument

2011-04-01 Thread Henrique Dallazuanna
Or:

foo-function (x, xfun = dist) {
match.fun(xfun)(x)
}

On Fri, Apr 1, 2011 at 7:06 PM, array chip arrayprof...@yahoo.com wrote:
 OK, I figured it out, need to add stats::: before dist

 foo-function (x,
    xfun = stats:::dist)
 {
 xfun(x)
 }


 John


 

 To: r-help@r-project.org
 Sent: Fri, April 1, 2011 2:56:06 PM
 Subject: [R] function in argument

 Hi, I tried to pass the function dist() as an argument, but got an error
 message. However, almost the same code with mean() as the function to be 
 passed,

 it works ok.

 foo-function (x,
    xfun = dist)
 {
 xfun(x)
 }

 foo(matrix(1:100,nrow=5))
 Error in foo(matrix(1:100, nrow = 5)) : could not find function xfun


 foo-function (x,
     xfun = mean)
 {
  xfun(x)
 }

 foo(1:10)
 [1] 5.5

 what am I missing here?

 Thanks

 John

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




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

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


[R] Lattice wireframe or cloud plot with different colours by a group

2011-04-01 Thread Pam Allen
I have a question about wireframe 3-D plots and how to apply colors.  I have
a large dataset of river flow (m^3/s) over time, and I have coded these
flows based on their height.  I would like to produce a wireframe plot that
colors the graph based on the flow code, i.e. I would like high flows to be
red, medium to be green and low flows to be blue.  Here is some sample data
with the basic wireframe plot:

flow.dat=cbind.data.frame(flow=sin(2*pi/53*c(1:3000))+1,day=as.numeric(format(as.Date(c(1:3000)),
format=%j)), year=as.numeric(format(as.Date(c(1:3000)),
format=%Y)),grp=c(rep(c(1.high,2.med,3.low),1000)))

wireframe(flow~day*year, data=flow.dat, shade=T)

Is there any way to specify what colours are passed to the plot?  I.e.
wireframe(flow~day*year, data=flow.dat, shade=T, groups=grp,
col.group=c(#FF3030,#551A8B,#43CD80))

I would also be happy if I could do this with a cloud plot, but I can't get
the colors to plot correctly. 
cloud(flow~day*year, data=flow.dat, shade=T, groups=grp,
col.group=c(#FF3030,#43CD80,#1E90FF), pch=20)

Any help is much appreciated!  Thank you.

-Pam Allen

allen_...@hotmail.com


--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-wireframe-or-cloud-plot-with-different-colours-by-a-group-tp3421296p3421296.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] filled contour plot with contour lines

2011-04-01 Thread Peter Ehlers

Steve,

I was just about to send off another suggestion which
began with ...

  Try the following or wait for David W. to chime in.

But I see that he's already done that. Anyway, in case
it's still of some use:

First I would check that you don't have a variable 'T' in
your workspace. (Never use T in place of TRUE.)

Then I would check that x and y are as they should be.

Then I would make sure that temp is of the correct type
(a matrix) by letting j take a few values (1,2,varsize[4]-1),
generating temp, and running str(temp). I assume that
varsize[4] is = 2.

Then I would run the following stripped-down version of
your loop (note that I modified your contour() call):

 for(j in 1:2) {
  temp - get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1)
  )
  filled.contour(x,
 y,
 temp,
 plot.axes = { contour(x, y, temp, add = TRUE)
   axis(1, seq(45 , 58, by = 1))
   axis(2, seq(280,400, by = 1))
 }
 }

If that gives reasonable results, you can add the prettyfying
statements back in. If you still get errors, then either I'm
out-to-lunch (quite possible!) or you need to use debug() to
figure out what's going on.

Peter Ehlers


On 2011-04-01 14:59, David Winsemius wrote:


On Apr 1, 2011, at 5:38 PM, steve_fried...@nps.gov wrote:


Hi Peter,

Thanks for taking the time to consider the problem. I realize the
procedure
is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in
size to
pull data into this process. Nobody in their right mind should work
with
such things. It's a spatial temporal database with 10 years of daily
data
in a irregular area spanning 405 x 287 cells.

Anyway, I tried your suggestion adding a { in front of the for loop
and a
closing } following the last line.


That suggestion was probably intended to get you a more informative
error message:

for(j in 1:(varsize[4]-1) )
   temp- get.var.ncdf(
 nc=input,
 varid=p_foraging,
 c(1,1,j),
 c(varsize[1],  varsize[2], 1)
  )

# I think Peter is correct. That loop will complete before the call to
filled.contour,
#  so you will only have the last version of temp plot.

filled.contour(x, y, temp, color = terrain.colors,
   plot.title = title( main =
   paste(Everglades Wood Stork Foraging Potential \nYear,
(2000+j)),

#that double call to title looks incomplete as well. The comma looks
premature.
# Shouldn't it be something like:
   plot.title = bquote(Everglades Wood Stork Foraging Potential
\nYear, .(2000+j) )

#(And since the for loop is already complete `j` will not exist.
# Which is probably the source of the error you are getting.)

  xlab = UTM East, ylab = UTM North) ,
  plot.axes = { contour(temp, add=T)
 axis(1, seq(45 , 58, by = 1))
 axis(2, seq(280,400, by = 1)) },
  key.title = title(main=Probability) ,
  key.axes = axis(4, seq(0 , 1 , by = 0.1))


It did not work.


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147



 Peter Ehlers
 ehlers@ucalgary.

ca To
   steve_fried...@nps.gov
 04/01/2011 05:08steve_fried...@nps.gov

PM cc
   r-help@r-project.org
   r-help@r-project.org

Subject
   Re: [R] filled contour plot with
   contour lines










Aren't you missing a set of parentheses?
I can't run your code since it's not reproducible, but to
my aging eyes it seems that you need a set of '{}' around
the contents of your loop:

  for(j in 1:(varsize[4]-1)) { loop stuff }

Peter Ehlers

On 2011-04-01 11:48, steve_fried...@nps.gov wrote:


I'm stumped,  can anyone find my error in this sequence.

  for(j in 1:(varsize[4]-1))
   temp- get.var.ncdf(nc=input,
varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1))
  filled.contour(x, y, temp, color = terrain.colors,
  plot.title = title(main = paste(Everglades Wood Stork
Foraging Potential \nYear, (2000+j)),
  xlab = UTM East, ylab = UTM North) ,
  plot.axes = { contour(temp, add=T)
 axis(1, seq(45 , 58, by = 1))
 axis(2, seq(280,400, by = 1)) },
  key.title = title(main=Probability) ,
  key.axes = axis(4, seq(0 , 1 , by = 0.1))


[R] package MICE, squeeze function, calling several variables at once

2011-04-01 Thread Rita Carreira

Hello everyone!I have a data set with missing observations that I am trying to 
impute. I am using MICE and I would like the imputed values to all be positive. 
I have two types of variables: prices (P1 to P136) and quantities (Q1 to Q136) 
and I also want the range of these two types to be different. Besides these 
variables. I am using the squeeze function but I am unable to set it such that 
I don't have to write the names of all the variables. Also note that I do not 
have all the 136 Ps and Qs because since some were completely missing, I had to 
drop those variables. But my first Q is called Q1 and the last one Q136 and 
similarly for P. I apologize if I am making a silly little error since I am 
still learning R. 
This is the code that I have and the error that I am getting:
#Program starts here#Read data into Rdf - 
read.table(F:\\testC2S4\\new_C2-S4_head_data.txt, header = TRUE); 
   #, stringsAsFactors = TRUEdfPZ - df[ ,1:3]dfDV - df[ 
,277:311]dfPtemp - df[ ,seq(4, 275, by = 2)]dfP - dfPtemp[, sapply(dfPtemp, 
function(x) !all(is.na(x)))]dfQtemp - df[ ,seq(5, 275, by = 2)]dfQ - 
dfQtemp[, sapply(dfQtemp, function(x) !all(is.na(x)))]remove(dfPtemp, dfQtemp)
NewPrimal - data.frame(c(dfPZ, dfQ, dfP, dfDV), row.names = NULL, check.rows = 
F, check.names = F) remove(dfPZ, dfQ, dfP, dfDV)
library(mice)# setting up the default settings for the imputationini - 
mice(NewPrimal, seed = 52275,imputationMethod = norm, 
   maxit=0,pred = quickpred(NewPrimal,
mincor = 0.25,   minpuc = 0.95,include = 
c(blnNewYearsDay, blnValentinesDay, blnStPatricksDay, 
   blnEaster, blnMothersDay, blnMemorialDay,  
  blnFathersDay, blnIndependenceDay, blnLaborDay, 
   blnThanksgiving, blnChristmas, Qtr1, Qtr2, Qtr3,   
Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, 
   Oct, Nov, Dec),   exclude 
= c(ActualWeekEndingDate, CompanyID, PriceZoneID, Date, Year)),   
print=FALSE)
meth - ini$meth # naming the default method in inipred - ini$pred   # naming 
the matrix of default predictors in inipost - ini$post# naming the default 
post processing method in inipost[Q1:Q136] - imp[[j]][,i] - 
squeeze(imp[[j]][,i],c(0,351000))  #setting the range for 
quantitypost[P1:P136] - imp[[j]][,i] - squeeze(imp[[j]][,i],c(0,50))
  #setting the range for price
# calling mice to impute given default settings:impNP - mice(NewPrimal, meth = 
meth, maxit=5, pred = pred, post = post)

##My error warningError in Q1:Q136 : NA/NaN argument
In addition: Warning messages:
1: In post[Q1:Q136] - imp[[j]][,i] - squeeze(imp[[j]][,i],c(0,351000)) :
  NAs introduced by coercion
2: In post[Q1:Q136] - imp[[j]][,i] - squeeze(imp[[j]][,i],c(0,351000)) :
  NAs introduced by coercion
Any ideas?
Thank you and have a great weekend!

Rita  If you think education is 
expensive, try ignorance--Derek Bok


  
[[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] filled contour plot with contour lines

2011-04-01 Thread skfgla...@gmail.com
Hi Peter and everyone else who has offered suggestions.  I am now at home  
and will try your suggestions this evening.

The initial effort with the stripped down verion I have used earlier did  
access the file correctly so I have no reason to think it is not formatted  
correctly.   That however is always a worthy check in all applications.   I  
appreciate the reminder.

Steve

friedman.st...@gmail.com
517-648-6290

-Original message-
From: Peter Ehlers ehl...@ucalgary.ca
To: David Winsemius dwinsem...@comcast.net
Cc: r-help@r-project.org r-help@r-project.org
Sent: Fri, Apr 1, 2011 22:49:38 GMT+00:00
Subject: Re: [R] filled contour plot with contour lines

Steve,

I was just about to send off another suggestion which
began with ...

   Try the following or wait for David W. to chime in.

But I see that he's already done that. Anyway, in case
it's still of some use:

First I would check that you don't have a variable 'T' in
your workspace. (Never use T in place of TRUE.)

Then I would check that x and y are as they should be.

Then I would make sure that temp is of the correct type
(a matrix) by letting j take a few values (1,2,varsize[4]-1),
generating temp, and running str(temp). I assume that
varsize[4] is = 2.

Then I would run the following stripped-down version of
your loop (note that I modified your contour() call):

  for(j in 1:2) {
   temp - get.var.ncdf(nc=input,
 varid=p_foraging,c(1,1,j),c(varsize[1],varsize[2],1)
   )
   filled.contour(x,
  y,
  temp,
  plot.axes = { contour(x, y, temp, add = TRUE)
axis(1, seq(45 , 58, by = 1))
axis(2, seq(280,400, by = 1))
  }
  }

If that gives reasonable results, you can add the prettyfying
statements back in. If you still get errors, then either I'm
out-to-lunch (quite possible!) or you need to use debug() to
figure out what's going on.

Peter Ehlers


On 2011-04-01 14:59, David Winsemius wrote:

 On Apr 1, 2011, at 5:38 PM, steve_fried...@nps.gov wrote:

 Hi Peter,

 Thanks for taking the time to consider the problem. I realize the
 procedure
 is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in
 size to
 pull data into this process. Nobody in their right mind should work
 with
 such things. It's a spatial temporal database with 10 years of daily
 data
 in a irregular area spanning 405 x 287 cells.

 Anyway, I tried your suggestion adding a { in front of the for loop
 and a
 closing } following the last line.

 That suggestion was probably intended to get you a more informative
 error message:

 for(j in 1:(varsize[4]-1) )
temp- get.var.ncdf(
  nc=input,
  varid=p_foraging,
  c(1,1,j),
  c(varsize[1],  varsize[2], 1)
   )

 # I think Peter is correct. That loop will complete before the call to
 filled.contour,
 #  so you will only have the last version of temp plot.

 filled.contour(x, y, temp, color = terrain.colors,
plot.title = title( main =
paste(Everglades Wood Stork Foraging Potential \nYear,
 (2000+j)),

 #that double call to title looks incomplete as well. The comma looks
 premature.
 # Shouldn't it be something like:
plot.title = bquote(Everglades Wood Stork Foraging Potential
 \nYear, .(2000+j) )

 #(And since the for loop is already complete `j` will not exist.
 # Which is probably the source of the error you are getting.)

   xlab = UTM East, ylab = UTM North) ,
   plot.axes = { contour(temp, add=T)
  axis(1, seq(45 , 58, by = 1))
  axis(2, seq(280,400, by = 1)) },
   key.title = title(main=Probability) ,
   key.axes = axis(4, seq(0 , 1 , by = 0.1))

 It did not work.


 Steve Friedman Ph. D.
 Ecologist  / Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax (305) 224 - 4147



  Peter Ehlers
  ehlers@ucalgary.

 ca To
steve_fried...@nps.gov
  04/01/2011 05:08steve_fried...@nps.gov

 PM cc
r-help@r-project.org
r-help@r-project.org

 Subject
Re: [R] filled contour plot with
contour lines










 Aren't you missing a set of parentheses?
 I can't run your code since it's not reproducible, but to
 my aging eyes it seems that you need a set of '{}' around
 the contents of your loop:

   for(j in 1:(varsize[4]-1)) { 

Re: [R] Lattice wireframe or cloud plot with different colours by a group

2011-04-01 Thread David Winsemius


On Apr 1, 2011, at 6:21 PM, Pam Allen wrote:

I have a question about wireframe 3-D plots and how to apply  
colors.  I have
a large dataset of river flow (m^3/s) over time, and I have coded  
these
flows based on their height.  I would like to produce a wireframe  
plot that
colors the graph based on the flow code, i.e. I would like high  
flows to be
red, medium to be green and low flows to be blue.  Here is some  
sample data

with the basic wireframe plot:

flow.dat=cbind.data.frame(flow=sin(2*pi/53*c(1:3000)) 
+1,day=as.numeric(format(as.Date(c(1:3000)),

format=%j)), year=as.numeric(format(as.Date(c(1:3000)),
format=%Y)),grp=c(rep(c(1.high,2.med,3.low),1000)))


It does not look to me that high flows are properly grouped with `grp`.



wireframe(flow~day*year, data=flow.dat, shade=T)


 wireframe(flow~day*year, data=flow.dat,  drape=TRUE,  
col.regions=c(#FF3030,#551A8B,#43CD80),

  at=c(0,.6,1.3,1.8))

Because of the coding at the corner and the long thin polygons you  
have specified with your day*year splits you get slanting colors.




Is there any way to specify what colours are passed to the plot?  I.e.
wireframe(flow~day*year, data=flow.dat, shade=T, groups=grp,
col.group=c(#FF3030,#551A8B,#43CD80))

I would also be happy if I could do this with a cloud plot, but I  
can't get

the colors to plot correctly.
cloud(flow~day*year, data=flow.dat, shade=T, groups=grp,
col.group=c(#FF3030,#43CD80,#1E90FF), pch=20)

Any help is much appreciated!  Thank you.

-Pam Allen

allen_...@hotmail.com


--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-wireframe-or-cloud-plot-with-different-colours-by-a-group-tp3421296p3421296.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
West Hartford, CT

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


[R] Putting a loop in a function

2011-04-01 Thread Ben Hunter
I'm stuck here. The following code works great if I just use it on the
command line in a 'for' loop. Once I try to define it as a function as seen
below, I get bad results. I'm trying to return a vector of column indices
based on a short string that is contained in a selection (length of about
70) of long column names that changes from time to time. Is there an
existing function that will do this for me? The more I think about this
problem, the more I feel there has to be a function out there. I've not
found it.


ind - function(col, string, vector){  # this is really the problem. I don't
feel like I'm declaring these arguments properly.
  indices - vector(mode = 'numeric') # I am not entirely confident that
this use is necessary. Is indices - c() okay?
  for (i in 1:length(col)){
num - regexpr(str, col[i])
if (num != -1){
 indices - c(vector, i) # I've also had success with indices -
append(indices, i)
  }
}
indices
}

ind(d[,'Column.I.want'], 'string', 'output.vector')

Am I wrong here? I've read that the last statement in the function is what
it will return, and what I want is a vector of integers.

Thanks,

-Ben

[[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] Putting a loop in a function

2011-04-01 Thread Joshua Wiley
Hi Ben,

I am having some trouble figuring out what it is exactly you want.  A
workable example would be nice and then (even if just manually) typed
out what you would like it to return based on a given input.  I almost
think you just want grep().

grep(test, c(test, not, test2, not), value = TRUE)
[1] test  test2

using your example:

grep(string, d[,Column.You.Want], value = TRUE)

On Fri, Apr 1, 2011 at 5:39 PM, Ben Hunter bjameshun...@gmail.com wrote:
 I'm stuck here. The following code works great if I just use it on the
 command line in a 'for' loop. Once I try to define it as a function as seen
 below, I get bad results. I'm trying to return a vector of column indices
 based on a short string that is contained in a selection (length of about
 70) of long column names that changes from time to time. Is there an
 existing function that will do this for me? The more I think about this
 problem, the more I feel there has to be a function out there. I've not
 found it.


 ind - function(col, string, vector){  # this is really the problem. I don't
 feel like I'm declaring these arguments properly.
  indices - vector(mode = 'numeric') # I am not entirely confident that
 this use is necessary. Is indices - c() okay?

indices - c() would sort of work, but vector() is better.  Also, if
you actually want your function to be returning integers, you should
instatiate indices as an integer class vector, not numeric.

  for (i in 1:length(col)){
    num - regexpr(str, col[i])

str() is a function, and as far as I can tell, a variable str is not
defined anywhere in your function or your functions argument.  Did you
mean string?

    if (num != -1){
         indices - c(vector, i) # I've also had success with indices -
 append(indices, i)

why are you combining vector with i over and over?  This will give
you something like:

c(vector, i1, vector, i2, vector, i3, etc.) except obviously
replace i1, i3 with their values and vector with its value.  Is that
what you want?

  }
 }
 indices
 }

 ind(d[,'Column.I.want'], 'string', 'output.vector')

 Am I wrong here? I've read that the last statement in the function is what
 it will return, and what I want is a vector of integers.

yes, if return() is not explicitly specified inside the function, then
it will return the output of the last statement.


 Thanks,

Thank you for providing code of what you tried.  For future reference,
it is good to at least provide useable input data and then show us
what the output you would like is.  For example: Blah blah blah, I
have a vector d - c(1, 2, 3), how can I find the average of this
(i.e., 2)? To which you would get the answer: mean(d) or some such.

If grep() is not actually what you are after, can you let us know a
little bit more about what you want?

Hope this helps,

Josh



 -Ben

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


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.


  1   2   >