Re: [R] column-wise z-scores by group

2008-10-07 Thread Peter Dalgaard

DISCCRS wrote:

Hi,

I have a dataset of historical monthly temperature data that is grouped by
weather station. I want to create z-scores of the monthly data using a base
period of a subset of years. I subset the dataset first to include only data
from the years (V2) that make up the base period so I could calculate the
appropriate means and standard deviations

 V1   V2V3   V12   V15   V16   V19
8411084 1978 40.16 63.13 44.06 63.41 63.47
8511084 1979 43.71 60.88 48.09 64.64 62.34
8611084 1980 50.61 61.64 47.93 62.10 63.45
8711084 1981 42.11 63.59 47.29 63.42 63.37
1583  18469 1978 30.78 56.93 34.62 56.40 57.39
1584  18469 1979 33.48 57.68 37.76 58.70 57.30
1585  18469 1980 40.83 54.48 39.27 56.14 57.42
1586  18469 1981 33.33 56.28 37.57 56.20 56.47
2688  25467 1978 52.61 75.51 55.02 68.20 70.70
2689  25467 1979 47.95 74.54 50.70 67.58 70.24
2690  25467 1980 55.12 72.51 56.59 66.49 71.21
2691  25467 1981 56.70 70.33 57.65 69.35 72.16

Then I split the data by group ID (V1) and got the means and std deviations:

subsets - split(test,V1)
sub.means - data.frame(t(sapply(subsets, mean)))
sub.sds - data.frame(t(sapply(subsets, sd, na.rm=T)))

Here are the means, for example:

   V1 V2  V3 V12 V15 V16 V19
11084   11084 1979.5 44.1475 62.3100 46.8425 63.3925 63.1575
18469   18469 1979.5 34.6050 56.3425 37.3050 56.8600 57.1450
25467   25467 1979.5 53.0950 73.2225 54.9900 67.9050 71.0775

How can I approach the next step -- applying the means and std deviations
from the two new arrays that I created to the original dataset (by station
and by month)? Or should I be using a different approach entirely? There are
NAs throughout the dataset.
Thanks very much in advance.

-Jennife

Playing the ball from where it landed, how about

nm - as.character(test$V1)
(test - sub.means[nm,])/sub.sds[nm,]

However, there could be a neater solution by looping ave(V2, V1, FUN=scale)

Or, you could apply scale() on each of your split() data and then 
unsplit(). Just beware that scale() turns things into matrices so you 
need an as.data.frame step inbetween.


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

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


Re: [R] Reading Data

2008-10-07 Thread Rahul-A.Agarwal

Hi I don't want to ignore the date row.
See basically my first row is the date column and the 1st column is the
stocks name.
Now using the if loop I have to find prices of stocks corresponding to a
date.
I hope the problem is clear to you now

For example


Stocks   30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
a1.003.007.003.00   
b2.004.004.007.00   
c3.008.00655.00  3.00   
d4.0023.00   4.005.00   
e5.0078.00   6.005.00   


Rahul Agarwal
Analyst
Equities Quantitative Research
UBS_ISC, Hyderabad
On Net: 19 533 6363




-Original Message-
From: Gustaf Rydevik [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 2:19 PM
To: Agarwal, Rahul-A
Cc: [EMAIL PROTECTED]; r-help@r-project.org
Subject: Re: [R] Reading Data

On Tue, Oct 7, 2008 at 10:36 AM,  [EMAIL PROTECTED] wrote:

 Hi,
 I have a data in which the first row is in date format and the first
 column is in text format and rest all the entries are numeric.
 Whenever I am trying to read the data using read.table, the whole of
 my data is converted in to the text format.

 Please suggest what shall I do because using the numeric data which
 are prices I need to calculate the return but if these prices are not
 numeric then calculating return will be a problem

 regards

 Rahul Agarwal
 Analyst
 Equities Quantitative Research
 UBS_ISC, Hyderabad
 On Net: 19 533 6363


Hi,

A single column in a data frame can't contain mixed formats.
In the absence of example data,  would guess one of the following could
work :

1)
read.table(data.txt,skip=1, header=T) ## If you have headers

2)
read.table(data.txt, header=T) ## If the date row is supposed to be
variable names.

3)
 read.table(data.txt,skip=1) ## If there are no headers, and you want
to ignore the date


regards,

Gustaf

--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik



[[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] Reading Data

2008-10-07 Thread Rahul-A.Agarwal
Hi
What if I need to take dates and stock names from these table...i mean I need 
to read in this table and then use if function and extratc the data from FOO
Identifier  weight  Start_Date  End_Date
a   6.7631Jan06 31Jan07
g   2.8628Feb06 28Feb07
e   22.94   31Mar06 30Mar07
c   30.05   28Apr06 30Apr07
t   20.55   31May06 31May07 


Rahul Agarwal 
Analyst 
Equities Quantitative Research 
UBS_ISC, Hyderabad 
On Net: 19 533 6363 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Philipp Pagel
Sent: Tuesday, October 07, 2008 2:52 PM
To: r-help@r-project.org
Subject: Re: [R] Reading Data

 For example
 
 Stocks 30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
 a  1.003.007.003.00   
 b  2.004.004.007.00   
 c  3.008.00655.00  3.00   
 d  4.0023.00   4.005.00   
 e  5.0078.00   6.005.00   

OK - this may be what you want:

 foo - read.table('q.tbl', header=T, check.names=F, row.names=1)
 str(foo)
'data.frame':   5 obs. of  4 variables:
 $ 30-Jan-08: num  1 2 3 4 5
 $ 28-Feb-08: num  3 4 8 23 78
 $ 31-Mar-08: num  7 4 655 4 6
 $ 30-Apr-08: num  3 7 3 5 5
 foo
  30-Jan-08 28-Feb-08 31-Mar-08 30-Apr-08
a 1 3 7 3
b 2 4 4 7
c 3 8   655 3
d 423 4 5
e 578 6 5
 foo['31-Mar-08']
  31-Mar-08
a 7
b 4
c   655
d 4
e 6
 foo['d', '31-Mar-08']
[1] 4

Maybe row.names is not what you want - but the example sould get you going.

cu
Philipp

--
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München 
Wissenschaftszentrum Weihenstephan 85350 Freising, Germany 
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fitting weibull, exponential and lognormal distributions to left-truncated data.

2008-10-07 Thread Gough Lauren
Dear All,

I have two questions regarding distribution fitting.

I have several datasets, all left-truncated at x=1, that I am attempting
to fit distributions to (lognormal, weibull and exponential).  I had
been using fitdistr in the MASS package as follows:

fitdistr-(x,weibull)

However, this does not take into consideration the truncation at x=1.  I
read another posting in this forum that suggested using the argument
lower to truncate the distribution fitting.  However, this does not
seem to be working.  For example, when I attempt to fit a weibull
distribution truncated at x=1 using lower, it seems to set the
best-fit shape parameter at 1:

 fitdistr(x,weibull,lower=1)
 shapescale   
  1.   9.87964337 
 (0.02358731) (0.40649570) ##I have tried this on other datasets also
truncated at x=1 and get the same result (i.e. shape=1).

Does anyone know how to successfully fit the exponential, weibull and
lognormal distributions to truncated data?



Secondly, as my datasets are large (1000 data points) assessing the fit
of the distribution with kolmogorov smirnov goodness of fit tests is
routinely showing statistical significance for all distributions.
Therefore, I would like to plot the observed data with the theoretical
best fit distributions (weibull, exponential and lognormal) to visually
assess which fits the observed data best.  So far I have been doing this
as follows:

fitdistr(x,weibull)
shapescale   
  a b 

D1-density(x) ##density distribution of observed data
D2-density(rweibull(1500,shape=a,scale=b)) ##density of a random
variable following the theoretical best fit weibull distribution with
shape parameter =a, scale parameter = b.

plot(range(D1$x),range(D1$y,D2$y),type=n,xlab=x,ylab=Density)
lines(D1,col=red)
lines(D2,col=blue)

This successfully plots the two density curves on the same graph, but it
plots data below the x=1 threshold - even for the observed data!  I have
tried limiting the scale of x-axis using xlim=c(1,150) but the graph
still plots the origin of the graph as (0,0).  I can only get different
origins if I limit x more extremely e.g. xlim=c(50,150).  Does anyone
know how I can successfully change the origin of the graph to (1,0)?


Sorry for the long e-mail! Any help would be greatly appreciated.

Regards,

Lauren

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

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


Re: [R] Automatic code diagramming for R?

2008-10-07 Thread Tobias Verbeke

Ben Bryant wrote:


Greetings -

Is anyone aware of an automatic code diagrammer/flow chart creator that
works for the R language (either a contributed package, or external
software)?  I need to explain some code structure of a package I'm working
on to non-R users, and would find it extremely helpful to have such a
program similar to, for example, Visustin (
http://www.aivosto.com/visustin.html ).  I can do it by hand (possibly
with the help of the 'diagram' package) but it seems like automated
capabilities for recognizing nested structures and argument-passing would be
of good general use to package developers.


When you document your package using Roxygen,
you can generate callgraphs (using the @callGraph
and/or @callGraphPrimitives tags).

The roxygen package homepage can be found at

http://roxygen.org/

and the vignette has an example of a call graph
(and how to generate it).

HTH,
Tobias


Much appreciated,
-Ben Bryant

[[alternative HTML version deleted]]

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




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


[R] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio
He everybody,
Well I have a biplot CCA-like origined from plot.cca (vegan package). I need to 
rotate on y axis the lines and symbols of constrained and sites representation. 
If I do that on an image editor, I rotate everything, including titles, axes 
labels and positions. I just need to rotate the inner par and keep the 
variables names (constrained) and symbols in the new positions but with the 
right direction.
So, is there on R a way to do that while creating the image?
Here is the code that generate the graphic.

plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total Fauna
Sites x Environment')
text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')

Thanks in advice.
___
MSc. Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia

[[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] Reading Data

2008-10-07 Thread Philipp Pagel
 For example
 
 Stocks 30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
 a  1.003.007.003.00   
 b  2.004.004.007.00   
 c  3.008.00655.00  3.00   
 d  4.0023.00   4.005.00   
 e  5.0078.00   6.005.00   

OK - this may be what you want:

 foo - read.table('q.tbl', header=T, check.names=F, row.names=1)
 str(foo)
'data.frame':   5 obs. of  4 variables:
 $ 30-Jan-08: num  1 2 3 4 5
 $ 28-Feb-08: num  3 4 8 23 78
 $ 31-Mar-08: num  7 4 655 4 6
 $ 30-Apr-08: num  3 7 3 5 5
 foo
  30-Jan-08 28-Feb-08 31-Mar-08 30-Apr-08
a 1 3 7 3
b 2 4 4 7
c 3 8   655 3
d 423 4 5
e 578 6 5
 foo['31-Mar-08']
  31-Mar-08
a 7
b 4
c   655
d 4
e 6
 foo['d', '31-Mar-08']
[1] 4

Maybe row.names is not what you want - but the example sould get you going.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

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


Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data.

2008-10-07 Thread Richard . Cotton
  I have several datasets, all left-truncated at x=1, that I am 
attempting
  to fit distributions to (lognormal, weibull and exponential).  I had
  been using fitdistr in the MASS package as follows:

 A possible solution is to use the survreg() in the survival package 
 without specifying the covariates, i.e.
 
 library(survival)
 survreg(Surv(..)~1, dist=weibull)
 
 where Surv(..) accepts information about times, censoring/truncation 
 variables and dist allows to specify alternative distributions.
 See ?Surv e ?survreg

The survival package is mostly targeted at right-censored data.  The NADA 
package provides wrappers for many of the survival routines so they work 
with left-censored data.

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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


Re: [R] Reading Data

2008-10-07 Thread Nutter, Benjamin
Perhaps it would be easier to try something like this:

 df1 - read.table(filename, ... )  # All columns read as characters
 df1 - t(df1)  # Transpose df1
 write.table - (df1, newfile, ...) # Write the transposed data 
 # to a new file
 df2 - read.table(newfile, header=TRUE, ...)  # Read in transposed
data

I doubt it's the most computation-time-efficient, but conceptually it's
pretty quick.

Benjamin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 8:28 AM
To: [EMAIL PROTECTED]; r-help@r-project.org
Subject: [R] FW: Reading Data

 
 

Rahul Agarwal 
Analyst 
Equities Quantitative Research 
UBS_ISC, Hyderabad 
On Net: 19 533 6363 



 

 hi let me explain you the problem
we have a database which is in this format


Stocks   30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
a1.003.007.003.00   
b2.004.004.007.00   
c3.008.00655.00  3.00   
d4.0023.00   4.005.00   
e5.0078.00   6.005.00   

 and we have a query which is in this format
 
Identifier   weight  Start_Date  End_Date   
a6.7631-Jan-06   31-Jan-07  
e2.8628-Feb-06   28-Feb-07  
f22.94   31-Mar-06   30-Mar-07  
y30.05   28-Apr-06   30-Apr-07  
h20.55   31-May-06   31-May-07  
d6.76   
f2.86   
r22.94  
  okay now my task is to calculate returns for all the indentifiers for
a respective start and end date from table 1.
 
now length of start date and end date column is same and that of weight
and identifier is same.
i hope everything is clear now.
 
let me also send you the code that i have written but in my code i have
problem with the date format and also with the stocks name
 
data=read.table(H:/Rahul/london/david/rexcel/price.txt)
query=read.table(H:/Rahul/london/david/rexcel/prac.txt,header=TRUE)
 
data=as.matrix(data)
instrument=data[,1]
date=data[1,]
 
query=as.matrix(query)
q_ins=query[,1]
wt=query[,2]
q_sd=query[,3]
q_ed=query[,4]
 
returns=function(I,SD,ED){
  p=rep(0,2)
  for(i in 2:length(instrument))
  {
if(instrument[i]==I)
{
  for(j in 2:length(date))
  {
if(date[j]==SD)
p[1]=data[i,j]
  }
  for(j in 2:length(date))
  {
if(date[j]==ED)
p[2]=data[i,j]
  }
}
returns=(p[2]/p[1])-1
  }
#print(p)
#print(I)
return(returns)
}
 
##The original Funda##
 
matrix_ret=matrix(0,length(q_ins),length(q_sd))
 
for(i in 1:length(q_sd))
{
 for(j in 1:length(q_ins))
 {
  matrix_ret[j,i]=returns(q_ins[j],q_sd[i],q_ed[i])
 }
}
 
#Removing NA from the matrix
 
matrix_ret1=sapply(X=matrix_ret, FUN=function(x)
ifelse(is.na(x),0.00,x))
matrix_ret=matrix(matrix_ret1,length(q_ins),length(q_sd))
 

wt_ret=matrix(0,length(q_sd),1)
for(i in 1:length(q_sd))
{
 for(j in 1:length(q_ins))
 {
  wt_ret[i]=wt_ret[i]+(wt[j]*matrix_ret[j,i])
 }
}
 
result=cbind(q_ed,wt_ret)

  
Rahul Agarwal
Analyst
Equities Quantitative Research
UBS_ISC, Hyderabad
On Net: 19 533 6363




-Original Message-
From: Gustaf Rydevik [mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ]
Sent: Tuesday, October 07, 2008 2:19 PM
To: Agarwal, Rahul-A
Cc: [EMAIL PROTECTED]; r-help@r-project.org
Subject: Re: [R] Reading Data

On Tue, Oct 7, 2008 at 10:36 AM,  [EMAIL PROTECTED] wrote:

 Hi,
 I have a data in which the first row is in date format and the first
 column is in text format and rest all the entries are numeric.
 Whenever I am trying to read the data using read.table, the whole of
 my data is converted in to the text format.

 Please suggest what shall I do because using the numeric data which
 are prices I need to calculate the return but if these prices are not
 numeric then calculating return will be a problem

 regards

 Rahul Agarwal
 Analyst
 Equities Quantitative Research
 UBS_ISC, Hyderabad
 On Net: 19 533 6363


Hi,

A single column in a data frame can't contain mixed formats.
In the absence of example data,  would guess one of the following could
work :

1)
read.table(data.txt,skip=1, header=T) ## If you have headers

2)
read.table(data.txt, header=T) ## If the date row is supposed to be
variable names.

3)
 read.table(data.txt,skip=1) ## If there are no headers, and you want
to ignore the date


regards,

Gustaf

--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik


[[alternative HTML version deleted]]

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

Re: [R] lmer: random factor nested in a fixed factor

2008-10-07 Thread Hank Stevens

hi folks,
I believe that the construction

y ~ A + (A|B)

(where A is a categorical variable for a fixed effect and
B is a categorical variable for a random effect) will generate random  
effects for all of the fixed effect coefficients. That is, in addition  
fitted a systematic fixed effect coefficient for intercept and  
relevant added effects of levels of A, it will fit corresponding  
random coefficients for each level of B, including random intercepts,  
and relevant added random effects of A, given B (i.e. for each  
separate B).


Thus if you think that each family has, in addition to a different  
overall mean, also has a different response to levels of A (and you  
have the replication to estimate them), then you should include (A|B)  
and see if it is better than simply (1|B).


Hank

On Oct 6, 2008, at 11:02 AM, Christian Ritz wrote:


Dear Agnes,

I think your model specification should look like this:

YourModel1 - lmerlmer(y ~ poptype*matingtype + (1|poptype:pop) + (1| 
poptype:fam),

data = ...)


The 1 in front of | refers to models that are random intercepts  
models as opposed to
general random coefficients models in which case 1 would need to  
be replaced by a
variable that is quantitative. So, the (poptype|/pop/fam)  
construction is definitely not
relevant to your problem, unless poptype is a quantitative  
variable...


The combined factor poptype:pop corresponds to the factor pop, but  
taking the nesting

structure into account. Similar for the construction poptype:fam.

From the summary output of the lmer() fit you should be able to  
check whether or not the

correct number of groups are used for these random factors.

Kind regards
Christian

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




Dr. Hank Stevens, Associate Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.cas.muohio.edu/ecology
http://www.muohio.edu/botany/

If the stars should appear one night in a thousand years, how would men
believe and adore. -Ralph Waldo Emerson, writer and philosopher  
(1803-1882)


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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

 I need to rotate on y axis the lines and symbols of constrained and sites
 representation.

Easiest is to multiply the axis you want to invert by -1. Something like the
following, where my.cca is the orginal object and yax = obj[, 2] (xax being
obj[, 1]). Obviously, copying isn't necessary.

mynew.cca - my.cca
mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

Regards, Mark.


Rodrigo Aluizio wrote:
 
 He everybody,
 Well I have a biplot CCA-like origined from plot.cca (vegan package). I
 need to rotate on y axis the lines and symbols of constrained and sites
 representation. If I do that on an image editor, I rotate everything,
 including titles, axes labels and positions. I just need to rotate the
 inner par and keep the variables names (constrained) and symbols in the
 new positions but with the right direction.
 So, is there on R a way to do that while creating the image?
 Here is the code that generate the graphic.
 
 plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total Fauna
 Sites x Environment')
 text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')
 
 Thanks in advice.
 ___
 MSc. Rodrigo Aluizio
 Centro de Estudos do Mar/UFPR
 Laboratório de Micropaleontologia
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Mirror-Image-on-Biplot-Graphic-tp19857549p19858155.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] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

Sorry, that will not return a result (I use several different ordination
packages, in most of which this is possible). What you need to do with vegan
is the following:

scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

You will be able to do the rest.

Regards, Mark.


Mark Difford wrote:
 
 Hi Rodrigo,
 
 I need to rotate on y axis the lines and symbols of constrained and
 sites representation.
 
 Easiest is to multiply the axis you want to invert by -1. Something like
 the following, where my.cca is the orginal object and yax = obj[, 2] (xax
 being obj[, 1]). Obviously, copying isn't necessary.
 
 mynew.cca - my.cca
 mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
 mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
 mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1
 
 Regards, Mark.
 
 
 Rodrigo Aluizio wrote:
 
 He everybody,
 Well I have a biplot CCA-like origined from plot.cca (vegan package). I
 need to rotate on y axis the lines and symbols of constrained and sites
 representation. If I do that on an image editor, I rotate everything,
 including titles, axes labels and positions. I just need to rotate the
 inner par and keep the variables names (constrained) and symbols in the
 new positions but with the right direction.
 So, is there on R a way to do that while creating the image?
 Here is the code that generate the graphic.
 
 plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total Fauna
 Sites x Environment')
 text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')
 
 Thanks in advice.
 ___
 MSc. Rodrigo Aluizio
 Centro de Estudos do Mar/UFPR
 Laboratório de Micropaleontologia
 
  [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Mirror-Image-on-Biplot-Graphic-tp19857549p19858268.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R on the Freakonomics Blog

2008-10-07 Thread John Kane
Quotes

I probably have an unhealthy attraction to the powers of Excel. I taught my 
daughter how to use it when she was 7. When I teach corporate finance, I try to 
make sure that my law students come away from the course knowing how to crunch 
in Excel.

And R is probably not kept up to speed on the cutting-edge empirical methods 
as quickly as the traditional packages. 

Yep, I'd say an unhealthy attraction to Excel and an stunning lack of knowledge 
about R.

I note that many contributers seem to be pointing out that R is just a bit 
better than the author seems to think it is. 




--- On Mon, 10/6/08, Scillieri, John [EMAIL PROTECTED] wrote:

 From: Scillieri, John [EMAIL PROTECTED]
 Subject: [R] R on the Freakonomics Blog
 To: r-help@r-project.org
 Received: Monday, October 6, 2008, 4:26 PM
 http://freakonomics.blogs.nytimes.com/2008/10/06/free-super-crunching-so
 ftware/
 
  This e-mail and any attachments are
 confidential, may contain legal,
 professional or other privileged information, and are
 intended solely for the
 addressee.  If you are not the intended recipient, do not
 use the information
 in this e-mail in any way, delete this e-mail and notify
 the sender. CEG-IP2
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


  __
[[elided Yahoo spam]]

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

2008-10-07 Thread Alexandre Aguiar
Hi,

I noticed the temperature of my laptop rises sharply during execution of a 
long R script that generates several hundred plots, all of them saved to 
files. No screen output. Temps reached above 90 Celsius degrees in the box 
and above 80 C deg in the processor. The machine turns on cooler at maximum 
speed and exhaled air is really hot. Tried similar operations (batch 
graphic and music format conversion) and temp rises were usual.

System: laptop, Turion 64, Kubuntu Linux, Xorg X server 1.4.0.90, KDE 3.5.9, 
R 2.7.2 compiled with MBCS, PCRE, etc.

Could it be fake due to an interaction of some R piece with system monitors?

Alexandre

-- 
Alexandre Santos Aguiar, MD, SCT
--
website: http://spsconsultoria.com/
Phone: +55-11-3717-4866 (SP)
Phone: +55-21-3717-4866 (RJ)
Voicemail: +55-11-2157-6891 (SP)
Fax: +55-11-5549-8760 (SP)
--


signature.asc
Description: This is a digitally signed message part.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to validate model?

2008-10-07 Thread Maithili Shiva
Hi!

I am working on scorecard model and I have arrived at the regression equation. 
I have used logistic regression using R.

My question is how do I validate this model? I do have hold out sample of 5000 
customers.

Please guide me. Problem is I had never used Logistic regression earlier 
neither I am used to credit scoring models.

Thanks in advance

Maithili

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


Re: [R] Reading Data

2008-10-07 Thread Philipp Pagel

 What if I need to take dates and stock names from these table...i mean I
 need to read in this table and then use if function and extratc the
 data from FOO

Not sure what exactly the problem is. Can you give an example? Of course
the first thing would be to make sure that dates are in the same format... 
And so far I don't see a good reason to use 'if' - R has extremely
flexible indexing capabilities.


 While using  the command foo['31-Mar-08'] in the below given example:
 On the left hand side I am getting the count and not
 alphabetsplease suggest

Maybe your stock names in the file were numbers? Maybe you left out the
row.names parameter?

 Why m I getting this message
 
 data=read.table(H:/Rahul/london/david/rexcel/price1.txt,header=T,check.names=F,row.names=1)
 Error in read.table(H:/Rahul/london/david/rexcel/price1.txt, header = T,  : 
   duplicate 'row.names' are not allowed 

The message means what it says: row names need to be unique. Apparently
yours are not. I.e. You wave multiple rows for the same stock
identifier.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

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


Re: [R] Stacked area chart and legends

2008-10-07 Thread Jim Lemon

mbr wrote:

I have found lots of good advice on this forum about stacked area charts but
I’ve run into problems with the 2 recommended options: stackploy in plotrix
or qplot in ggplot2. I have a many page report that will be in a 2x2 page
format “par(mfrow=c(2,2))”” and need one of the page components to be a
stacked chart. 


I’d prefer to use stackpoly, if possible, but I’m stuck on how to do the
legend in hopefully a relatively simple way. I just need a simple legend to
be outside the plot area (b/c the plot area is full as I’m doing it as 100%
stacked area chart format) on the right side with the little box with the
color and the series name next to it – same/similar to Excel format.

The qplot approach would work as well and seems like the legend is built
into the default, but the graph always ends up on its own page and can’t
figure out how to force it into one of boxes of my 2x2 page layout. I like
the looks of the stackpoly more as consistent with other graphs I have on
report but qplot stacked chart would be fine if I could get it into the
layout.

  

Hi Matt,
The easy way is to make your device wider than it is high:

# use the screen device for the example
x11(width=10,height=7)
#leave lots of room on the right side of the plot:
par(mar=c(5,4,4,10))
#then plot, stop clipping to the plot region, add the legend
# and restore clipping
stackpoly(matrix(abs(rnorm(30)),nrow=10),stack=TRUE,
main=Look ma. just like Excel!)
par(xpd=TRUE)
legend(11,3,1:5,fill=1:5)
par(xpd=FALSE)

Jim

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


Re: [R] Reading Data

2008-10-07 Thread Gustaf Rydevik
On Tue, Oct 7, 2008 at 10:36 AM,  [EMAIL PROTECTED] wrote:

 Hi,
 I have a data in which the first row is in date format and the first
 column is in text format and rest all the entries are numeric. Whenever
 I am trying to read the data using read.table, the whole of my data is
 converted in to the text format.

 Please suggest what shall I do because using the numeric data which are
 prices I need to calculate the return but if these prices are not
 numeric then calculating return will be a problem

 regards

 Rahul Agarwal
 Analyst
 Equities Quantitative Research
 UBS_ISC, Hyderabad
 On Net: 19 533 6363


Hi,

A single column in a data frame can't contain mixed formats.
In the absence of example data,  would guess one of the following could work :

1)
read.table(data.txt,skip=1, header=T) ## If you have headers

2)
read.table(data.txt, header=T) ## If the date row is supposed to be
variable names.

3)
 read.table(data.txt,skip=1) ## If there are no headers, and you
want to ignore the date


regards,

Gustaf

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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


Re: [R] R and computer heat

2008-10-07 Thread Dr Eberhard Lisse
Why don't you hack a little script that looks at system load,
temperature and date/time and writes it somewhere. Then
you can load it into R and plot it nicely :-))-O

Even compare it witht he desktop :-)-O

el

on 10/7/08 12:21 PM Alexandre Aguiar said the following:
 Hi,
 
 I noticed the temperature of my laptop rises sharply during execution of a 
 long R script that generates several hundred plots, all of them saved to 
 files. No screen output. Temps reached above 90 Celsius degrees in the box 
 and above 80 C deg in the processor. The machine turns on cooler at maximum 
 speed and exhaled air is really hot. Tried similar operations (batch 
 graphic and music format conversion) and temp rises were usual.
 
 System: laptop, Turion 64, Kubuntu Linux, Xorg X server 1.4.0.90, KDE 3.5.9, 
 R 2.7.2 compiled with MBCS, PCRE, etc.
 
 Could it be fake due to an interaction of some R piece with system monitors?
 
 Alexandre
 
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Dr. Eberhard W. Lisse  \/ Obstetrician  Gynaecologist (Saar)
[EMAIL PROTECTED] el108-ARIN / * |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ /   Please do NOT email to this address
Bachbrecht, Namibia ;/if it is DNS related in ANY 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.


[R] How to store the results of multiple iterations of 'aov' in a data.frame?

2008-10-07 Thread Michal Figurski

A follow-up to Need to calculate within- and between-run CV

I have a dataset of 210 Samples, of which each was run several times in 
several consecutive days. A dataset for one sample is below:


qu.s -
structure(list(Sample = c(44L, 44L, 44L, 44L, 44L, 44L, 44L,
44L, 44L, 44L), Run = c(1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L
), Rep = c(1, 2, 1, 2, 3, 4, 1, 2, 3, 4), value = c(120L, 107L,
117L, 124L, 118L, 127L, 110L, 113L, 109L, 113L)), .Names = c(Sample,
Run, Rep, value), row.names = c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L), class = data.frame)

and the code I used is below:

a=aov(value ~ Run, data=qu.s)   

I assume that 'Residual' is the variance between replicates in my data.
Since I have to run the above code 210 times, my question is: how to 
store the results of 'aov' in a separate data.frame?


For each iteration of 'aov' I need to store: the _sums of squares_ for 
Run and Residual, the _N_ of replicates and the _mean_. Later I want to 
use it to calculate the coefficients of variation (CV) for each sample.


I looked at the structure of aov object, but the sums of squares are not 
listed there, though 'summary(a)' prints them. Please help.


--
Michal Figurski


Michal Figurski wrote:

Dear R-helpers,

I have a dataset named qu, organized as follows:

SampleRunReplicateValue
11125
11240
11333
11429
12137
12244
12345
13125
13240
14133
14229
14325
2 ...

Basically, a sample was run on an assay multiple times within a single 
day. Each of these results is Replicate. Then run was repeated several 
times in consecutive days - variable Run. There are 210 such samples.


I need to actually calculate the CV for each sample:
 - within run (between replicates) - that's easy to do in Excel
 - between run - that's the problem.

I was thinking of using either 'aov' or 'lme' to solve this. However, I 
don't know how to interpret the output. For example, a summary output 
from aov(Value~Run+Replicate, subset(qu,Sample==79))' for one sample was:


Df Sum Sq Mean Sq F value Pr(F)
Run  1  4.000   4.000  0.3214 0.6104
Replicate1 73.500  73.500  5.9062 0.0933 .
Residuals3 37.333  12.444
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Do you guys think this is correct approach?
How do I extract these numbers (sum of squares) to store in a separate 
dataframe for further calculations?


And how should I interpret the Residual in this setting?

I will appreciate your comments.



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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio

Thanks a lot for your help (again) Mark.
I adapted your suggestion to my analysis.
But I'm getting and error when trying to apply the new values.
The error is:

Erro em scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[,  :
 não foi posssível encontrar a função scores-

Translating:
Error at scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[, 
:

 it's not possible to find the function scores-

Bellow how I applied the suggestion:
CAPpotiFTI-CAPpotiFT
scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

Any ideas? I'm trying similar things but without success.

--
From: Mark Difford [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 10:34 AM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry, that will not return a result (I use several different ordination
packages, in most of which this is possible). What you need to do with 
vegan

is the following:

scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

You will be able to do the rest.

Regards, Mark.


Mark Difford wrote:


Hi Rodrigo,


I need to rotate on y axis the lines and symbols of constrained and
sites representation.


Easiest is to multiply the axis you want to invert by -1. Something like
the following, where my.cca is the orginal object and yax = obj[, 2] 
(xax

being obj[, 1]). Obviously, copying isn't necessary.

mynew.cca - my.cca
mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

Regards, Mark.


Rodrigo Aluizio wrote:


He everybody,
Well I have a biplot CCA-like origined from plot.cca (vegan package). I
need to rotate on y axis the lines and symbols of constrained and sites
representation. If I do that on an image editor, I rotate everything,
including titles, axes labels and positions. I just need to rotate the
inner par and keep the variables names (constrained) and symbols in the
new positions but with the right direction.
So, is there on R a way to do that while creating the image?
Here is the code that generate the graphic.

plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total 
Fauna

Sites x Environment')
text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')

Thanks in advice.
___
MSc. Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia

[[alternative HTML version deleted]]


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







--
View this message in context: 
http://www.nabble.com/Mirror-Image-on-Biplot-Graphic-tp19857549p19858268.html

Sent from the R help mailing list archive at Nabble.com.

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

and provide commented, minimal, self-contained, reproducible code.



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


[R] Selecting numeric data from a data frame

2008-10-07 Thread Meir Preiszler
Hi

I have a data frame containing numeric and factor data.
I want to extract the numeric data only. How can this be done?

Thanks
Meir





Meir Preiszler - Research Engineer
I t a m a r M e d i c a l Ltd. 
Caesarea, Israel:
Tel: +(972) 4 617 7000 ext 232
Fax: +(972) 4 627 5598
Cell: +(972) 54 699 9630
Email: [EMAIL PROTECTED] 
Web: www.Itamar-medical.com 
*




88---8---
 This E-mail is confidential information of Itamar medical Ltd. It may also 
  be legally privileged. If you are not the addressee you may not copy, forward,
  disclose or use any part of it. If you have received this message in error,
  please delete it and all copies from your system and notify the sender
  immediately by return E-mail. Internet communications cannot be guaranteed 
  to be timely, secure, error or virus-free. The sender does not accept 
  liability for any errors or omissions. Before printing this email , 
  kindly think about the environment.   Itamar Medical Ltd. MIS Yan Malgin.
88---8---


[[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 validate model?

2008-10-07 Thread Frank E Harrell Jr

Maithili Shiva wrote:

Hi!

I am working on scorecard model and I have arrived at the regression equation. 
I have used logistic regression using R.

My question is how do I validate this model? I do have hold out sample of 5000 
customers.

Please guide me. Problem is I had never used Logistic regression earlier 
neither I am used to credit scoring models.

Thanks in advance

Maithili


The holdout sample of 5000 may be too small.  You didn't specify the 
size of the training sample.  I assume it is 50,000 or larger.  50-fold 
repeats of 10-fold cross-validation is better.  With any resampling 
technique you need to repeat all exploratory and modeling steps inside 
the loop.


Frank



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




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] Selecting numeric data from a data frame

2008-10-07 Thread Peter Dalgaard
Meir Preiszler wrote:
 Hi

 I have a data frame containing numeric and factor data.
 I want to extract the numeric data only. How can this be done?

 Thanks
 Meir

   
d[sapply(d,is.numeric)]

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

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


Re: [R] R and computer heat

2008-10-07 Thread Tom Backer Johnsen

Alexandre Aguiar wrote:

Hi,

I noticed the temperature of my laptop rises sharply during execution of a 
long R script that generates several hundred plots, all of them saved to 
files. No screen output. Temps reached above 90 Celsius degrees in the box 
and above 80 C deg in the processor. The machine turns on cooler at maximum 
speed and exhaled air is really hot. Tried similar operations (batch 
graphic and music format conversion) and temp rises were usual.


System: laptop, Turion 64, Kubuntu Linux, Xorg X server 1.4.0.90, KDE 3.5.9, 
R 2.7.2 compiled with MBCS, PCRE, etc.


Could it be fake due to an interaction of some R piece with system monitors?

Alexandre


My guess is that it the graphics card which is hard at work.

Tom

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


Re: [R] fitting a curve to data points

2008-10-07 Thread Dieter Menne
carlos.grohmann at gmail.com writes:

 
 Hello all. This is likely to be a silly question, but I have a set of
 data points and I want to fit a curve to it, like this:
 http://www.igc.usp.br/pessoais/guano/temp/curve.png

While you could use a loess-curve, interpreting the rising branch a the 
end is probably close to cheating. I would simply guess that this is an
exp(-t/t0) curve with a few outliers. You should really have good reasons 
with so few datapoints in the upward branch.

Dieter

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


[R] S3 vs S4 class

2008-10-07 Thread Terry Therneau
  
  
  A simple example:
temp - as.Date('2001-10-5')
class(temp)
  Date

How do I tell if Date is implemented as an S3 or an S4 class type?
I tried ?class, but didn't see anything obvious.  Functions like inherit() work
equally well with both types (which is a good thing).

  I expect the answer will be obvious - once someone points it out to me.

Terry T

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


Re: [R] plyr package: passing further arguments fail

2008-10-07 Thread baptiste auguie
Thanks Hadley, for some reason I didn't see your email until now. It  
works fine with the development version,


library(plyr)
df - data.frame(a=1:10 , b=1:10)

foo1 - function(a, b, cc=0, d=0){
  a + b + cc + d
}

mdply(data. = df, foo1, cc=1, d=2)

I think using . prefixes is a safer option (and possibly more  
consistent with R customs), although that means the current code using  
plyr will have to be modified.


Congratulations on the new ggplot2 release too!

Thanks,

baptiste




On 5 Oct 2008, at 14:39, hadley wickham wrote:

On Sun, Oct 5, 2008 at 8:02 AM, Auguie, Baptiste  
[EMAIL PROTECTED] wrote:

Dear list and Hadley,

The new plyr package seems to provide a clean and consistent way to  
apply a function on several arguments. However, I don't understand  
why the following example does not work like the standard mapply,


library(plyr)
df - data.frame(a=1:10 , b=1:10)

foo1 - function(a, b, cc=0, d=0){
  a + b + cc + d
}

mdply(df, foo1, cc=1) # fine

mdply(df, foo1, d=1) # fails
mdply(df, foo1, cc=1, d=2) # fails


Unfortunately this bug is R's partial name matching: d = 2 - data. =
2.  You should be able to fix this by manually specifying mdply(data.
= df, foo1, cc=1, d=2) but there are some bugs in the current version
that prevent this from happening.  I've fixed this in the development
version, available from http://github.com/hadley/plyr (click the
download link)

However, the whole point of plyr is that you should have to think
about this kind of thing, so I'll revisit my naming scheme - probably
to use . prefixes instead of suffixes.

Hadley


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


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


Re: [R] S3 vs S4 class

2008-10-07 Thread Duncan Murdoch

On 07/10/2008 10:41 AM, Terry Therneau wrote:
  
  
  A simple example:

temp - as.Date('2001-10-5')
class(temp)
  Date

How do I tell if Date is implemented as an S3 or an S4 class type?
I tried ?class, but didn't see anything obvious.  Functions like inherit() work
equally well with both types (which is a good thing).

  I expect the answer will be obvious - once someone points it out to me.


You could use the isS4 function:

 temp - as.Date('2001-10-5')
 isS4(temp)
[1] FALSE

Duncan Murdoch

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


Re: [R] Reading Data

2008-10-07 Thread Rahul-A.Agarwal

Bang on!!
Thanks for the help
 


Rahul Agarwal 
Analyst 
Equities Quantitative Research 
UBS_ISC, Hyderabad 
On Net: 19 533 6363 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Philipp Pagel
Sent: Tuesday, October 07, 2008 2:52 PM
To: r-help@r-project.org
Subject: Re: [R] Reading Data

 For example
 
 Stocks 30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
 a  1.003.007.003.00   
 b  2.004.004.007.00   
 c  3.008.00655.00  3.00   
 d  4.0023.00   4.005.00   
 e  5.0078.00   6.005.00   

OK - this may be what you want:

 foo - read.table('q.tbl', header=T, check.names=F, row.names=1)
 str(foo)
'data.frame':   5 obs. of  4 variables:
 $ 30-Jan-08: num  1 2 3 4 5
 $ 28-Feb-08: num  3 4 8 23 78
 $ 31-Mar-08: num  7 4 655 4 6
 $ 30-Apr-08: num  3 7 3 5 5
 foo
  30-Jan-08 28-Feb-08 31-Mar-08 30-Apr-08
a 1 3 7 3
b 2 4 4 7
c 3 8   655 3
d 423 4 5
e 578 6 5
 foo['31-Mar-08']
  31-Mar-08
a 7
b 4
c   655
d 4
e 6
 foo['d', '31-Mar-08']
[1] 4

Maybe row.names is not what you want - but the example sould get you going.

cu
Philipp

--
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München 
Wissenschaftszentrum Weihenstephan 85350 Freising, Germany 
http://mips.gsf.de/staff/pagel

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

2008-10-07 Thread Mark Kimpel
I am performing many permutations on a data-set with each permutation
producing a variable number of results. I thought that the best way to keep
track of all this in one object would be with a list ('res.lst'). To address
these variable results for each permutation I attempted to construct this
list using 'assign'. There is even more nesting than indicated below, but
this is a simple example that, if addressed, will fit answer my question.
The below code chunk clearly does not produce the desired results because,
instead of assigning a new vector to the list, it creates a new variable
'res.list$contrast.i.j' . In the last two lines I show what I really want to
happen. Can I use assign in this context by using it differently?

Thanks, Mark

res.lst - list()
for (i in 1:2){
  for (j in 1:2){
assign(paste(res.lst$contrast, i, j, sep = .), paste(i,j,sep=.))
  }
}
res.lst

ls(pattern = res.lst..?)

res.lst$contrast.5.5 - 5.5
res.lst

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 399-1219  Home
Skype:  mkimpel

**

[[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] lme and lmer df's and F-statistics again

2008-10-07 Thread Dieter Menne
Julia S. julia.schroeder at gmail.com writes:

 Now, I did that in my article and I got a response from a reviewer that I
 additionally should give the degrees of freedom, and the F-statistics. From
 what I read here, that would be incorrect to do, and I sort of intuitively
 also understand why (at least I think I do). 
... 
 Well, writing on my rebuttal, I find myself being unable to explain in a
 few, easy to understand (and, at the same time, correct) sentences stating
 that it is not a good idea to report (most likely wrong) dfs and F
 statistics. Can somebody here help me out with a correct explanation for a
 laymen? 

Feeling with you, and hoping some day this will be resolved. I am sure you 
have read Douglas Bates'

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76742.html

but I thought this was temporary. The only workaround I have is not to use 
lmer for gaussian models. 

Dieter

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


[R] read.spss: variable.labels

2008-10-07 Thread soeren . vogel

Hi,

how can I attach variable labels originally read by read.spss() to the  
resulting variables?


pre
X - read.spss('data.sav', use.value.labels = TRUE, to.data.frame =  
TRUE, trim.factor.names = TRUE, trim_values = TRUE, reencode = UTF-8)

names(X) - tolower(names(X))
attach(X)
/pre

Thank you

Sören

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


Re: [R] R and computer heat

2008-10-07 Thread Dieter Menne
Alexandre Aguiar asaguiar at spsconsultoria.com writes:

 I noticed the temperature of my laptop rises sharply during execution of a 
 long R script that generates several hundred plots, all of them saved to 
 files. No screen output. Temps reached above 90 Celsius degrees in the box 
 and above 80 C deg in the processor. The machine turns on cooler at maximum 
 speed and exhaled air is really hot. Tried similar operations (batch 
 graphic and music format conversion) and temp rises were usual.

Compare it with a while(TRUE){} loop in any not to agressively optimizing
language of your choice. Heat simply shows that R is working hard.

Dieter

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


Re: [R] How to validate model?

2008-10-07 Thread Pedro.Rodriguez
Hi Frank,

Thanks for your feedback! But I think we are talking about two different
things.

1) Validation: The generalization performance of the classifier. See,
for example, Studies on the Validation of Internal Rating Systems by
BIS. 

2) Calibration: Correct calibration of a PD rating system means that the
calibrated PD estimates are accurate and conform to the observed default
rates. See, for instance, An Overview and Framework for
PD Backtesting and Benchmarking, by Castermans et al. 

Frank, you are referring the #1 and I am referring to #2. 

Nonetheless, I would never create a rating system if my model doesn't
discriminate better than a coin toss.

Regards,

Pedro 







-Original Message-
From: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 07, 2008 11:02 AM
To: Rodriguez, Pedro
Cc: [EMAIL PROTECTED]; r-help@r-project.org
Subject: Re: [R] How to validate model?

[EMAIL PROTECTED] wrote:
 Usually one validates scorecards with the ROC curve, Pietra Index, KS
 test, etc. You may be interested in the WP 14 from BIS (www.bis.org).
 
 Regards,
 
 Pedro

No, the validation should be done using an absolute reliability 
(calibration) curve.  You need to verify that at all levels of predicted

risk there is agreement with the true probability of failure.  An ROC 
curve does not do that, and I doubt the others do.  A 
resampling-corrected loess calibration curve is a good approach as 
implemented in the Design package's calibrate function.

Frank

 
 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
 On Behalf Of Maithili Shiva
 Sent: Tuesday, October 07, 2008 8:22 AM
 To: r-help@r-project.org
 Subject: [R] How to validate model?
 
 Hi!
 
 I am working on scorecard model and I have arrived at the regression
 equation. I have used logistic regression using R.
 
 My question is how do I validate this model? I do have hold out sample
 of 5000 customers.
 
 Please guide me. Problem is I had never used Logistic regression
earlier
 neither I am used to credit scoring models.
 
 Thanks in advance
 
 Maithili
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt
University

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

Sorry again: the structure vegan uses is quite complex. Technically you
should use the extractor function scores() to extract what you want from the
object, e.g. scores(my.cca, display=species) or scores(my.cca,
display=cn) [centroids]. I did work out a quicker way of reversing axes,
but that seems to have gone walking...and I am not using vegan at the
moment.

Quickest hack is to make a copy of the objects you want to plot, reversing
orientations along the way. So do (my.cca is your original object):

Temp.data - scores(my.cca, display=c(sites, species, cn))

## Reverse yaxes
Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
Temp.data$species[, 2] - Temp.data$species[, 2] * -1
Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

Do this for all the things you are plotting whose axes you want reversed.
Check this against your original plot to ensure that the mirror isn't
broken.

You can then use the Temp.data with the scores() function to make your plot.

## Mock e.g.
points(scores(Temp.data, display=sites), pch=21)

Regards, Mark.


Rodrigo Aluizio wrote:
 
 Thanks a lot for your help (again) Mark.
 I adapted your suggestion to my analysis.
 But I'm getting and error when trying to apply the new values.
 The error is:

 Erro em scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[, 
 :
  não foi posssível encontrar a função scores-

 Translating:
 Error at scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[, 
 :
  it's not possible to find the function scores-

 Bellow how I applied the suggestion:
 CAPpotiFTI-CAPpotiFT
 scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
 scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

 Any ideas? I'm trying similar things but without success.

 --
 From: Mark Difford [EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 10:34 AM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic


 Hi Rodrigo,

 Sorry, that will not return a result (I use several different ordination
 packages, in most of which this is possible). What you need to do with 
 vegan
 is the following:

 scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

 You will be able to do the rest.

 Regards, Mark.


 Mark Difford wrote:

 Hi Rodrigo,

 I need to rotate on y axis the lines and symbols of constrained and
 sites representation.

 Easiest is to multiply the axis you want to invert by -1. Something
 like
 the following, where my.cca is the orginal object and yax = obj[, 2] 
 (xax
 being obj[, 1]). Obviously, copying isn't necessary.

 mynew.cca - my.cca
 mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
 mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
 mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

 Regards, Mark.


 Rodrigo Aluizio wrote:

 He everybody,
 Well I have a biplot CCA-like origined from plot.cca (vegan package).
 I
 need to rotate on y axis the lines and symbols of constrained and
 sites
 representation. If I do that on an image editor, I rotate everything,
 including titles, axes labels and positions. I just need to rotate the
 inner par and keep the variables names (constrained) and symbols in
 the
 new positions but with the right direction.
 So, is there on R a way to do that while creating the image?
 Here is the code that generate the graphic.

 plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total 
 Fauna
 Sites x Environment')
 text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
 points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')

 Thanks in advice.
 ___
 MSc. Rodrigo Aluizio
 Centro de Estudos do Mar/UFPR
 Laboratório de Micropaleontologia

 [[alternative HTML version deleted]]


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





 -- 
 View this message in context: 
 http://www.nabble.com/Mirror-Image-on-Biplot-Graphic-tp19857549p19858268.html
 Sent from the R help mailing list archive at Nabble.com.

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

 
 __
 R-help@r-project.org 

Re: [R] Reading Data

2008-10-07 Thread Rahul-A.Agarwal
Why m I getting this message

data=read.table(H:/Rahul/london/david/rexcel/price1.txt,header=T,check.names=F,row.names=1)
Error in read.table(H:/Rahul/london/david/rexcel/price1.txt, header = T,  : 
  duplicate 'row.names' are not allowed 


Rahul Agarwal 
Analyst 
Equities Quantitative Research 
UBS_ISC, Hyderabad 
On Net: 19 533 6363 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Philipp Pagel
Sent: Tuesday, October 07, 2008 2:52 PM
To: r-help@r-project.org
Subject: Re: [R] Reading Data

 For example
 
 Stocks 30-Jan-08   28-Feb-08   31-Mar-08   30-Apr-08  
 a  1.003.007.003.00   
 b  2.004.004.007.00   
 c  3.008.00655.00  3.00   
 d  4.0023.00   4.005.00   
 e  5.0078.00   6.005.00   

OK - this may be what you want:

 foo - read.table('q.tbl', header=T, check.names=F, row.names=1)
 str(foo)
'data.frame':   5 obs. of  4 variables:
 $ 30-Jan-08: num  1 2 3 4 5
 $ 28-Feb-08: num  3 4 8 23 78
 $ 31-Mar-08: num  7 4 655 4 6
 $ 30-Apr-08: num  3 7 3 5 5
 foo
  30-Jan-08 28-Feb-08 31-Mar-08 30-Apr-08
a 1 3 7 3
b 2 4 4 7
c 3 8   655 3
d 423 4 5
e 578 6 5
 foo['31-Mar-08']
  31-Mar-08
a 7
b 4
c   655
d 4
e 6
 foo['d', '31-Mar-08']
[1] 4

Maybe row.names is not what you want - but the example sould get you going.

cu
Philipp

--
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München 
Wissenschaftszentrum Weihenstephan 85350 Freising, Germany 
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fitting weibull, exponential and lognormal distributions to left-truncated data.

2008-10-07 Thread Prof Brian Ripley

On Tue, 7 Oct 2008, [EMAIL PROTECTED] wrote:


I have several datasets, all left-truncated at x=1, that I am

attempting

to fit distributions to (lognormal, weibull and exponential).  I had
been using fitdistr in the MASS package as follows:



A possible solution is to use the survreg() in the survival package
without specifying the covariates, i.e.

library(survival)
survreg(Surv(..)~1, dist=weibull)

where Surv(..) accepts information about times, censoring/truncation
variables and dist allows to specify alternative distributions.
See ?Surv e ?survreg


The survival package is mostly targeted at right-censored data.  The NADA
package provides wrappers for many of the survival routines so they work
with left-censored data.


Left-censoring and left-truncation are not the same thing.  With 
left-censoring you see that you had observations  1, and with 
left-truncation you do not (at least how the terms are usually applied: 
occasionally the meanings are reversed).


For left-truncation it is relatively easy, e.g.

ltwei - function(x, shape, scale = 1, log = FALSE)
dweibull(x, shape, scale, log)/pweibull(1, shape, scale, lower=FALSE)

and use this in fitdistr.

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

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


[R] Mac crash- Probably memory problem

2008-10-07 Thread dimitris kapetanakis

Dear all,

I am running a code using bootstraps for estimating standard errors but the
mac crashes. When I use small number of bootstraps (100) it works fine but
if I increase that number it crashes. 

Thanks in advance 

dimitris

The code, the error and my mac characteristics are the following:

##code#
qr.1- rq(y~factor(year)+factor(state)+x1+I(x^2)+I(x^3), tau=0.05,
data=data1)

s.qr1.05 - summary(qr.1, se=boot, R=1000)$coefficient

##error#

 *** caught segfault ***
address 0x1de9e000, cause 'memory not mapped'

Traceback:
 1: .Fortran(xys, as.integer(m), as.integer(n), as.integer(p),
as.integer(R), as.integer(m + 5), as.integer(p + 2), as.double(x),
as.double(y), as.double(tau), as.double(tol), flag = integer(R), coef =
double(p * R), resid = double(m), integer(m), double((m + 5) * (p +
2)), double(m), xx = double(m * p), yy = double(m), as.integer(s),
PACKAGE = quantreg)
 2: boot.rq.xy(x, y, s, tau)
 3: boot.rq(x, y, tau, ...)
 4: summary.rq(qr.05.nox, se = boot, R = 1000)
 5: summary(qr.05.nox, se = boot, R = 1000)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 

###characteristics#
Mac OS X

version 10.5.4

Model Name: MacBook
  Model Identifier: MacBook4,1
  Processor Name:   Intel Core 2 Duo
  Processor Speed:  2.4 GHz
  Number Of Processors: 1
  Total Number Of Cores:2
  L2 Cache: 3 MB
  Memory:   4 GB
  Bus Speed:800 MHz
  Boot ROM Version: MB41.00C1.B00





-- 
View this message in context: 
http://www.nabble.com/Mac-crash--Probably-memory-problem-tp19860892p19860892.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] panel.groups: use group.number to define colors

2008-10-07 Thread baptiste auguie

Dear list,


I've been trying this for a few hours and I just don't understand how  
lattice works with groups and subscripts.


Consider the following example,




xx - seq(1, 10, length=100)
x - rep(xx, 4)
y - c(cos(xx), sin(xx), xx, xx^2/10)
fact - factor(rep(c(cos, sin, id, square), each=100))
fact2 - factor(rep(c(periodic, not periodic), each=100))

my.df - data.frame(x=x, y=y, fact = fact, fact2 = fact2)

head(my.df)


myColors - c(2, 4)

xyplot(y ~ x | fact,  data = my.df, groups = fact2,
  panel =  panel.superpose,
  panel.groups = function(..., group.number) {

 panel.xyplot(...)
#panel.xyplot( ..., col=myColors[group.number]) # error

  })



My aim is to assign a custom color to each group, but for some reason  
the col parameter is already given to panel.xyplot and I can't find  
where it gets the values from.


Many thanks,

baptiste

_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


Re: [R] horizontal boxplot + xlim

2008-10-07 Thread Ben Bolker
Antje niederlein-rstat at yahoo.de writes:


 I get a strange behaviour of a boxplot with the following code. There seems 
 to 
 be a problem with the xlim-parameter. Did I do anything wrong? What else can 
 I 
 do to force the boxplot to have a defined x-range?
 
 x - rnorm(100)
 boxplot(x, notch=TRUE, xlab=parameter, xlim - c(-4,4), horizontal = TRUE)
 

   This should be just fine if you say 

boxplot(x, notch=TRUE, xlab=parameter, xlim=c(-4,4), horizontal = TRUE)

instead.

- is only for assignment.  You must use = for setting arguments
to a function.

  Ben Bolker

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


Re: [R] using assign with lists

2008-10-07 Thread jim holtman
Here is something to try:

 result - list()
 for (i in 1:2){
+ for (j in 1:2){
+ result[[paste(i, j, sep=|)]] - rep(i,j)
+ }
+ }

 result
$`1|1`
[1] 1

$`1|2`
[1] 1 1

$`2|1`
[1] 2

$`2|2`
[1] 2 2


On Tue, Oct 7, 2008 at 11:01 AM, Mark Kimpel [EMAIL PROTECTED] wrote:
 I am performing many permutations on a data-set with each permutation
 producing a variable number of results. I thought that the best way to keep
 track of all this in one object would be with a list ('res.lst'). To address
 these variable results for each permutation I attempted to construct this
 list using 'assign'. There is even more nesting than indicated below, but
 this is a simple example that, if addressed, will fit answer my question.
 The below code chunk clearly does not produce the desired results because,
 instead of assigning a new vector to the list, it creates a new variable
 'res.list$contrast.i.j' . In the last two lines I show what I really want to
 happen. Can I use assign in this context by using it differently?

 Thanks, Mark

 res.lst - list()
 for (i in 1:2){
  for (j in 1:2){
assign(paste(res.lst$contrast, i, j, sep = .), paste(i,j,sep=.))
  }
 }
 res.lst

 ls(pattern = res.lst..?)

 res.lst$contrast.5.5 - 5.5
 res.lst
 
 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine

 15032 Hunter Court, Westfield, IN  46074

 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 399-1219  Home
 Skype:  mkimpel

 **

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] Extracting text from html code using the RCurl package.

2008-10-07 Thread Martin Morgan
Hi Tony --

Tony Breyal [EMAIL PROTECTED] writes:

 Dear R-help,

 I want to download the text from a web page, however what i end up
 with is the html code. Is there some option that i am missing in the
 RCurl package? Or is there another way to achieve this? This is the
 code i am using:

 library(RCurl)
 
 html.file - getURI(my.url, ssl.verifyhost = FALSE, ssl.verifypeer = FALSE, 
 followlocation = TRUE)
 print(html.file)

 I thought perhaps the htmlTreeParse() function from the XML package
 might help, but I just don't know what to do next with it:

 library(XML)
 htmlTreeParse(html.file)

 Many thanks for any help you can provide,

Sounds like you're on the right track. One way is to parse the html
file into its 'internal' representation, and then use xpathApply to
extract relevant information (e.g., the third 'p' (paragraph) element
from the XML mark-up

 html = htmlTreeParse(getURL(my.url), useInternal=TRUE)
Opening and ending tag mismatch: td and font
Unexpected end tag : p
Unexpected end tag : form
 xpathApply(html, //p[3], xmlValue)
[[1]]
[1] You can subscribe to the list, or change your existing\r\n\t
subscription, in the sections below.\r\n\t

the 'xpath' is the path from the root of the document through various
nested tags to tags of the specified type. //p, says 'start at the
root ('/') and look in all sub-nodes (that this '//') for an 'p'
tag. ?xpathApply.  is a good starting place, as is
http://www.w3.org/TR/xpath, especially

http://www.w3.org/TR/xpath#path-abbrev 

Martin

 Tony Breyal


 sessionInfo()
 R version 2.7.2 (2008-08-25)
 i386-pc-mingw32

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

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

 other attached packages:
 [1] XML_1.94-0  RCurl_0.9-4

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

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


Re: [R] Load a program at the front end

2008-10-07 Thread Gang Chen
Thanks a lot for the suggestion!

Unfortunately  R --no-save  prog.R does not work well with my
situation because prog.R
contain lines such as readline() and () that require user response in
the middle of the
execution. I also tried other options such as R -f prog.R and R
--interactive  prog.R, and
they all failed.

Any other suggestions?

Thanks,
Gang


On Mon, Oct 6, 2008 at 10:12 PM, Bernardo Rangel Tura
[EMAIL PROTECTED] wrote:
 Em Qui, 2008-10-02 às 14:36 -0400, Gang Chen escreveu:
 I want to run a R program, prog.R,  interactively. My question is, is
 there a way I can start prog.R on the shell terminal when invoking R,
 instead of using source() inside R?

 TIA,
 Gang

 Hi Gang

 I my system just only type:

  R --no-save prog.R

 platform   x86_64-unknown-linux-gnu
 arch   x86_64
 os linux-gnu
 system x86_64, linux-gnu
 status Patched
 major  2
 minor  7.2
 year   2008
 month  09
 day11
 svn rev46532
 language   R
 version.string R version 2.7.2 Patched (2008-09-11 r46532)

 --
 Bernardo Rangel Tura, M.D,MPH,Ph.D
 National Institute of Cardiology
 Brazil

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

2008-10-07 Thread rkevinburton
I am trying to sort a list and the data is obiously not in the right format. I 
am trying:

x - list()
x[[A]] - 1
x[[B]] - 2

order(x)

But am getting:

Error in order(x) : unimplemented type 'list' in 'orderVector1'

How should I change the list so that it can be sorted? What kinds of objects 
(classes of objects) can be sorted?

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 squared value for a line on a plot

2008-10-07 Thread Georgina Sarah Humphreys
Does anyone know how to retrieve the R squared value for a line on a graph?

Thanks
Georgina

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Frank Hedler
Dear all,
We have a data frame x with n people as rows and k variables as columns.
Now, for each person (i.e., each row) we want to calculate a distance
between  him/her and EACH other person in x. In other words, we want to
create a n x n matrix with distances (with zeros in the diagonal).

However, we do not want to calculate Euclidian distances. We want to calculate
Mahalanobis distances, which take into account the covariance among
variables.

Below is the piece of code we wrote (covmat in the function below is the
variance-covariance matrix among variables in Data that has to be fed into
mahalonobis function we are using).
 mahadist = function(x, covmat) {
 dismat = matrix(0,ncol=nrow(x),nrow=nrow(x))

 for (i in 1:nrow(x)) {

   dismat[i,] = mahalanobis(as.matrix(x), as.matrix(x[i,]), covmat)^.5

 }

 return(dismat)

}


This piece of code works, but it is very slow. We were wondering if it's at
all possible to somehow vectorize this function. Any help would be greatly
appreciated.
Thanks,
Frank

[[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] Algorithm = port convergence codes

2008-10-07 Thread Nakamura

Hello all,

I am fitting a Gamma distribution to some data I have using nls(). The
function obviously runs into issues when using a 0 as a parameter value. I
understand the line alg = port can be used to set the lower bounds to
prevent this from happening. When I run the code I get the following:
Algorithm port, convergence message: relative convergence (4). I have
attempted changing the starting parameter values and the paramter estimates
appear robust. 

The R help file mentions the code is 0 for converence. Should I be
concerned here that nls() is returning a local optimum here, or is this
quite normal?

Thanks in advance!
Rob

PS Please try to ignore the fact a distribution is being fitted to too few
data points!


##Code

Acancellata.caughtintraps = c(6,2,1,2,0,0,0,0,0,0,0)  
Acancellata.released = 1250 

distances = c(2,3,4,5,7.5,10,12.5,15,17.5,20,25)
totalseedscaught = sum(Acancellata.caughtintraps)
Pcatch = totalseedscaught/Acancellata.released

## Calculate cumulative seed numbers reaching each distance
cumsumcaught - rev(cumsum(rev(Acancellata.caughtintraps)))

i = numeric(11)
i - distances

## Gamma distribution
gamma.nls  - nls(cumsumcaught ~ Pcatch*Acancellata.released*
pgamma(distances,shape=a,scale=c,lower.tail=FALSE),
## 'alg=port' is required for lower bounds ## 
alg=port,
start = list(a=5,c=1),
lower=list(a=0.1,b=0.1))

print(gamma.nls)
print(summary(gamma.nls))

## Output

[1] Gamma
Nonlinear regression model
  model:  cumsumcaught ~ Pcatch * Acancellata.released * pgamma(distances, 
shape = a, scale = c, lower.tail = FALSE) 
   data:  parent.frame() 
 a  c 
7.5731 0.4399 
 residual sum-of-squares: 4.176

Algorithm port, convergence message: relative convergence (4) 

Formula: cumsumcaught ~ Pcatch * Acancellata.released * pgamma(distances, 
shape = a, scale = c, lower.tail = FALSE)

Parameters:
  Estimate Std. Error t value Pr(|t|)  
a   7.5731 2.3786   3.184   0.0111 *
c   0.4399 0.1415   3.109   0.0125 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.6812 on 9 degrees of freedom

Algorithm port, convergence message: relative convergence (4) 



-- 
View this message in context: 
http://www.nabble.com/Algorithm-%3D-%22port%22-convergence-codes-tp19860224p19860224.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R and Multi threading

2008-10-07 Thread pejpm

I will preface this message by saying that I am not an R developer and no
very little about R...but here is my situation:

One of my users has developed a model for analysing commodity prices. At the
moment when he runs this model on his daily data set it takes roughly 5
hours to complete. He is using a quad core PC with 2gb of RAM. The R process
only uses 1 core..i.e. the overall CPU usage tops out at around 25%. This
has been a managable situation for a while, but he would now like to run
this model on 5 years of historical data. He has a colleague who ran the
model on a 16 core Redhat Linux box, but it took even longer to run. He has
asked me for assistance in speeding up this process. I have a couple of
questions:

1) Is is possible to run the Windows version of R across all four
processors?

2) I was under the impression that R for Linux supported multi-threading by
default. Am I correct in this assumption? If not, is it possible for Linux R
to multi thread, and how do I go about configuring this?

Apologies for the lack of detailed info in this post. I work in trade floor
support and engineering and we dont really have much demand for this kind of
heavy duty computational work so I am learning as I investigate this issue.

Regards

pejpm
-- 
View this message in context: 
http://www.nabble.com/R-and-Multi-threading-tp19861868p19861868.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] Load a program at the front end

2008-10-07 Thread Luke Tierney

Something like

env R_PROFILE=prog.R R

may work for you.  You may need to call .First.sys at the beginning of
prog.R to get default packages loaded.

luke

On Tue, 7 Oct 2008, Gang Chen wrote:


Thanks a lot for the suggestion!

Unfortunately  R --no-save  prog.R does not work well with my
situation because prog.R
contain lines such as readline() and () that require user response in
the middle of the
execution. I also tried other options such as R -f prog.R and R
--interactive  prog.R, and
they all failed.

Any other suggestions?

Thanks,
Gang


On Mon, Oct 6, 2008 at 10:12 PM, Bernardo Rangel Tura
[EMAIL PROTECTED] wrote:

Em Qui, 2008-10-02 às 14:36 -0400, Gang Chen escreveu:

I want to run a R program, prog.R,  interactively. My question is, is
there a way I can start prog.R on the shell terminal when invoking R,
instead of using source() inside R?

TIA,
Gang


Hi Gang

I my system just only type:

 R --no-save prog.R

platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status Patched
major  2
minor  7.2
year   2008
month  09
day11
svn rev46532
language   R
version.string R version 2.7.2 Patched (2008-09-11 r46532)

--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil


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



--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  [EMAIL PROTECTED]
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Sarah Goslee
distance() from the ecodist package will calculate Mahalanobis distances.

Sarah

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

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


Re: [R] Extracting text from html code using the RCurl package.

2008-10-07 Thread Gabor Grothendieck
I gather you are using Windows and in that case you could
use RDCOMClient or rcom to get it via Internet Explorer, e.g.

library(RDCOMClient)
ie - COMCreate(InternetExplorer.Application)
URL - https://stat.ethz.ch/mailman/listinfo/r-help;
ie$Navigate(URL)
while(ie[[Busy]]) Sys.sleep(1)
txt - ie[[document]][[body]][[innerText]]
ie$Quit()

You may need to run this in elevated mode if you are Vista.

On Mon, Oct 6, 2008 at 11:45 AM, Tony Breyal [EMAIL PROTECTED] wrote:
 Dear R-help,

 I want to download the text from a web page, however what i end up
 with is the html code. Is there some option that i am missing in the
 RCurl package? Or is there another way to achieve this? This is the
 code i am using:

 library(RCurl)
 my.url - 'https://stat.ethz.ch/mailman/listinfo/r-help'
 html.file - getURI(my.url, ssl.verifyhost = FALSE, ssl.verifypeer = FALSE, 
 followlocation = TRUE)
 print(html.file)

 I thought perhaps the htmlTreeParse() function from the XML package
 might help, but I just don't know what to do next with it:

 library(XML)
 htmlTreeParse(html.file)

 Many thanks for any help you can provide,
 Tony Breyal


 sessionInfo()
 R version 2.7.2 (2008-08-25)
 i386-pc-mingw32

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

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

 other attached packages:
 [1] XML_1.94-0  RCurl_0.9-4

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

2008-10-07 Thread Henrique Dallazuanna
Try this:

 x[order(unlist(x), decreasing = TRUE)]

On Tue, Oct 7, 2008 at 1:28 PM,  [EMAIL PROTECTED] wrote:
 I am trying to sort a list and the data is obiously not in the right format. 
 I am trying:

 x - list()
 x[[A]] - 1
 x[[B]] - 2

 order(x)

 But am getting:

 Error in order(x) : unimplemented type 'list' in 'orderVector1'

 How should I change the list so that it can be sorted? What kinds of objects 
 (classes of objects) can be sorted?

 Thank you.

 Kevin

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

2008-10-07 Thread jim holtman
Exactly what were your expections from sorting the list?  What did you
expect the answer to look like?  You can 'unlist' the list and then
sort the elements:

 x[[A]] - 1:10
 x[[B]] - 4:12
 sort(unlist(x))
 A1  A2  A3  A4  B1  A5  B2  A6  B3  A7  B4  A8  B5  A9  B6 A10  B7  B8  B9
  1   2   3   4   4   5   5   6   6   7   7   8   8   9   9  10  10  11  12


Is this what you want?

On Tue, Oct 7, 2008 at 12:28 PM,  [EMAIL PROTECTED] wrote:
 I am trying to sort a list and the data is obiously not in the right format. 
 I am trying:

 x - list()
 x[[A]] - 1
 x[[B]] - 2

 order(x)

 But am getting:

 Error in order(x) : unimplemented type 'list' in 'orderVector1'

 How should I change the list so that it can be sorted? What kinds of objects 
 (classes of objects) can be sorted?

 Thank you.

 Kevin

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




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

What is the problem that you are trying to solve?

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


[R] Creating GUIs for R

2008-10-07 Thread Wade Wall
Hi all,

I have looked around for help on creating GUIs for R, but haven't found
anything.  I would be interested in any advice or webpages that have
information on the best language, tutorials etc. for creating simple GUIs.
Mainly I want to do this as a heuristic exercise.

Thanks for any help.

Wade Wall

[[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] sort a list?

2008-10-07 Thread Erik Iverson
Since objects of class list in R can be made up of heterogeneous 
objects, sorting them does not make much sense.  For example, does A, 
come before or after 1000, does a linear model summary come before or 
after pi?


If your data are all numeric, store them as a numeric vector, where sort 
works.  Vectors can be named in R, as in your example.


Also, 'order' does something different than 'sort'.

try the following:

x - c(a = 1, b = 4, c = 2)
sort(x)
order(x)

Hope that helps,
Erik



[EMAIL PROTECTED] wrote:

I am trying to sort a list and the data is obiously not in the right format. I 
am trying:

x - list()
x[[A]] - 1
x[[B]] - 2

order(x)

But am getting:

Error in order(x) : unimplemented type 'list' in 'orderVector1'

How should I change the list so that it can be sorted? What kinds of objects 
(classes of objects) can be sorted?

Thank you.

Kevin

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


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


Re: [R] R squared value for a line on a plot

2008-10-07 Thread Ben Bolker
Georgina Sarah Humphreys g.humphreys.1 at research.gla.ac.uk writes:

 
 Does anyone know how to retrieve the R squared value for a line on a graph?
 
 Thanks
 Georgina
 

  We need a LOT more information to answer your question ...
please read the posting guide and tell us in a bit more
detail what you're trying to do.  It sounds like you
have a graphical figure of a regression line in a paper
and want to know the R^2, which is basically impossible
unless you have the original data, or unless the plot
shows the data points and you can retrieve by digitizing
(look for the g3data software tool).

  Ben Bolker

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


Re: [R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Sarah Goslee
Hi Frank,

If the way distance() calculates the Mahalanobis distance meets your
needs other than the covariance specification, you can tweak that
_very_ easily. If you use fix(distance) at the command line, you can
edit the source.
change the first line to:
function (x, method = euclidean, icov)
and under method 4, change the icov calculation to:
if(missing(icov)) {
   icov - solve(cov(x))
}

Alternatively, here's a simplified distanceM function with everything but the
relevant bits deleted. You'll still need to have ecodist loaded.

distanceM - function (x, method = mahalanobis, icov)
{
paireddiff - function(x) {
N - nrow(x)
P - ncol(x)
A - numeric(N * N * P)
A - .C(pdiff, as.double(as.vector(t(x))), as.integer(N),
as.integer(P), A = as.double(A), PACKAGE = ecodist)$A
A - array(A, dim = c(N, N, P))
A
}
x - as.matrix(x)
N - nrow(x)
P - ncol(x)

if(missing(icov)) {
   icov - solve(cov(x))
}
A - paireddiff(x)
A1 - apply(A, 1, function(z) (z %*% icov %*% t(z)))
D - A1[seq(1, N * N, by = (N + 1)), ]


D - D[col(D)  row(D)]
attr(D, Size) - N
attr(D, Labels) - rownames(x)
attr(D, Diag) - FALSE
attr(D, Upper) - FALSE
attr(D, method) - METHODS[method]
class(D) - dist
D
}

Sarah

On Tue, Oct 7, 2008 at 1:05 PM, Frank Hedler [EMAIL PROTECTED] wrote:
 Dear all,
 we just realized something. Sarah's distance function - indeed - calculates
 mahalanobis distance very well. However, it uses the
 observed variance-covariance matrix by default.
 What we actually need (sorry for not stating it clearly in to be able to
 specify which variance-covariance matrix goes into that calculation.
 On Tue, Oct 7, 2008 at 12:44 PM, Sarah Goslee [EMAIL PROTECTED]
 wrote:

 distance() from the ecodist package will calculate Mahalanobis distances.

 Sarah


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

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


Re: [R] Creating GUIs for R

2008-10-07 Thread Greg Snow
Wade,

What type of GUI do you want?

Do you want a full GUI that the user runs to do everything (that uses R as the 
computational engine)?  Look at R commander, JGR, and the R plugin for Excel as 
possible examples.

Are you more interested in a simple GUI for one specific plot or function to 
run from within R?  Some examples include the tkexamp function in the 
TeachingDemos package (or many of the functions in that package for examples), 
the fgui package, the playwith package, the tkrplot package, and the details of 
the tcltk and RGtk2 packages.

There are other packages that help with web interfaces (not GUIs, but still 
show using R as a back end).

I don't know of any specific documents on how to write either type of gui, but 
the above can give examples to start from.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Wade Wall
 Sent: Tuesday, October 07, 2008 10:56 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Creating GUIs for R

 Hi all,

 I have looked around for help on creating GUIs for R, but haven't found
 anything.  I would be interested in any advice or webpages that have
 information on the best language, tutorials etc. for creating simple
 GUIs.
 Mainly I want to do this as a heuristic exercise.

 Thanks for any help.

 Wade Wall

 [[alternative HTML version deleted]]

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

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


Re: [R] R squared value for a line on a plot

2008-10-07 Thread Dieter Menne
Georgina Sarah Humphreys g.humphreys.1 at research.gla.ac.uk writes:

 
 Does anyone know how to retrieve the R squared value for a line on a graph?

The balloon rule

http://www.jstor.org/pss/2683562

Dieter

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


Re: [R] Creating GUIs for R

2008-10-07 Thread Bert Gunter
Seek and ye shall find ... Check the RGUI's link on the other web page on
CRAN.

If you are on Windows, there is some simple built-in GUI functionality.
?winMenuAdd, ?select.list and the links therein will get you started there.

Cheers,
Bert Gunter

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Wade Wall
Sent: Tuesday, October 07, 2008 9:56 AM
To: [EMAIL PROTECTED]
Subject: [R] Creating GUIs for R

Hi all,

I have looked around for help on creating GUIs for R, but haven't found
anything.  I would be interested in any advice or webpages that have
information on the best language, tutorials etc. for creating simple GUIs.
Mainly I want to do this as a heuristic exercise.

Thanks for any help.

Wade Wall

[[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] panel.groups: use group.number to define colors

2008-10-07 Thread Bert Gunter
Not exactly sure what you want to do, but ...

In your example, you do not need groups, since the color doesn't change
within the levels of the conditioning variable (fact). Hence you can use the
panel.number() function to choose the plotting color of each panel, like
this:

## .. continuing with your example 

 myColors - rep(c(2,4),2)

 xyplot(y ~ x | fact,  data = my.df,
  panel =  function(...){
panel.xyplot(...,col=myColors[panel.number()])
 }
  )

If you actually **need** groups (to color different subsets of the data
within a panel differently). it does get a bit more complicated.
Incidentally, note that col is already a formal argument of panel.superpose
and was therefore  picked up in the ... argument of the panel.groups
function -- that's why you got the error you did when you repeated col
explicitly in the panel.xyplot call. By default, it's values are those of
trellis.par.get(superpose.symbol) I believe. Also, group.number appears to
be undefined in your code.

HTH

Cheers,
Bert Gunter

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


Re: [R] Creating GUIs for R

2008-10-07 Thread Wade Wall
Sorry that my post wasn't very clear.

What I am wanting to do is learn to build some simple GUIs for a limited
number of functions. Basically, I am envisioning a screen with check boxes,
a drop down menu etc. that users could select to run analyses on imported
data.

I have worked with VB before, but it has been several years and I am not
sure how it interfaces with R.


On Tue, Oct 7, 2008 at 1:20 PM, Bert Gunter [EMAIL PROTECTED] wrote:

 Seek and ye shall find ... Check the RGUI's link on the other web page on
 CRAN.

 If you are on Windows, there is some simple built-in GUI functionality.
 ?winMenuAdd, ?select.list and the links therein will get you started there.

 Cheers,
 Bert Gunter

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On
 Behalf Of Wade Wall
 Sent: Tuesday, October 07, 2008 9:56 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Creating GUIs for R

 Hi all,

 I have looked around for help on creating GUIs for R, but haven't found
 anything.  I would be interested in any advice or webpages that have
 information on the best language, tutorials etc. for creating simple GUIs.
 Mainly I want to do this as a heuristic exercise.

 Thanks for any help.

 Wade Wall

 [[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] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Frank Hedler
Dear all,we just realized something. Sarah's distance function - indeed -
calculates mahalanobis distance very well. However, it uses the
observed variance-covariance matrix by default.
What we actually need (sorry for not stating it clearly in to be able to
specify which variance-covariance matrix goes into that calculation.

On Tue, Oct 7, 2008 at 12:44 PM, Sarah Goslee [EMAIL PROTECTED]wrote:

 distance() from the ecodist package will calculate Mahalanobis distances.

 Sarah

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


ORIGINAL request:
Dear all,
We have a data frame x with n people as rows and k variables as columns.
Now, for each person (i.e., each row) we want to calculate a distance
between  him/her and EACH other person in x. In other words, we want to
create a n x n matrix with distances (with zeros in the diagonal).

However, we do not want to calculate Euclidian distances. We want to calculate
Mahalanobis distances, which take into account the covariance among
variables.

Below is the piece of code we wrote (covmat in the function below is the
variance-covariance matrix among variables in Data that has to be fed into
mahalonobis function we are using).
 mahadist = function(x, covmat) {
 dismat = matrix(0,ncol=nrow(x),nrow=nrow(x))

 for (i in 1:nrow(x)) {

   dismat[i,] = mahalanobis(as.matrix(x), as.matrix(x[i,]), covmat)^.5

 }

 return(dismat)

}


This piece of code works, but it is very slow. We were wondering if it's at
all possible to somehow vectorize this function.
Any help would be greatly appreciated.
Thanks,
Frank

[[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] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio

Ok Mark, it worked for the species.
I still get an error if I try with biplot (cn,sp), but it's not a problem, 
repositioning the species is enough.

Thanks once again.

Just for future consults the error that still remains:
CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total Fauna
+ Species x Environment')
Erro em match.arg(display) : 'arg' must be of length 1

or

text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
Doesn't return an error, but it's not a mirror image as expected, it's 
nonsense.


--
From: Mark Difford [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 12:22 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry again: the structure vegan uses is quite complex. Technically you
should use the extractor function scores() to extract what you want from 
the

object, e.g. scores(my.cca, display=species) or scores(my.cca,
display=cn) [centroids]. I did work out a quicker way of reversing axes,
but that seems to have gone walking...and I am not using vegan at the
moment.

Quickest hack is to make a copy of the objects you want to plot, reversing
orientations along the way. So do (my.cca is your original object):

Temp.data - scores(my.cca, display=c(sites, species, cn))

## Reverse yaxes
Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
Temp.data$species[, 2] - Temp.data$species[, 2] * -1
Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

Do this for all the things you are plotting whose axes you want reversed.
Check this against your original plot to ensure that the mirror isn't
broken.

You can then use the Temp.data with the scores() function to make your 
plot.


## Mock e.g.
points(scores(Temp.data, display=sites), pch=21)

Regards, Mark.


Rodrigo Aluizio wrote:



Thanks a lot for your help (again) Mark.
I adapted your suggestion to my analysis.
But I'm getting and error when trying to apply the new values.
The error is:

Erro em scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[,
:
 não foi posssível encontrar a função scores-

Translating:
Error at scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[,
:
 it's not possible to find the function scores-

Bellow how I applied the suggestion:
CAPpotiFTI-CAPpotiFT
scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

Any ideas? I'm trying similar things but without success.

--



Sent: Tuesday, October 07, 2008 10:34 AM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry, that will not return a result (I use several different 
ordination

packages, in most of which this is possible). What you need to do with
vegan
is the following:

scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

You will be able to do the rest.

Regards, Mark.


Mark Difford wrote:


Hi Rodrigo,


I need to rotate on y axis the lines and symbols of constrained and
sites representation.


Easiest is to multiply the axis you want to invert by -1. Something
like
the following, where my.cca is the orginal object and yax = obj[, 2]
(xax
being obj[, 1]). Obviously, copying isn't necessary.

mynew.cca - my.cca
mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

Regards, Mark.


Rodrigo Aluizio wrote:


He everybody,
Well I have a biplot CCA-like origined from plot.cca (vegan package).
I
need to rotate on y axis the lines and symbols of constrained and
sites
representation. If I do that on an image editor, I rotate everything,
including titles, axes labels and positions. I just need to rotate 
the

inner par and keep the variables names (constrained) and symbols in
the
new positions but with the right direction.
So, is there on R a way to do that while creating the image?
Here is the code that generate the graphic.

plot.cca(CAPpotiFT,type='none',display=c('bp','sites'),main='Total
Fauna
Sites x Environment')
text.cca(CAPpotiFT,dis='cn',col='black',cex=0.6,lwd=0.5,lty='dotted')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='1',],pch=21)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='2',],pch=20)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='3',],pch=22,bg='gray')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='4',],pch=24)
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='5',],pch=24,bg='black')
points(ScoresCAPFT$sites[FatoresRep$BiofaciesBC=='6',],pch=25,bg='gray')

Thanks in advice.
___
MSc. Rodrigo Aluizio
Centro de Estudos 

[R] Statistically significant in linear and non-linear model

2008-10-07 Thread Hsiao-nan Cheung
Hi,

 

I have a question to ask. if in a linear regression model, the independent
variables are not statistically significant, is it necessary to test these
variables in a non-linear model? Since most of non-linear form of a variable
can be represented to a linear combination using Taylor's theorem, so I
wonder whether the non-linear form is also not statistically significant in
such a situation.

 

Best Regards

Hsiao-nan Cheung

2008/10/08

 

 

 


[[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] sort a list?

2008-10-07 Thread rkevinburton
THank you. I just didn't know the rules. In other languages it is possible to 
pass in a 'compare' function so the sort is defined by the function. I guess I 
was a) wondering why it failed, and b) if there was a similar work around to 
sort generic lists. Also I was specifically addressing the list that I gave in 
the example not a generic list. I think I have a solution. 

Thank you.

Kevin
 Erik Iverson [EMAIL PROTECTED] wrote: 
 Since objects of class list in R can be made up of heterogeneous 
 objects, sorting them does not make much sense.  For example, does A, 
 come before or after 1000, does a linear model summary come before or 
 after pi?
 
 If your data are all numeric, store them as a numeric vector, where sort 
 works.  Vectors can be named in R, as in your example.
 
 Also, 'order' does something different than 'sort'.
 
 try the following:
 
 x - c(a = 1, b = 4, c = 2)
 sort(x)
 order(x)
 
 Hope that helps,
 Erik
 
 
 
 [EMAIL PROTECTED] wrote:
  I am trying to sort a list and the data is obiously not in the right 
  format. I am trying:
  
  x - list()
  x[[A]] - 1
  x[[B]] - 2
  
  order(x)
  
  But am getting:
  
  Error in order(x) : unimplemented type 'list' in 'orderVector1'
  
  How should I change the list so that it can be sorted? What kinds of 
  objects (classes of objects) can be sorted?
  
  Thank you.
  
  Kevin
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Programing and writing function help

2008-10-07 Thread Stephen Cole
Hello R users

My goal is to use R to write functions for and automate a series of analyses
i would like to do on a large data set.  The calculations are not very
difficult in themselves, however they will be very time consuming (Plus I
think R will be extremely useful and this is another excuse to learn how to
program).

I have a vector of 20 values

x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30)

1.
I  want to select random pairs from this data set but do it without
replacement exhaustively

I know i can select random pairs without replacement using

sample(N,n,replace=F)
However i am wondering if there is any way to get 10 random pairs from this
data set without repeating any of the data points
that is to say if i got a (20, 94) for one pair, i would like to get 9 other
pairs from the data without again getting 20 or 94?

2.
The second thing i would like to do is be able to select all possible pairs
of numbers and calculate each pairs variance.  I think i will need a for
loop here but I am unsure of how to do the programing.  I am reading two
books on S and s-plus now and hope they are some help.  I thought i would
also post on this list and get some expert advice for the more experienced R
users

Thank-you very much

Stephen Cole
Marine Ecology Lab
Saint Francis Xavier University

[[alternative HTML version deleted]]

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


Re: [R] Load a program at the front end

2008-10-07 Thread Gang Chen
Thanks for the suggestion, Luke!

Your approach would load prog.R whenever invoking R, but that is not
exactly what I want. Basically I can run prog.R through
source(~/someDir/prog.R) inside R. Also since prog.R involves many
lines of readline() and tclvalue() in tcltk package, the program
requires the user responses in the middle of the execution. If
possible, I would like to create an executable  shell script RunProg
with one line or two inside like

R ... ~/someDir/prog.R

If this is feasible, whenever I want to run prog.R, I can simply type
the following at the terminal prompt:

RunProg

and I would still be able to interact with the user. Is this something doable?

Thanks,
Gang



On Tue, Oct 7, 2008 at 12:43 PM, Luke Tierney [EMAIL PROTECTED] wrote:
 Something like

env R_PROFILE=prog.R R

 may work for you.  You may need to call .First.sys at the beginning of
 prog.R to get default packages loaded.

 luke

 On Tue, 7 Oct 2008, Gang Chen wrote:

 Thanks a lot for the suggestion!

 Unfortunately  R --no-save  prog.R does not work well with my
 situation because prog.R
 contain lines such as readline() and () that require user response in
 the middle of the
 execution. I also tried other options such as R -f prog.R and R
 --interactive  prog.R, and
 they all failed.

 Any other suggestions?

 Thanks,
 Gang


 On Mon, Oct 6, 2008 at 10:12 PM, Bernardo Rangel Tura
 [EMAIL PROTECTED] wrote:

 Em Qui, 2008-10-02 às 14:36 -0400, Gang Chen escreveu:

 I want to run a R program, prog.R,  interactively. My question is, is
 there a way I can start prog.R on the shell terminal when invoking R,
 instead of using source() inside R?

 TIA,
 Gang

 Hi Gang

 I my system just only type:

  R --no-save prog.R

 platform   x86_64-unknown-linux-gnu
 arch   x86_64
 os linux-gnu
 system x86_64, linux-gnu
 status Patched
 major  2
 minor  7.2
 year   2008
 month  09
 day11
 svn rev46532
 language   R
 version.string R version 2.7.2 Patched (2008-09-11 r46532)

 --
 Bernardo Rangel Tura, M.D,MPH,Ph.D
 National Institute of Cardiology
 Brazil

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


 --
 Luke Tierney
 Chair, Statistics and Actuarial Science
 Ralph E. Wareham Professor of Mathematical Sciences
 University of Iowa  Phone: 319-335-3386
 Department of Statistics andFax:   319-335-3017
   Actuarial Science
 241 Schaeffer Hall  email:  [EMAIL PROTECTED]
 Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


Re: [R] Statistically significant in linear and non-linear model

2008-10-07 Thread Greg Snow
Well here is one example where x is not significant in a linear regression:

 x - seq( -1,1, 0.1 )
 y - x^2 + rnorm(21,0,.1)
 summary(lm(y~x))

Would you really want to dismiss any relationship (non-linear) between x and y 
based on the above p-value?

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Hsiao-nan Cheung
 Sent: Tuesday, October 07, 2008 11:47 AM
 To: R-help
 Subject: [R] Statistically significant in linear and non-linear model

 Hi,



 I have a question to ask. if in a linear regression model, the
 independent
 variables are not statistically significant, is it necessary to test
 these
 variables in a non-linear model? Since most of non-linear form of a
 variable
 can be represented to a linear combination using Taylor's theorem, so I
 wonder whether the non-linear form is also not statistically
 significant in
 such a situation.



 Best Regards

 Hsiao-nan Cheung

 2008/10/08








 [[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] Creating GUIs for R

2008-10-07 Thread Gabor Grothendieck
I think prior posters addressed that or maybe what you really want is
a command that accepts your function and automatically constructs
a GUI front end for it.  In that case see ggenericwidget in the gWidgets
package and the fgui package.  You don't need VB at all for this.

On Tue, Oct 7, 2008 at 1:32 PM, Wade Wall [EMAIL PROTECTED] wrote:
 Sorry that my post wasn't very clear.

 What I am wanting to do is learn to build some simple GUIs for a limited
 number of functions. Basically, I am envisioning a screen with check boxes,
 a drop down menu etc. that users could select to run analyses on imported
 data.

 I have worked with VB before, but it has been several years and I am not
 sure how it interfaces with R.


 On Tue, Oct 7, 2008 at 1:20 PM, Bert Gunter [EMAIL PROTECTED] wrote:

 Seek and ye shall find ... Check the RGUI's link on the other web page on
 CRAN.

 If you are on Windows, there is some simple built-in GUI functionality.
 ?winMenuAdd, ?select.list and the links therein will get you started there.

 Cheers,
 Bert Gunter

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On
 Behalf Of Wade Wall
 Sent: Tuesday, October 07, 2008 9:56 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Creating GUIs for R

 Hi all,

 I have looked around for help on creating GUIs for R, but haven't found
 anything.  I would be interested in any advice or webpages that have
 information on the best language, tutorials etc. for creating simple GUIs.
 Mainly I want to do this as a heuristic exercise.

 Thanks for any help.

 Wade Wall

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


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


Re: [R] Statistically significant in linear and non-linear model

2008-10-07 Thread Ted Harding
On 07-Oct-08 17:46:52, Hsiao-nan Cheung wrote:
 Hi,
 I have a question to ask. if in a linear regression model, the
 independent variables are not statistically significant, is it
 necessary to test these variables in a non-linear model?
 Since most of non-linear form of a variable can be represented
 to a linear combination using Taylor's theorem,

That depends on the coefficients in the Taylor's series expansion.
It is quite possible to have the linear coefficient zero, and the
quadratic coefficient non-zero.

 so I wonder whether the non-linear form is also not statistically
 significant in such a situation.
 
 Best Regards
 Hsiao-nan Cheung
 2008/10/08

Example:

  X -  0.2*((-10):10)
  Y -  0.5*(X^2) + 0.2*rnorm(21)
  X2 - X^2

[A] Linear regression, Y on X:
  summary(lm(Y ~ X))$coef
#   Estimate Std. Error   t value Pr(|t|)
# (Intercept) 0.72840442  0.1554215 4.6866382 0.0001606966
# X   0.06570652  0.1283351 0.5119919 0.6145564688

So the coefficient of X is not significant.

[B] Quadratic regression, Y on X and X^2:
  summary(lm(Y ~ X + X2))$coef
#Estimate Std. Error t value Pr(|t|)
# (Intercept) 0.003425041 0.07203265  0.04754846 9.625997e-01
# X   0.065706524 0.03957727  1.66020864 1.141924e-01
# X2  0.494304121 0.03666239 13.48259513 7.570563e-11

So the coefficient of X is still not significant (P = 0.14),
but the coefficient of X^2 is *highly* significant!

So it all depends ... of course the original coefficients
(Taylor) could be anything.
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 07-Oct-08   Time: 19:16:04
-- XFMail --

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


Re: [R] panel.groups: use group.number to define colors

2008-10-07 Thread baptiste auguie

Hi, and thanks for your email,

I realise my example was not very good. The actual dataset I'm trying  
to plot is rather big and this oversimplified example did not make  
much sense.


I actually do need to color different subsets of the data differently  
in each panel, that's why I thought of using panel.groups. Here's a  
more realistic example:




x - seq(1, 2*pi, length=100)
numberOfCurves - 20
y1 - sapply(seq(0, pi/2, length=numberOfCurves), function(phi) sin(x 
+phi))
y2 - sapply(seq(0, pi/2, length=numberOfCurves), function(phi) cos(x 
+phi))

y - cbind(y1, y2)

fact - factor(rep(c(cos, sin), each=numberOfCurves*100))
fact2 - factor(rep(seq(0, pi, length=numberOfCurves), each=100,  
length=2*numberOfCurves*100))


my.df - data.frame(x=rep(x, length=800), y=as.vector(y), fact =  
fact, fact2 = fact2)

head(my.df)


myColors - c(grey, grey, red, rep(grey, ncol(y)-3))

xyplot(y ~ x | fact,  data = my.df, groups = fact2, type=l,
par.settings=list(superpose.line=list(col=myColors, lwd=2)),
  panel =  panel.superpose,
  panel.groups = function(..., group.number) {

panel.xyplot(...)

  })


Two things I don't like about my approach:

- I'd rather select the colors in the panel function than set a  
specific palette in par.settings, as it's not obvious to me what the  
order of the plotting will be. This is where I fail to use  
group.number correctly


- the purpose of the red line is make this particular curve stand out  
from the mess of grey curves. However, they partially cover it and I  
don't really know how to change the plotting order (or replot the red  
one only on top if it's any easier)


Hope this is a bit clearer,

Best regards,

baptiste





On 7 Oct 2008, at 18:25, Bert Gunter wrote:


Not exactly sure what you want to do, but ...

In your example, you do not need groups, since the color doesn't  
change
within the levels of the conditioning variable (fact). Hence you can  
use the
panel.number() function to choose the plotting color of each panel,  
like

this:

## .. continuing with your example

myColors - rep(c(2,4),2)

xyplot(y ~ x | fact,  data = my.df,
 panel =  function(...){
   panel.xyplot(...,col=myColors[panel.number()])
}
 )

If you actually **need** groups (to color different subsets of the  
data

within a panel differently). it does get a bit more complicated.
Incidentally, note that col is already a formal argument of  
panel.superpose

and was therefore  picked up in the ... argument of the panel.groups
function -- that's why you got the error you did when you repeated col
explicitly in the panel.xyplot call. By default, it's values are  
those of
trellis.par.get(superpose.symbol) I believe. Also, group.number  
appears to

be undefined in your code.

HTH

Cheers,
Bert Gunter

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


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


[R] weighted quantiles

2008-10-07 Thread sj
I have a set of values and their corresponding weights. I can use the
function weighted.mean to calculate the weighted mean, I would like to be
able to similarly calculate the weighted median and quantiles? Is there a
function in R that can do this?

thanks,


Spencer

[[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] Programing and writing function help

2008-10-07 Thread jim holtman
Here is one way that might work for you:

 x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30)
 # create a matrix of pairs
 matrix(sample(x), ncol=2)
  [,1] [,2]
 [1,]   14   16
 [2,]   27   20
 [3,]   26   16
 [4,]   47   15
 [5,]   35   47
 [6,]   16   18
 [7,]   14   12
 [8,]   18   26
 [9,]   45   26
[10,]   94   30
 # all possible pairs
 # create a matrix of the dimensions x*x and the the indices of the lower 
 triangle
 ind - which(lower.tri(matrix(1,length(x), length(x))), arr.ind=TRUE)
 # create the pairs
 x.pairs - cbind(x[ind[,1]], x[ind[,2]])
 str(x.pairs)
 num [1:190, 1:2] 18 45 16 47 47 15 26 14 14 12 ...
 head(x.pairs)
 [,1] [,2]
[1,]   18   20
[2,]   45   20
[3,]   16   20
[4,]   47   20
[5,]   47   20
[6,]   15   20


On Tue, Oct 7, 2008 at 1:50 PM, Stephen Cole [EMAIL PROTECTED] wrote:
 Hello R users

 My goal is to use R to write functions for and automate a series of analyses
 i would like to do on a large data set.  The calculations are not very
 difficult in themselves, however they will be very time consuming (Plus I
 think R will be extremely useful and this is another excuse to learn how to
 program).

 I have a vector of 20 values

 x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30)

 1.
 I  want to select random pairs from this data set but do it without
 replacement exhaustively

 I know i can select random pairs without replacement using

 sample(N,n,replace=F)
 However i am wondering if there is any way to get 10 random pairs from this
 data set without repeating any of the data points
 that is to say if i got a (20, 94) for one pair, i would like to get 9 other
 pairs from the data without again getting 20 or 94?

 2.
 The second thing i would like to do is be able to select all possible pairs
 of numbers and calculate each pairs variance.  I think i will need a for
 loop here but I am unsure of how to do the programing.  I am reading two
 books on S and s-plus now and hope they are some help.  I thought i would
 also post on this list and get some expert advice for the more experienced R
 users

 Thank-you very much

 Stephen Cole
 Marine Ecology Lab
 Saint Francis Xavier University

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

I looked through my scripts and found my old hack. __WARNING__: Be very
careful to check that
the mirror isn't broken and that all is in order! Make sure that you are
reversing the axes you want. In your original post you mention axis 2, i.e.
y-axis. Below you have used axis 1.

## This does axis 2
mynew.cca - my.cca
for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

plot(mynew.cca)

## This does axis 1
for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1

Regards, Mark.


Rodrigo Aluizio wrote:
 
 Ok Mark, it worked for the species.
 I still get an error if I try with biplot (cn,sp), but it's not a problem, 
 repositioning the species is enough.
 Thanks once again.
 
 Just for future consults the error that still remains:
 CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
 CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
 CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
 CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
 CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
  plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
 Fauna
 + Species x Environment')
 Erro em match.arg(display) : 'arg' must be of length 1
 
 or
 
 text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
 Doesn't return an error, but it's not a mirror image as expected, it's 
 nonsense.
 
 --
 From: Mark Difford [EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 12:22 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic
 

 Hi Rodrigo,

 Sorry again: the structure vegan uses is quite complex. Technically you
 should use the extractor function scores() to extract what you want from 
 the
 object, e.g. scores(my.cca, display=species) or scores(my.cca,
 display=cn) [centroids]. I did work out a quicker way of reversing
 axes,
 but that seems to have gone walking...and I am not using vegan at the
 moment.

 Quickest hack is to make a copy of the objects you want to plot,
 reversing
 orientations along the way. So do (my.cca is your original object):

 Temp.data - scores(my.cca, display=c(sites, species, cn))

 ## Reverse yaxes
 Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
 Temp.data$species[, 2] - Temp.data$species[, 2] * -1
 Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

 Do this for all the things you are plotting whose axes you want reversed.
 Check this against your original plot to ensure that the mirror isn't
 broken.

 You can then use the Temp.data with the scores() function to make your 
 plot.

 ## Mock e.g.
 points(scores(Temp.data, display=sites), pch=21)

 Regards, Mark.


 Rodrigo Aluizio wrote:

 Thanks a lot for your help (again) Mark.
 I adapted your suggestion to my analysis.
 But I'm getting and error when trying to apply the new values.
 The error is:

 Erro em scores(CAPpotiFTI)$species[, 2] - scores(CAPpotiFTI)$species[,
 :
  não foi posssível encontrar a função scores-

 Translating:
 Error at scores(CAPpotiFTI)$species[, 2] -
 scores(CAPpotiFTI)$species[,
 :
  it's not possible to find the function scores-

 Bellow how I applied the suggestion:
 CAPpotiFTI-CAPpotiFT
 scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
 scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

 Any ideas? I'm trying similar things but without success.

 --
 
 Sent: Tuesday, October 07, 2008 10:34 AM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic


 Hi Rodrigo,

 Sorry, that will not return a result (I use several different 
 ordination
 packages, in most of which this is possible). What you need to do with
 vegan
 is the following:

 scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

 You will be able to do the rest.

 Regards, Mark.


 Mark Difford wrote:

 Hi Rodrigo,

 I need to rotate on y axis the lines and symbols of constrained and
 sites representation.

 Easiest is to multiply the axis you want to invert by -1. Something
 like
 the following, where my.cca is the orginal object and yax = obj[, 2]
 (xax
 being obj[, 1]). Obviously, copying isn't necessary.

 mynew.cca - my.cca
 mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
 mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
 mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

 Regards, Mark.


 Rodrigo Aluizio wrote:

 He everybody,
 Well I have a biplot CCA-like origined from plot.cca (vegan
 package).
 I
 need to rotate on y axis the lines and symbols of constrained and
 sites
 representation. If I do that on an image editor, I rotate
 everything,
 including titles, axes labels and positions. I just need to rotate 
 the
 inner par and keep the variables names (constrained) and symbols in
 the
 new positions but with the right direction.
 So, is there on R a way to do that while creating the image?
 Here is the code that generate the graphic.

 

Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

Again an error, as that doesn't touch one of the data structures. You need
to extend the range to include #15, as below:

## This does axis 2
mynew.cca - my.cca
for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

Cheers, Mark.


Mark Difford wrote:
 
 Hi Rodrigo,
 
 I looked through my scripts and found my old hack. __WARNING__: Be very
 careful to check that
 the mirror isn't broken and that all is in order! Make sure that you are
 reversing the axes you want. In your original post you mention axis 2,
 i.e. y-axis. Below you have used axis 1.
 
 ## This does axis 2
 mynew.cca - my.cca
 for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1
 
 plot(mynew.cca)
 
 ## This does axis 1
 for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1
 
 Regards, Mark.
 
 
 Rodrigo Aluizio wrote:
 
 Ok Mark, it worked for the species.
 I still get an error if I try with biplot (cn,sp), but it's not a
 problem, 
 repositioning the species is enough.
 Thanks once again.
 
 Just for future consults the error that still remains:
 CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
 CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
 CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
 CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
 CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
  plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
 Fauna
 + Species x Environment')
 Erro em match.arg(display) : 'arg' must be of length 1
 
 or
 
 text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
 Doesn't return an error, but it's not a mirror image as expected, it's 
 nonsense.
 
 --
 From: Mark Difford [EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 12:22 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic
 

 Hi Rodrigo,

 Sorry again: the structure vegan uses is quite complex. Technically you
 should use the extractor function scores() to extract what you want from 
 the
 object, e.g. scores(my.cca, display=species) or scores(my.cca,
 display=cn) [centroids]. I did work out a quicker way of reversing
 axes,
 but that seems to have gone walking...and I am not using vegan at the
 moment.

 Quickest hack is to make a copy of the objects you want to plot,
 reversing
 orientations along the way. So do (my.cca is your original object):

 Temp.data - scores(my.cca, display=c(sites, species, cn))

 ## Reverse yaxes
 Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
 Temp.data$species[, 2] - Temp.data$species[, 2] * -1
 Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

 Do this for all the things you are plotting whose axes you want
 reversed.
 Check this against your original plot to ensure that the mirror isn't
 broken.

 You can then use the Temp.data with the scores() function to make your 
 plot.

 ## Mock e.g.
 points(scores(Temp.data, display=sites), pch=21)

 Regards, Mark.


 Rodrigo Aluizio wrote:

 Thanks a lot for your help (again) Mark.
 I adapted your suggestion to my analysis.
 But I'm getting and error when trying to apply the new values.
 The error is:

 Erro em scores(CAPpotiFTI)$species[, 2] -
 scores(CAPpotiFTI)$species[,
 :
  não foi posssível encontrar a função scores-

 Translating:
 Error at scores(CAPpotiFTI)$species[, 2] -
 scores(CAPpotiFTI)$species[,
 :
  it's not possible to find the function scores-

 Bellow how I applied the suggestion:
 CAPpotiFTI-CAPpotiFT
 scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
 scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

 Any ideas? I'm trying similar things but without success.

 --
 
 Sent: Tuesday, October 07, 2008 10:34 AM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic


 Hi Rodrigo,

 Sorry, that will not return a result (I use several different 
 ordination
 packages, in most of which this is possible). What you need to do
 with
 vegan
 is the following:

 scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] * -1

 You will be able to do the rest.

 Regards, Mark.


 Mark Difford wrote:

 Hi Rodrigo,

 I need to rotate on y axis the lines and symbols of constrained
 and
 sites representation.

 Easiest is to multiply the axis you want to invert by -1. Something
 like
 the following, where my.cca is the orginal object and yax = obj[, 2]
 (xax
 being obj[, 1]). Obviously, copying isn't necessary.

 mynew.cca - my.cca
 mynew.cca$scores$species[, 2] - my.cca$scores$species[, 2] * -1
 mynew.cca$scores$sites[, 2] - my.cca$scores$sites[, 2] * -1
 mynew.cca$scores$centroids[, 2] - my.cca$scores$centroids[, 2] * -1

 Regards, Mark.


 Rodrigo Aluizio wrote:

 He everybody,
 Well I have a biplot CCA-like origined from plot.cca (vegan
 package).
 I
 need to rotate on y axis the lines and symbols of constrained and
 sites
 representation. If I do that on an image editor, I rotate
 everything,
 

Re: [R] weighted quantiles

2008-10-07 Thread Frank E Harrell Jr

sj wrote:

I have a set of values and their corresponding weights. I can use the
function weighted.mean to calculate the weighted mean, I would like to be
able to similarly calculate the weighted median and quantiles? Is there a
function in R that can do this?

thanks,


Spencer


library(Hmisc)
?wtd.quantile





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


Re: [R] read.spss: variable.labels

2008-10-07 Thread Frank E Harrell Jr

[EMAIL PROTECTED] wrote:

Hi,

how can I attach variable labels originally read by read.spss() to the 
resulting variables?


pre
X - read.spss('data.sav', use.value.labels = TRUE, to.data.frame = 
TRUE, trim.factor.names = TRUE, trim_values = TRUE, reencode = UTF-8)

names(X) - tolower(names(X))
attach(X)
/pre

Thank you

Sören


library(Hmisc)
?spss.get


--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] weighted quantiles

2008-10-07 Thread Brian S Cade
Try the linear quantile regression function rq() in the quantreg package. 
For 1 sample estimates, your model would have just an intercept term. 
There is a weight argument.

quantiles.out - rq(y ~ 1, data=mydata, tau=1:9/10, weight=myweights)

would yield the 0.10, 0.20, ..., 0.80, 0.90 weighted quantile estimates.

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  [EMAIL PROTECTED]
tel:  970 226-9326



sj [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/07/2008 12:38 PM

To
r-help [EMAIL PROTECTED]
cc

Subject
[R] weighted quantiles






I have a set of values and their corresponding weights. I can use the
function weighted.mean to calculate the weighted mean, I would like to be
able to similarly calculate the weighted median and quantiles? Is there a
function in R that can do this?

thanks,


Spencer

 [[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] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio

Sorry for the mistake, I'm trying to rotate the CAP 1 axis not 2!
Ah well, I tried the this other way, but it gave me an error.
Something in the syntax, I tried to change something but didn't fix the 
error.


CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1
Erro: unexpected ',' in for(i in c(2:8,15)) 
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,


for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1
Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of limits)

Well, it needs lots of patience...

--
From: Mark Difford [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 3:50 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Again an error, as that doesn't touch one of the data structures. You need
to extend the range to include #15, as below:

## This does axis 2
mynew.cca - my.cca
for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] 
* -1


Cheers, Mark.


Mark Difford wrote:


Hi Rodrigo,

I looked through my scripts and found my old hack. __WARNING__: Be very
careful to check that
the mirror isn't broken and that all is in order! Make sure that you are
reversing the axes you want. In your original post you mention axis 2,
i.e. y-axis. Below you have used axis 1.

## This does axis 2
mynew.cca - my.cca
for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

plot(mynew.cca)

## This does axis 1
for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1

Regards, Mark.


Rodrigo Aluizio wrote:


Ok Mark, it worked for the species.
I still get an error if I try with biplot (cn,sp), but it's not a
problem,
repositioning the species is enough.
Thanks once again.

Just for future consults the error that still remains:
CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
 plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
Fauna
+ Species x Environment')
Erro em match.arg(display) : 'arg' must be of length 1

or

text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
Doesn't return an error, but it's not a mirror image as expected, it's
nonsense.

--



Sent: Tuesday, October 07, 2008 12:22 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry again: the structure vegan uses is quite complex. Technically you
should use the extractor function scores() to extract what you want 
from

the
object, e.g. scores(my.cca, display=species) or scores(my.cca,
display=cn) [centroids]. I did work out a quicker way of reversing
axes,
but that seems to have gone walking...and I am not using vegan at the
moment.

Quickest hack is to make a copy of the objects you want to plot,
reversing
orientations along the way. So do (my.cca is your original object):

Temp.data - scores(my.cca, display=c(sites, species, cn))

## Reverse yaxes
Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
Temp.data$species[, 2] - Temp.data$species[, 2] * -1
Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

Do this for all the things you are plotting whose axes you want
reversed.
Check this against your original plot to ensure that the mirror isn't
broken.

You can then use the Temp.data with the scores() function to make your
plot.

## Mock e.g.
points(scores(Temp.data, display=sites), pch=21)

Regards, Mark.


Rodrigo Aluizio wrote:



Thanks a lot for your help (again) Mark.
I adapted your suggestion to my analysis.
But I'm getting and error when trying to apply the new values.
The error is:

Erro em scores(CAPpotiFTI)$species[, 2] -
scores(CAPpotiFTI)$species[,
:
 não foi posssível encontrar a função scores-

Translating:
Error at scores(CAPpotiFTI)$species[, 2] -
scores(CAPpotiFTI)$species[,
:
 it's not possible to find the function scores-

Bellow how I applied the suggestion:
CAPpotiFTI-CAPpotiFT
scores(CAPpotiFTI)$species[,2]-scores(CAPpotiFTI)$species[,2]*-1
scores(CAPpotiFTI)$sites[,2]-scores(CAPpotiFTI)$sites[,2]*-1

Any ideas? I'm trying similar things but without success.

--



Sent: Tuesday, October 07, 2008 10:34 AM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry, that will not return a result (I use several different
ordination
packages, in most of which this is possible). What you need to do
with
vegan
is the following:

scores(mynew.cca)$species[, 2] - scores(mynew.cca)$species[, 2] 
* -1


You will be able to do the rest.

Regards, Mark.


Mark Difford wrote:


Hi Rodrigo,


I need to rotate on y axis the lines and symbols of constrained
and
sites representation.


Easiest is to multiply the axis you want to invert by -1. 

[R] RBloomberg - Converting international stock prices into $US

2008-10-07 Thread Lapushin, Dan
To all:
I'm using RBloomberg to pull historical equity prices across a range of
international markets.  Bloomberg defaults to returning stock prices to
R in local currency, for example,
 
blpGetData(conn, ALUA AR Equity, PX_LAST,start=09/30/08,
end=09/30/08)
 
returns a stock price in Argentine Peso's.  If ones use the BLPH
function directly in Excel to do this pull, you can change the currency
base using the CCY parameter set to USD.  How would I do something
comparable in R with the blpGetHistoricalData function of RBloomberg??
Obviously, I could download exchange rates and do the calculations
myself but was hoping to avoid this.
 
Thanks very much in advance,
 
Dan LaPushin
[EMAIL PROTECTED]
 

[[alternative HTML version deleted]]

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


Re: [R] How to validate model?

2008-10-07 Thread Frank E Harrell Jr

[EMAIL PROTECTED] wrote:

Hi Frank,

Thanks for your feedback! But I think we are talking about two different
things.

1) Validation: The generalization performance of the classifier. See,
for example, Studies on the Validation of Internal Rating Systems by
BIS. 


I didn't think the desire was for a classifier but instead was for a 
risk predictor.  If prediction is the goal, classification methods or 
accuracy indexes based on classifications do not work very well.




2) Calibration: Correct calibration of a PD rating system means that the
calibrated PD estimates are accurate and conform to the observed default
rates. See, for instance, An Overview and Framework for
PD Backtesting and Benchmarking, by Castermans et al. 


I'm unclear on what you mean here.  Correct calibration of a predictive 
system means that the UNcalibrated estimates are accurate (i.e., they 
don't need any calibration).  (What is PD?)




Frank, you are referring the #1 and I am referring to #2. 


Nonetheless, I would never create a rating system if my model doesn't
discriminate better than a coin toss.


For sure
Frank



Regards,

Pedro 








-Original Message-
From: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 07, 2008 11:02 AM

To: Rodriguez, Pedro
Cc: [EMAIL PROTECTED]; r-help@r-project.org
Subject: Re: [R] How to validate model?

[EMAIL PROTECTED] wrote:

Usually one validates scorecards with the ROC curve, Pietra Index, KS
test, etc. You may be interested in the WP 14 from BIS (www.bis.org).

Regards,

Pedro


No, the validation should be done using an absolute reliability 
(calibration) curve.  You need to verify that at all levels of predicted


risk there is agreement with the true probability of failure.  An ROC 
curve does not do that, and I doubt the others do.  A 
resampling-corrected loess calibration curve is a good approach as 
implemented in the Design package's calibrate function.


Frank


-Original Message-
From: [EMAIL PROTECTED]

[mailto:[EMAIL PROTECTED]

On Behalf Of Maithili Shiva
Sent: Tuesday, October 07, 2008 8:22 AM
To: r-help@r-project.org
Subject: [R] How to validate model?

Hi!

I am working on scorecard model and I have arrived at the regression
equation. I have used logistic regression using R.

My question is how do I validate this model? I do have hold out sample
of 5000 customers.

Please guide me. Problem is I had never used Logistic regression

earlier

neither I am used to credit scoring models.

Thanks in advance

Maithili

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







--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

Yes it does, but this will work. You have erroneously used a , in your
call, it should be a ., if anything. You have also inserted cca... And
the axes being switched must be conformant:

 CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15))
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1  ## you are
 writing axis 1 over axis 2; and there is no ...,cca...
Erro: unexpected ',' in for(i in c(2:8,15))   ## unexpected
comma
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,

## Using your example to switch axis 1. Make sure that CAPpotiFT exists and
is your
## original object. Copy and paste the lines below into your R console
window and run
CAPpotiFTI - CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] * -1

Cheers, Mark.


Rodrigo Aluizio wrote:
 
 Sorry for the mistake, I'm trying to rotate the CAP 1 axis not 2!
 Ah well, I tried the this other way, but it gave me an error.
 Something in the syntax, I tried to change something but didn't fix the 
 error.
 
 CAPpotiFTI-CAPpotiFT
  for(i in c(2:8,15))
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1
 Erro: unexpected ',' in for(i in c(2:8,15)) 
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,
 
  for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1
 Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of limits)
 
 Well, it needs lots of patience...
 
 --
 From: Mark Difford [EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 3:50 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic
 

 Hi Rodrigo,

 Again an error, as that doesn't touch one of the data structures. You
 need
 to extend the range to include #15, as below:

 ## This does axis 2
 mynew.cca - my.cca
 for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] 
 * -1

 Cheers, Mark.


 Mark Difford wrote:

 Hi Rodrigo,

 I looked through my scripts and found my old hack. __WARNING__: Be very
 careful to check that
 the mirror isn't broken and that all is in order! Make sure that you are
 reversing the axes you want. In your original post you mention axis 2,
 i.e. y-axis. Below you have used axis 1.

 ## This does axis 2
 mynew.cca - my.cca
 for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

 plot(mynew.cca)

 ## This does axis 1
 for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1

 Regards, Mark.


 Rodrigo Aluizio wrote:

 Ok Mark, it worked for the species.
 I still get an error if I try with biplot (cn,sp), but it's not a
 problem,
 repositioning the species is enough.
 Thanks once again.

 Just for future consults the error that still remains:
 CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
 CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
 CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
 CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
 CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
  plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
 Fauna
 + Species x Environment')
 Erro em match.arg(display) : 'arg' must be of length 1

 or

 text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
 Doesn't return an error, but it's not a mirror image as expected, it's
 nonsense.

 --
 
 Sent: Tuesday, October 07, 2008 12:22 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic


 Hi Rodrigo,

 Sorry again: the structure vegan uses is quite complex. Technically
 you
 should use the extractor function scores() to extract what you want 
 from
 the
 object, e.g. scores(my.cca, display=species) or scores(my.cca,
 display=cn) [centroids]. I did work out a quicker way of reversing
 axes,
 but that seems to have gone walking...and I am not using vegan at the
 moment.

 Quickest hack is to make a copy of the objects you want to plot,
 reversing
 orientations along the way. So do (my.cca is your original object):

 Temp.data - scores(my.cca, display=c(sites, species, cn))

 ## Reverse yaxes
 Temp.data$sites[, 2] - Temp.data$sites[, 2] * -1
 Temp.data$species[, 2] - Temp.data$species[, 2] * -1
 Temp.data$centroid[, 2] - Temp.data$centroid[, 2] * -1

 Do this for all the things you are plotting whose axes you want
 reversed.
 Check this against your original plot to ensure that the mirror isn't
 broken.

 You can then use the Temp.data with the scores() function to make your
 plot.

 ## Mock e.g.
 points(scores(Temp.data, display=sites), pch=21)

 Regards, Mark.


 Rodrigo Aluizio wrote:

 Thanks a lot for your help (again) Mark.
 I adapted your suggestion to my analysis.
 But I'm getting and error when trying to apply the new values.
 The error is:

 Erro em scores(CAPpotiFTI)$species[, 2] -
 scores(CAPpotiFTI)$species[,
 :
  não foi posssível encontrar a função scores-

 Translating:
 Error at scores(CAPpotiFTI)$species[, 2] -
 scores(CAPpotiFTI)$species[,
 :
  it's not possible to find the function scores-

 Bellow how I applied the 

Re: [R] Ecological Niche Modelling on R

2008-10-07 Thread stephen sefick
that is a pretty big question.  And I am not qualified to answer it,
but my suggestion- from figuring out how to use other things- is to
find out how other people have modeled ecological niches- not
necessarily with R,  and then try and find out functions that preform
the pieces or the whole analysis.  I believe there is a book out there
about modeling ecological niches with R.  I did  a google search for
that and this is what I found:
http://www.zoology.ufl.edu/bolker/emdbook/.  I don't know if this
helps, but maybe it will.  Good luck.

On Tue, Oct 7, 2008 at 12:46 PM, milton ruser [EMAIL PROTECTED] wrote:
 Dear all,
 I have strong interest on Ecological Niche Model, which in general use a set
 of environmental variables (continuous, categorical etc) and Presence (or
 Presense/Absence) records for species. I think that grasp and adehabitat
 packages could help me on these tasks.
 My input layers are on ASC format, and the record of species is a data-frame
 with X, Y, name of species. Note that in general we don´t have real absence
 data.

 Could someone give some advice how can I use grasp and/or adehabitat to
 generate my predictive models?

 Best regards,

 Miltinho AStronauta
 brazil

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





-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

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


Re: [R] panel.groups: use group.number to define colors

2008-10-07 Thread Deepayan Sarkar
On Tue, Oct 7, 2008 at 8:54 AM, baptiste auguie [EMAIL PROTECTED] wrote:
 Dear list,


 I've been trying this for a few hours and I just don't understand how
 lattice works with groups and subscripts.

 Consider the following example,



 xx - seq(1, 10, length=100)
 x - rep(xx, 4)
 y - c(cos(xx), sin(xx), xx, xx^2/10)
 fact - factor(rep(c(cos, sin, id, square), each=100))
 fact2 - factor(rep(c(periodic, not periodic), each=100))

 my.df - data.frame(x=x, y=y, fact = fact, fact2 = fact2)

 head(my.df)


 myColors - c(2, 4)

xyplot(y ~ x | fact,  data = my.df, groups = fact2,
  panel =  panel.superpose,
  panel.groups = function(..., group.number) {

 panel.xyplot(...)
#panel.xyplot( ..., col=myColors[group.number]) #
 error

  })


 My aim is to assign a custom color to each group, but for some reason the
 col parameter is already given to panel.xyplot and I can't find where it
 gets the values from.

It get's the values from the 'panel.superpose' function, of which
'panel.groups' is an argument. Both the documentation and source code
for 'panel.superpose' should make this clear.

From what I understand, what you want should be as simple as (with a
small correction to your example):


xx - seq(1, 10, length=100)
x - rep(xx, 4)
y - c(cos(xx), sin(xx), xx, xx^2/10)
fact - factor(rep(c(cos, sin, id, square), each=100))
fact2 - factor(rep(c(periodic, not periodic), each=200))
my.df - data.frame(x=x, y=y, fact = fact, fact2 = fact2)

myColors - c(2, 4)

xyplot(y ~ x | fact,  data = my.df, groups = fact2, col = myColors, type = l)


The use of 'par.settings' is not compulsory, but would help if you
needed to add a legend; e.g.,


xyplot(y ~ x | fact,  data = my.df, groups = fact2, type = l,
   par.settings = simpleTheme(col = myColors),
   auto.key = list(lines = TRUE, points = FALSE))


If you insist on writing your own panel function, what you need is


xyplot(y ~ x | fact,  data = my.df, groups = fact2,
   panel =  panel.superpose,
   panel.groups = function(..., col.line, type, group.number) {
   panel.xyplot(..., type = l,
col.line = myColors[group.number])
   })


As Bert pointed out, you are responsible for ensuring that argument
names are not repeated by capturing and overriding them.

All of this applies to your second, more complicated, example as well.
As for the order in which the groups are plotted, it is the order of
levels(fact2), which seemed to me the most obvious (or at least the
least surprising) choice. You are free to specify the order when you
create the factor; see ?factor to learn how.

-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] Mac crash- Probably memory problem

2008-10-07 Thread stephen sefick
not reproducible.

On Tue, Oct 7, 2008 at 11:35 AM, dimitris kapetanakis [EMAIL PROTECTED] wrote:

 Dear all,

 I am running a code using bootstraps for estimating standard errors but the
 mac crashes. When I use small number of bootstraps (100) it works fine but
 if I increase that number it crashes.

 Thanks in advance

 dimitris

 The code, the error and my mac characteristics are the following:

 ##code#
 qr.1- rq(y~factor(year)+factor(state)+x1+I(x^2)+I(x^3), tau=0.05,
 data=data1)

 s.qr1.05 - summary(qr.1, se=boot, R=1000)$coefficient

 ##error#

  *** caught segfault ***
 address 0x1de9e000, cause 'memory not mapped'

 Traceback:
  1: .Fortran(xys, as.integer(m), as.integer(n), as.integer(p),
 as.integer(R), as.integer(m + 5), as.integer(p + 2), as.double(x),
 as.double(y), as.double(tau), as.double(tol), flag = integer(R), coef =
 double(p * R), resid = double(m), integer(m), double((m + 5) * (p +
 2)), double(m), xx = double(m * p), yy = double(m), as.integer(s),
 PACKAGE = quantreg)
  2: boot.rq.xy(x, y, s, tau)
  3: boot.rq(x, y, tau, ...)
  4: summary.rq(qr.05.nox, se = boot, R = 1000)
  5: summary(qr.05.nox, se = boot, R = 1000)

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace
 Selection:

 ###characteristics#
 Mac OS X

 version 10.5.4

 Model Name: MacBook
  Model Identifier: MacBook4,1
  Processor Name:   Intel Core 2 Duo
  Processor Speed:  2.4 GHz
  Number Of Processors: 1
  Total Number Of Cores:2
  L2 Cache: 3 MB
  Memory:   4 GB
  Bus Speed:800 MHz
  Boot ROM Version: MB41.00C1.B00





 --
 View this message in context: 
 http://www.nabble.com/Mac-crash--Probably-memory-problem-tp19860892p19860892.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.




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

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

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


Re: [R] panel.groups: use group.number to define colors

2008-10-07 Thread baptiste auguie
Many thanks, I think I got the spirit of 'capturing and overriding'  
the arguments which was the bit i was missing. It's much clearer now  
with a working example.


Thanks again,

baptiste


On 7 Oct 2008, at 21:19, Deepayan Sarkar wrote:

On Tue, Oct 7, 2008 at 8:54 AM, baptiste auguie [EMAIL PROTECTED]  
wrote:

Dear list,


I've been trying this for a few hours and I just don't understand how
lattice works with groups and subscripts.

Consider the following example,




xx - seq(1, 10, length=100)
x - rep(xx, 4)
y - c(cos(xx), sin(xx), xx, xx^2/10)
fact - factor(rep(c(cos, sin, id, square), each=100))
fact2 - factor(rep(c(periodic, not periodic), each=100))

my.df - data.frame(x=x, y=y, fact = fact, fact2 = fact2)

head(my.df)


myColors - c(2, 4)

  xyplot(y ~ x | fact,  data = my.df, groups = fact2,
panel =  panel.superpose,
panel.groups = function(..., group.number) {

   panel.xyplot(...)
  #panel.xyplot( ...,  
col=myColors[group.number]) #

error

})



My aim is to assign a custom color to each group, but for some  
reason the
col parameter is already given to panel.xyplot and I can't find  
where it

gets the values from.


It get's the values from the 'panel.superpose' function, of which
'panel.groups' is an argument. Both the documentation and source code
for 'panel.superpose' should make this clear.

From what I understand, what you want should be as simple as (with a
small correction to your example):


xx - seq(1, 10, length=100)
x - rep(xx, 4)
y - c(cos(xx), sin(xx), xx, xx^2/10)
fact - factor(rep(c(cos, sin, id, square), each=100))
fact2 - factor(rep(c(periodic, not periodic), each=200))
my.df - data.frame(x=x, y=y, fact = fact, fact2 = fact2)

myColors - c(2, 4)

xyplot(y ~ x | fact,  data = my.df, groups = fact2, col = myColors,  
type = l)



The use of 'par.settings' is not compulsory, but would help if you
needed to add a legend; e.g.,


xyplot(y ~ x | fact,  data = my.df, groups = fact2, type = l,
  par.settings = simpleTheme(col = myColors),
  auto.key = list(lines = TRUE, points = FALSE))


If you insist on writing your own panel function, what you need is


xyplot(y ~ x | fact,  data = my.df, groups = fact2,
  panel =  panel.superpose,
  panel.groups = function(..., col.line, type, group.number) {
  panel.xyplot(..., type = l,
   col.line = myColors[group.number])
  })


As Bert pointed out, you are responsible for ensuring that argument
names are not repeated by capturing and overriding them.

All of this applies to your second, more complicated, example as well.
As for the order in which the groups are plotted, it is the order of
levels(fact2), which seemed to me the most obvious (or at least the
least surprising) choice. You are free to specify the order when you
create the factor; see ?factor to learn how.

-Deepayan


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


Re: [R] lme and lmer df's and F-statistics again

2008-10-07 Thread Kingsford Jones
You may find this site useful:

http://lme4.r-forge.r-project.org/bib/lme4bib.html


On Tue, Oct 7, 2008 at 9:08 AM, Dieter Menne
[EMAIL PROTECTED] wrote:
 Julia S. julia.schroeder at gmail.com writes:

 Now, I did that in my article and I got a response from a reviewer that I
 additionally should give the degrees of freedom, and the F-statistics. From
 what I read here, that would be incorrect to do, and I sort of intuitively
 also understand why (at least I think I do).
 ...
 Well, writing on my rebuttal, I find myself being unable to explain in a
 few, easy to understand (and, at the same time, correct) sentences stating
 that it is not a good idea to report (most likely wrong) dfs and F
 statistics. Can somebody here help me out with a correct explanation for a
 laymen?

 Feeling with you, and hoping some day this will be resolved. I am sure you
 have read Douglas Bates'

 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76742.html

 but I thought this was temporary. The only workaround I have is not to use
 lmer for gaussian models.

 Dieter

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vectorized sub, gsub, grep, etc.

2008-10-07 Thread Thaden, John J
R pattern-matching and replacement functions are
vectorized: they can operate on vectors of targets.
However, they can only use one pattern and replacement.
Here is code to apply a different pattern and replacement
for every target.  My question: can it be done better?

sub2 - function(pattern, replacement, x) {
len - length(x)
if (length(pattern) == 1) 
pattern - rep(pattern, len)
if (length(replacement) == 1) 
replacement - rep(replacement, len)
FUN - function(i, ...) {
sub(pattern[i], replacement[i], x[i], fixed = TRUE)
}
idx - 1:length(x)
sapply(idx, FUN)
}

#Example
X - c(ab, cd, ef)
patt - c(b, cd, a)
repl - c(B, CD, A)
sub2(patt, repl, X)

-John

Confidentiality Notice: This e-mail message, including a...{{dropped:8}}

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio

Well this time I have to assume, I'm not understanding what is wrong now.
And I have to say: 'Thank You for your patience', cause I'm going crazy 
here! :-)


Mark, I tried this:

CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] * -1

and got this:

Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of limits)

Here is the script until this point

library(vegan)
library(xlsReadWrite)
#FT--#
PotiAbioFT-read.xls('FatorialReplica.xls',sheet=4,rowNames=T)
PotiBioFT-read.xls('FatorialReplica.xls',sheet=6,rowNames=T)
attach(PotiAbioFT)
LogPotiBioFT-log(PotiBioFT+1)
CAPpotiFT-capscale(t(LogPotiBioFT)~Envoronmental+Variables,dist=bray,add=T)
PermCAPFT-anova.cca(CAPpotiFT,alpha=0.05,model='full',first=F,permutations=999)
PermCAPFT
summary(CAPpotiFT)
# Rotating the axis
CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] * -1



--
From: Mark Difford [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 5:17 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Yes it does, but this will work. You have erroneously used a , in your
call, it should be a ., if anything. You have also inserted cca... And
the axes being switched must be conformant:


CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1  ## you are
writing axis 1 over axis 2; and there is no ...,cca...

Erro: unexpected ',' in for(i in c(2:8,15))   ## unexpected

comma

CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,


## Using your example to switch axis 1. Make sure that CAPpotiFT exists 
and

is your
## original object. Copy and paste the lines below into your R console
window and run
CAPpotiFTI - CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] 
* -1


Cheers, Mark.


Rodrigo Aluizio wrote:



[[elided Yahoo spam]]

Ah well, I tried the this other way, but it gave me an error.
Something in the syntax, I tried to change something but didn't fix the
error.

CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1
Erro: unexpected ',' in for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,

 for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1
Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of 
limits)


Well, it needs lots of patience...

--



Sent: Tuesday, October 07, 2008 3:50 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Again an error, as that doesn't touch one of the data structures. You
need
to extend the range to include #15, as below:

## This does axis 2
mynew.cca - my.cca
for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2]
* -1

Cheers, Mark.


Mark Difford wrote:


Hi Rodrigo,

I looked through my scripts and found my old hack. __WARNING__: Be very
careful to check that
the mirror isn't broken and that all is in order! Make sure that you 
are

reversing the axes you want. In your original post you mention axis 2,
i.e. y-axis. Below you have used axis 1.

## This does axis 2
mynew.cca - my.cca
for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

plot(mynew.cca)

## This does axis 1
for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1

Regards, Mark.


Rodrigo Aluizio wrote:


Ok Mark, it worked for the species.
I still get an error if I try with biplot (cn,sp), but it's not a
problem,
repositioning the species is enough.
Thanks once again.

Just for future consults the error that still remains:
CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
 plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
Fauna
+ Species x Environment')
Erro em match.arg(display) : 'arg' must be of length 1

or

text.cca(scores(CAPpotiFTI$biplot),col=323232,cex=0.6,lwd=2,lty='dotted')
Doesn't return an error, but it's not a mirror image as expected, it's
nonsense.

--



Sent: Tuesday, October 07, 2008 12:22 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Sorry again: the structure vegan uses is quite complex. Technically
you
should use the extractor function scores() to extract what you want
from
the
object, e.g. scores(my.cca, display=species) or scores(my.cca,
display=cn) [centroids]. I did work out a quicker way of reversing
axes,
but that seems to have gone walking...and I am not using vegan at the
moment.

Quickest hack is to make a copy of the objects you want to plot,
reversing
orientations along the way. So do (my.cca is your original object):

Temp.data - 

Re: [R] vectorized sub, gsub, grep, etc.

2008-10-07 Thread N. Lapidus
Hi John,

Wouldn't you get the same with just mapply(sub, patt, repl, X) ?

Nael


On Tue, Oct 7, 2008 at 9:58 PM, Thaden, John J [EMAIL PROTECTED] wrote:

 R pattern-matching and replacement functions are
 vectorized: they can operate on vectors of targets.
 However, they can only use one pattern and replacement.
 Here is code to apply a different pattern and replacement
 for every target.  My question: can it be done better?

 sub2 - function(pattern, replacement, x) {
len - length(x)
if (length(pattern) == 1)
pattern - rep(pattern, len)
if (length(replacement) == 1)
replacement - rep(replacement, len)
FUN - function(i, ...) {
sub(pattern[i], replacement[i], x[i], fixed = TRUE)
}
idx - 1:length(x)
sapply(idx, FUN)
 }

 #Example
 X - c(ab, cd, ef)
 patt - c(b, cd, a)
 repl - c(B, CD, A)
 sub2(patt, repl, X)

 -John

 Confidentiality Notice: This e-mail message, including a...{{dropped:8}}

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


[[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] vectorized sub, gsub, grep, etc.

2008-10-07 Thread Christos Hatzis
John,
Try the following:

 mapply(function(p, r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, x=X)
   b   cda 
aB CD ef  

-Christos

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Thaden, John J
 Sent: Tuesday, October 07, 2008 3:59 PM
 To: r-help@r-project.org
 Cc: [EMAIL PROTECTED]
 Subject: [R] vectorized sub, gsub, grep, etc.
 
 R pattern-matching and replacement functions are
 vectorized: they can operate on vectors of targets.
 However, they can only use one pattern and replacement.
 Here is code to apply a different pattern and replacement for 
 every target.  My question: can it be done better?
 
 sub2 - function(pattern, replacement, x) {
 len - length(x)
 if (length(pattern) == 1) 
 pattern - rep(pattern, len)
 if (length(replacement) == 1) 
 replacement - rep(replacement, len)
 FUN - function(i, ...) {
 sub(pattern[i], replacement[i], x[i], fixed = TRUE)
 }
 idx - 1:length(x)
 sapply(idx, FUN)
 }
 
 #Example
 X - c(ab, cd, ef)
 patt - c(b, cd, a)
 repl - c(B, CD, A)
 sub2(patt, repl, X)
 
 -John
 
 Confidentiality Notice: This e-mail message, including 
 a...{{dropped:8}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Multiple hist(ograms) - One plot

2008-10-07 Thread Michael Just
Deepayan,
Thanks for the advice.

-Micahel

On Fri, Oct 3, 2008 at 1:24 AM, Deepayan Sarkar
[EMAIL PROTECTED]wrote:

 On 10/2/08, Michael Just [EMAIL PROTECTED] wrote:
  Dieter and Thierry:
 
   Per you suggestions I have tried:
 
   ggplot2 from Thierry:
 
   p - ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()
 
   p + facet_grid(. ~ sc_recov %in% c(21,31,41))
 
   But get the followinng error:
 
  Error in check_formula(formula, varnames) :
Formula contains variables not in list of known variables
 
 
  If I don't make selections it works, but makes that very busy plot.
 
   histogram from Dieter:
histogram(~bbContag | sc_recov %in% c(21,31,41), data=dat)
   This produces a plot with only two histograms side by side, but I have
   chosen three groups, where is the third? I tried only choosing two
 groups
   and it plotted two histograms different than when I tried choosing
 three.

 Actually, Dieter's suggestion was to use the subset argument, which
 would go something like

 histogram(~bbContag | sc_recov, data=dat,
  subset = (sc_recov %in% c(21,31,41)))

 Given that your 'sc_recov' seems to be a numeric variable, you will
 probably get better annotation with

 histogram(~bbContag | factor(sc_recov), data=dat,
  subset = (sc_recov %in% c(21,31,41)))

 -Deepayan

   Please advise,
   Thank you for your continued help,
   Michael Just
 
 
 
   On Thu, Oct 2, 2008 at 5:21 AM, ONKELINX, Thierry
 
  [EMAIL PROTECTED]wrote:
 
Michael,
   
Use %in% to select multiple cases:
   
dat[dat$sc_recov %in% c(21, 31, 41), ]
   
   
   
 

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
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: [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED]
Namens Michael Just
Verzonden: donderdag 2 oktober 2008 10:59
Aan: r-help@r-project.org
CC: [EMAIL PROTECTED]
Onderwerp: Re: [R] Multiple hist(ograms) - One plot
   
Dieter Menne:
Thanks for the suggestion and link, it looks good. I think my trouble
now is
lack of basic R knowledge.
   
Cheers,
Michael
   
For example,
   
I tried:
histogram(~bbContag | sc_recov, data=dat)
   
This would work fine if I could select cases from sc_recov. How can I
select
more than one case? I know I can do:
   
sc_recov.21 - dat[dat$sc_recov=21,]
   
but how could I select all cases where sc_recov = 21, 31 or 41?
   
   
On Thu, Oct 2, 2008 at 3:33 AM, Michael Just [EMAIL PROTECTED]
 wrote:
   
 Hello,
 If I use:

 p - ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()

 and then:

 p + facet_grid(. ~ sc_recov)

 Its a little crazy because I have 48 different values in 'sc_recov'.
 Instead I want to select cases from 'sc_recov' and only use three at
 a
time:

 I tried:
  p + facet_grid(sc_recov==21 ~.)
 Error in check_formula(formula, varnames) :
   Formula contains variables not in list of known variables

 How can I select cases?

 Any ideas or suggestions?
 Thanks,
 M Just

 On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry 
 [EMAIL PROTECTED] wrote:

 Dear Michael,

 Try ggplot2. Use something like

 install.packages(ggplot2)
 library(ggplot2)
 recov - 0:2
 n - 1000
 all - data.frame(bbED = rnorm(3 * n, mean = recov), recov =
 factor(rep(recov, n)))
 ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(.
 ~
 recov)
 ggplot(data = all, aes(x = bbED)) + geom_histogram() +
facet_grid(recov
 ~ .)
 ggplot(data = all, aes(x = bbED, colour = recov)) + geom_density()

 You'll find more information on ggplot2 at
 http://had.co.nz/ggplot2/

 HTH,

 Thierry


   
 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for
Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 

Re: [R] Multiple hist(ograms) - One plot

2008-10-07 Thread Michael Just
Thierry,
Thanks. This worked.

Cheers,
Michael

On Fri, Oct 3, 2008 at 2:46 AM, ONKELINX, Thierry
[EMAIL PROTECTED]wrote:

  Michael,

 You get this error because you make the subset at the wrong place. Try

 p - ggplot(dat[dat$sc_recov %in% c(21,31,41), ], aes(x=bbContag,
 y=..density..)) + geom_histogram()
 p + facet_grid(. ~ sc_recov)

 or

 subdat - dat[dat$sc_recov %in% c(21,31,41), ]
 p - ggplot(subdat, aes(x=bbContag, y=..density..)) + geom_histogram()
 p + facet_grid(. ~ sc_recov)
 HTH,

 Thierry


 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
 Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 [EMAIL PROTECTED]
 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


  --
 *Van:* Michael Just [mailto:[EMAIL PROTECTED]
 *Verzonden:* vrijdag 3 oktober 2008 6:52
 *Aan:* ONKELINX, Thierry
 *CC:* r-help@r-project.org; [EMAIL PROTECTED]

 *Onderwerp:* Re: [R] Multiple hist(ograms) - One plot

  Dieter and Thierry:

 Per you suggestions I have tried:

 ggplot2 from Thierry:
  p - ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()
  p + facet_grid(. ~ sc_recov %in% c(21,31,41))

 But get the followinng error:
 Error in check_formula(formula, varnames) :
   Formula contains variables not in list of known variables

 If I don't make selections it works, but makes that very busy plot.

 histogram from Dieter:
  histogram(~bbContag | sc_recov %in% c(21,31,41), data=dat)
 This produces a plot with only two histograms side by side, but I have
 chosen three groups, where is the third? I tried only choosing two groups
 and it plotted two histograms different than when I tried choosing three.

 Please advise,
 Thank you for your continued help,
 Michael Just



 On Thu, Oct 2, 2008 at 5:21 AM, ONKELINX, Thierry 
 [EMAIL PROTECTED] wrote:

 Michael,

 Use %in% to select multiple cases:

 dat[dat$sc_recov %in% c(21, 31, 41), ]


 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 [EMAIL PROTECTED]
 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Namens Michael Just
 Verzonden: donderdag 2 oktober 2008 10:59
 Aan: r-help@r-project.org
 CC: [EMAIL PROTECTED]
 Onderwerp: Re: [R] Multiple hist(ograms) - One plot

 Dieter Menne:
 Thanks for the suggestion and link, it looks good. I think my trouble
 now is
 lack of basic R knowledge.

 Cheers,
 Michael

 For example,

 I tried:
 histogram(~bbContag | sc_recov, data=dat)

 This would work fine if I could select cases from sc_recov. How can I
 select
 more than one case? I know I can do:

 sc_recov.21 - dat[dat$sc_recov=21,]

 but how could I select all cases where sc_recov = 21, 31 or 41?


 On Thu, Oct 2, 2008 at 3:33 AM, Michael Just [EMAIL PROTECTED] wrote:

  Hello,
  If I use:
 
  p - ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()
 
  and then:
 
  p + facet_grid(. ~ sc_recov)
 
  Its a little crazy because I have 48 different values in 'sc_recov'.
  Instead I want to select cases from 'sc_recov' and only use three at a
 time:
 
  I tried:
   p + facet_grid(sc_recov==21 ~.)
  Error in check_formula(formula, varnames) :
Formula contains variables not in list of known variables
 
  How can I select cases?
 
  Any ideas or suggestions?
  Thanks,
  M Just
 
  On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry 
  [EMAIL PROTECTED] wrote:
 
  Dear Michael,
 
  Try ggplot2. Use something like
 
  install.packages(ggplot2)
  library(ggplot2)
  recov - 0:2
  n - 1000
  all - data.frame(bbED = rnorm(3 * n, mean = recov), recov =
  factor(rep(recov, n)))
  ggplot(data = all, aes(x = bbED)) + geom_histogram() + 

[R] Factor tutorial?

2008-10-07 Thread rkevinburton
This is probably a very basic question. I want to understand factors but I am 
not sure where to turn. Looking up factor in the Chambers book doesn't even 
show up in the index. Maybe I am just slow but ?factor doesn't help either. 
Would someone please point me to a very basic tutorial where I can see what the 
usefullness of factors is (so far they have just gotten in the way).

Thank you.

Kevin

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


Re: [R] Ecological Niche Modelling on R

2008-10-07 Thread Ben Bolker
stephen sefick ssefick at gmail.com writes:

 
 that is a pretty big question.  And I am not qualified to answer it,
 but my suggestion- from figuring out how to use other things- is to
 find out how other people have modeled ecological niches- not
 necessarily with R,  and then try and find out functions that preform
 the pieces or the whole analysis.  I believe there is a book out there
 about modeling ecological niches with R.  I did  a google search for
 that and this is what I found:
 http://www.zoology.ufl.edu/bolker/emdbook/. 

 [snip]
 
 On Tue, Oct 7, 2008 at 12:46 PM, 
milton ruser milton.ruser at gmail.com wrote:
  Dear all,
  I have strong interest on Ecological Niche Model, which in general 
  use a set
  of environmental variables (continuous, categorical etc) and Presence (or
  Presense/Absence) records for species. I think that grasp 
  and adehabitat
  packages could help me on these tasks.
[snip]  Note that in general we 
  don´t have real absence
  data.
 

  It's very kind of Stephen to plug my book, but it's not
what you're looking for. 

  You need to read more about this general topic, and about
the particular packages: try

http://www.unine.ch/CSCF/grasp/grasp-r/index.html
http://www.unine.ch/CSCF/grasp/

  Based on downloading grasp , it doesn't look as though
it will handle presence-only data, though -- you may need
to look further.

 It doesn't look like adehabitat is what you want.
From Calenge, Clement. 2006. The package adehabitat for the 
R software: A tool
for the analysis of space and habitat use by animals. 
Ecological Modelling 197,
no. 3-4 (August 25): 516-519. doi:10.1016/j.ecolmodel.2006.03.017.

' ... the “adehabitat” package for the R software, which offers basic GIS
(Geographic Information System) functions, methods to analyze radio-tracking
data and habitat selection by wildlife, and interfaces with other R packages.'

  General advice about I want to do X in R -- (expanding
on Stephen's advice above):

1. read about X in general (perhaps you have already done this);
2. search for R packages and functions that do what you want
  (you've already done this, although you misidentified adehabitat
3. install those packages and see what they do.  Look at the
documentation included with the packages, including any citations
referenced.  Try the examples.
4. If you don't know enough R to understand the examples or how
to get your data into R, back up and read the introductory R
documentation.

  If you get stuck again, you might want to try this query
on the r-sig-eco mailing list.

  cheers
Ben Bolker

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Mark Difford

Hi Rodrigo,

This is because [I now see] you are working on a capscale object, not a cca
object, which is what I thought you were using. It still works, though, even
with c(2:8,15), though DF #15 doesn't exist in capscale objects. To show you
that this is so, run the example below, which uses a data set from vegan. I
have dropped #15 from the selection set.

## Ex. of switching axes of capscale object
windows(); par(mfrow=c(2,2))
data(varespec)
data(varechem)
vare.cap - capscale(varespec ~ N + P + K + Condition(Al), varechem,
dist=bray)
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 1]-vare.cap$CCA[[i]][, 1] * -1
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 2]-vare.cap$CCA[[i]][, 2] * -1
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 1:2]-vare.cap$CCA[[i]][, 1:2] * -1
plot(vare.cap)

Cheers, Mark.


Rodrigo Aluizio wrote:
 
 Well this time I have to assume, I'm not understanding what is wrong now.
 And I have to say: 'Thank You for your patience', cause I'm going crazy 
 here! :-)
 
 Mark, I tried this:
 
 CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] *
 -1
 
 and got this:
 
 Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of limits)
 
 Here is the script until this point
 
 library(vegan)
 library(xlsReadWrite)
 #FT--#
 PotiAbioFT-read.xls('FatorialReplica.xls',sheet=4,rowNames=T)
 PotiBioFT-read.xls('FatorialReplica.xls',sheet=6,rowNames=T)
 attach(PotiAbioFT)
 LogPotiBioFT-log(PotiBioFT+1)
 CAPpotiFT-capscale(t(LogPotiBioFT)~Envoronmental+Variables,dist=bray,add=T)
 PermCAPFT-anova.cca(CAPpotiFT,alpha=0.05,model='full',first=F,permutations=999)
 PermCAPFT
 summary(CAPpotiFT)
 # Rotating the axis
 CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] *
 -1
 
 
 
 --
 From: Mark Difford [EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 5:17 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic
 

 Hi Rodrigo,

 Yes it does, but this will work. You have erroneously used a , in your
 call, it should be a ., if anything. You have also inserted cca...
 And
 the axes being switched must be conformant:

 CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15))
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1  ## you are
 writing axis 1 over axis 2; and there is no ...,cca...
Erro: unexpected ',' in for(i in c(2:8,15))   ## unexpected
 comma
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,

 ## Using your example to switch axis 1. Make sure that CAPpotiFT exists 
 and
 is your
 ## original object. Copy and paste the lines below into your R console
 window and run
 CAPpotiFTI - CAPpotiFT
 for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] 
 * -1

 Cheers, Mark.


 Rodrigo Aluizio wrote:

 [[elided Yahoo spam]]
 Ah well, I tried the this other way, but it gave me an error.
 Something in the syntax, I tried to change something but didn't fix the
 error.

 CAPpotiFTI-CAPpotiFT
  for(i in c(2:8,15))
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1
 Erro: unexpected ',' in for(i in c(2:8,15))
 CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,

  for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1
 Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of 
 limits)

 Well, it needs lots of patience...

 --
 
 Sent: Tuesday, October 07, 2008 3:50 PM
 To: r-help@r-project.org
 Subject: Re: [R] Mirror Image on Biplot Graphic


 Hi Rodrigo,

 Again an error, as that doesn't touch one of the data structures. You
 need
 to extend the range to include #15, as below:

 ## This does axis 2
 mynew.cca - my.cca
 for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2]
 * -1

 Cheers, Mark.


 Mark Difford wrote:

 Hi Rodrigo,

 I looked through my scripts and found my old hack. __WARNING__: Be
 very
 careful to check that
 the mirror isn't broken and that all is in order! Make sure that you 
 are
 reversing the axes you want. In your original post you mention axis 2,
 i.e. y-axis. Below you have used axis 1.

 ## This does axis 2
 mynew.cca - my.cca
 for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] * -1

 plot(mynew.cca)

 ## This does axis 1
 for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] * -1

 Regards, Mark.


 Rodrigo Aluizio wrote:

 Ok Mark, it worked for the species.
 I still get an error if I try with biplot (cn,sp), but it's not a
 problem,
 repositioning the species is enough.
 Thanks once again.

 Just for future consults the error that still remains:
 CAPpotiFTI-scores(CAPpotiFT, display=c('bp','species','cn','sites')
 CAPpotiFTI$species[,1]-CAPpotiFTI$species[,1]*-1
 CAPpotiFTI$cn[,1]-CAPpotiFTI$cn[,1]*-1
 CAPpotiFTI$sites[,1]-CAPpotiFTI$sites[,1]*-1
 CAPpotiFTI$bp[,1]-CAPpotiFTI$bp[,1]*-1
 
 plot.cca(CAPpotiFTI,type='none',display=c('bp','species'),main='Total
 Fauna
 + 

Re: [R] lme and lmer df's and F-statistics again

2008-10-07 Thread Bert Gunter
 Well, writing on my rebuttal, I find myself being unable to explain in a
 few, easy to understand (and, at the same time, correct) sentences
stating
 that it is not a good idea to report (most likely wrong) dfs and F
 statistics. 


Without pretending to be able to discuss the details, may I nevertheless ask
WHY one should assume that an easy to understand (and, at the same time,
correct) answer to the question exists? For example, I would not begin to
presume that an easy to understand (and, at the same time, correct answer
exists for why an electron can simultaneously have the properties of a
particle (photoelectric effect) and a wave (2 slit interference patterns)--
or to the question of why is the 2nd law of thermodynamics equivalent to
information loss? -- or to how the Krebs cycle works or the nature of
Benzene rings.  It has never ceased to amaze me that many casual (in the
sense of not having training at, say, the graduate statistics level)users of
statistics automatically assume that all statistical principles are
fundamentally simple and at least easily comprehensible at a conceptual
level by someone with only minimal (or no!) background in the discipline.
The extreme manifestation of this is the popular view of a statistician as
someone who expertly compiles and tracks baseball records! While I would
readily admit that there is much that we can and should do to make our
discipline more accessible and useful, I am still offended by those whose
attitude is, as appears to be the case here, that even the most technical
aspects of the discipline can be made manifest to anyone with half a brain
and a stat 101 course under their belt.

I think we owe Doug Bates a little more respect than that!

Cheers,
Bert Gunter

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


Re: [R] Mirror Image on Biplot Graphic

2008-10-07 Thread Rodrigo Aluizio

Exactly. It's solved. Just remove #15.

CAPpotiFTI-CAPpotiFT
for(i in c(2:8))CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1

It seems that I've to pay more attention and study more about R language.

Thanks a lot once more.

Rodrigo.

--
From: Mark Difford [EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 6:34 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

This is because [I now see] you are working on a capscale object, not a 
cca
object, which is what I thought you were using. It still works, though, 
even
with c(2:8,15), though DF #15 doesn't exist in capscale objects. To show 
you
that this is so, run the example below, which uses a data set from vegan. 
I

have dropped #15 from the selection set.

## Ex. of switching axes of capscale object
windows(); par(mfrow=c(2,2))
data(varespec)
data(varechem)
vare.cap - capscale(varespec ~ N + P + K + Condition(Al), varechem,
dist=bray)
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 1]-vare.cap$CCA[[i]][, 1] * -1
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 2]-vare.cap$CCA[[i]][, 2] * -1
plot(vare.cap)
for(i in c(2:8)) vare.cap$CCA[[i]][, 1:2]-vare.cap$CCA[[i]][, 1:2] * -1
plot(vare.cap)

Cheers, Mark.


Rodrigo Aluizio wrote:


Well this time I have to assume, I'm not understanding what is wrong now.
And I have to say: 'Thank You for your patience', cause I'm going crazy
here! :-)

Mark, I tried this:

CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] *
-1

and got this:

Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of 
limits)


Here is the script until this point

library(vegan)
library(xlsReadWrite)
#FT--#
PotiAbioFT-read.xls('FatorialReplica.xls',sheet=4,rowNames=T)
PotiBioFT-read.xls('FatorialReplica.xls',sheet=6,rowNames=T)
attach(PotiAbioFT)
LogPotiBioFT-log(PotiBioFT+1)
CAPpotiFT-capscale(t(LogPotiBioFT)~Envoronmental+Variables,dist=bray,add=T)
PermCAPFT-anova.cca(CAPpotiFT,alpha=0.05,model='full',first=F,permutations=999)
PermCAPFT
summary(CAPpotiFT)
# Rotating the axis
CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1] *
-1



--



Sent: Tuesday, October 07, 2008 5:17 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Yes it does, but this will work. You have erroneously used a , in your
call, it should be a ., if anything. You have also inserted cca...
And
the axes being switched must be conformant:


CAPpotiFTI-CAPpotiFT
for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1  ## you are
writing axis 1 over axis 2; and there is no ...,cca...

Erro: unexpected ',' in for(i in c(2:8,15))   ## unexpected

comma

CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,


## Using your example to switch axis 1. Make sure that CAPpotiFT exists
and
is your
## original object. Copy and paste the lines below into your R console
window and run
CAPpotiFTI - CAPpotiFT
for(i in c(2:8,15)) CAPpotiFTI$CCA[[i]][, 1]-CAPpotiFTI$CCA[[i]][, 1]
* -1

Cheers, Mark.


Rodrigo Aluizio wrote:



[[elided Yahoo spam]]

Ah well, I tried the this other way, but it gave me an error.
Something in the syntax, I tried to change something but didn't fix the
error.

CAPpotiFTI-CAPpotiFT
 for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,cca$CCA[[i]][,1]*-1
Erro: unexpected ',' in for(i in c(2:8,15))
CAPpotiFTI$CCA[[i]][,2]-CAPpotiFTI,

 for(i in c(2:8,15)) 
CAPpotiFTI$CCA[[i]][,1]-CAPpotiFTI$CCA[[i]][,1]*-1

Erro em CAPpotiFTI$CCA[[i]] : índice fora de limites (index out of
limits)

Well, it needs lots of patience...

--



Sent: Tuesday, October 07, 2008 3:50 PM
To: r-help@r-project.org
Subject: Re: [R] Mirror Image on Biplot Graphic



Hi Rodrigo,

Again an error, as that doesn't touch one of the data structures. You
need
to extend the range to include #15, as below:

## This does axis 2
mynew.cca - my.cca
for (i in c(2:8,15)) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 
2]

* -1

Cheers, Mark.


Mark Difford wrote:


Hi Rodrigo,

I looked through my scripts and found my old hack. __WARNING__: Be
very
careful to check that
the mirror isn't broken and that all is in order! Make sure that you
are
reversing the axes you want. In your original post you mention axis 
2,

i.e. y-axis. Below you have used axis 1.

## This does axis 2
mynew.cca - my.cca
for (i in 2:8) mynew.cca$CCA[[i]][, 2] - mynew,cca$CCA[[i]][, 2] 
* -1


plot(mynew.cca)

## This does axis 1
for (i in 2:8) mynew.cca$CCA[[i]][, 1] - mynew,cca$CCA[[i]][, 1] 
* -1


Regards, Mark.


Rodrigo Aluizio wrote:


Ok Mark, it worked for the species.
I still get an error if I try with biplot (cn,sp), but it's not a
problem,
repositioning the species is enough.
Thanks once again.

Just for future consults the error that still remains:

  1   2   >