Re: [R] generalized linear models

2009-08-09 Thread annie Zhang
I think I need to restate the problem. If the test data is only a vector,
then I am predicting one test sample. But the output from the predict result
has the same length as the training set. And there is a warning message
about this.

Annie

On Sat, Aug 8, 2009 at 2:52 PM, annie Zhang annie.zhang2...@gmail.comwrote:

 Hi, Milton,

 Thank you for the reply. I tried, but it seems the problem is the column
 name of the test data is not the same as the column name of the training
 data. I didn't give the column name, the system seemed do. How to chang
 here?

 Annie

  On Fri, Aug 7, 2009 at 7:52 PM, milton ruser milton.ru...@gmail.comwrote:

 Hi Annie,

 create a new data.frame with input variables having all predictors
 variables on it.
 after give a look at ?predict

 best wishes

 milton

   On Fri, Aug 7, 2009 at 8:19 PM, annie Zhang 
 annie.zhang2...@gmail.comwrote:

  Hi, R users,

 I am trying to use glm to do logistic regression. I know generally when I
 have two covariates, say x1 and x2, then I do
 fit - glm(y~x1+x2,famliy='binomial')
 But now my covariates form a n*p matrix, say x, so actually each column
 is a
 covariate. So I think I should do
 fit - glm(y~x,family='binomial')
 Then I need to predict new data. How should I write the newdata? I tried
 several thing, all failed. The x in the fit is a matrix, but is a vector
 for
 the new data.

 Thank you,
 Annie

[[alternative HTML version deleted]]

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





[[alternative HTML version deleted]]

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


Re: [R] linear model: Test difference between coefficients and given values (t.test?)

2009-08-09 Thread Katharina May
Thanks to somebody I got the hint to use offset for the purpose of
validating if there's
a difference between the intercept and slope of a model and some
provided values for
the coefficients intercept and slope.

I read ?model.offset and I'm still struggling to use it for my
purpose. If I understood
the concepts correctly, offset can be used to define a known
coefficient of a model,
so therefore I could create two models based on the same data like my
original one
 with an additional offset term (one model with intercept specified
and one with the
slope specified)?

Sorry for troubling you: I struggling with the data analysis of my
bachelor thesis and
just want to compare the coefficients of my linear regression to
published ones...
a method often used I guess, but still I cannot find any appropriate
documentations.

Thanks,

 Katharina


 On Aug 8, 2009, Katharina May may.kathar...@googlemail.com wrote:

 Hi there,

 I've got a question which is really trivial for sure but still I have
 to ask as I'm not
 making any progress solving it by myself (please be patient with an
 undergraduate
 student):

 I've got a linear model (lm and lmer fitted with method=ML).
 Now I want to compare the coefficients (slope, intercept, not the
 random effects)
 of both models with a given value (e.g. intercept=0.5, slope=2) to see
 if the values
 estimated with the models are significantly different from the given values.

 I heard about t.test, but I'm sorry to say that I'm not quite
 understanding what I have
 to provide as arguments.

 I would be more than happy if somebody can point out an example similar to
 the
 comparison I have to do...

 Thanks,

 Katharina

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


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


Re: [R] linear model: Test difference between coefficients and given values (t.test?)

2009-08-09 Thread Achim Zeileis

On Sat, 8 Aug 2009, Katharina May wrote:


Thanks to somebody I got the hint to use offset for the purpose of
validating if there's
a difference between the intercept and slope of a model and some
provided values for
the coefficients intercept and slope.


You could also use a Wald test for a linear hypothesis which does not 
require refitting of the data under the null hypothesis. Suppose you've 
got the regression

  fm - lm(dist ~ speed, data = cars)
and then want to test the null hypothesis that
  (Intercept) = -10
  speed = 4
Then you can do
  library(car)
  linear.hypothesis(fm, c((Intercept) = -10, speed = 4))
which will give you an ANOVA-like output.

Conceptually, this approach should also be possible for models with random 
effects but I don't think that linear.hypothesis() works out of the box 
for this.

Z


I read ?model.offset and I'm still struggling to use it for my
purpose. If I understood
the concepts correctly, offset can be used to define a known
coefficient of a model,
so therefore I could create two models based on the same data like my
original one
with an additional offset term (one model with intercept specified
and one with the
slope specified)?

Sorry for troubling you: I struggling with the data analysis of my
bachelor thesis and
just want to compare the coefficients of my linear regression to
published ones...
a method often used I guess, but still I cannot find any appropriate
documentations.

Thanks,

Katharina



On Aug 8, 2009, Katharina May may.kathar...@googlemail.com wrote:

Hi there,

I've got a question which is really trivial for sure but still I have
to ask as I'm not
making any progress solving it by myself (please be patient with an
undergraduate
student):

I've got a linear model (lm and lmer fitted with method=ML).
Now I want to compare the coefficients (slope, intercept, not the
random effects)
of both models with a given value (e.g. intercept=0.5, slope=2) to see
if the values
estimated with the models are significantly different from the given values.

I heard about t.test, but I'm sorry to say that I'm not quite
understanding what I have
to provide as arguments.

I would be more than happy if somebody can point out an example similar to
the
comparison I have to do...

Thanks,

Katharina

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



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

2009-08-09 Thread Alain Zuur


annie Zhang wrote:
 
 Hi, Milton,
 
 Thank you for the reply. I tried, but it seems the problem is the column
 name of the test data is not the same as the column name of the training
 data. I didn't give the column name, the system seemed do. How to chang
 here?
 
 Annie
 
 On Fri, Aug 7, 2009 at 7:52 PM, milton ruser milton.ru...@gmail.com
 wrote:
 
 Hi Annie,

 create a new data.frame with input variables having all predictors
 variables on it.
 after give a look at ?predict

 best wishes

 milton

   On Fri, Aug 7, 2009 at 8:19 PM, annie Zhang
 annie.zhang2...@gmail.comwrote:

  Hi, R users,

 I am trying to use glm to do logistic regression. I know generally when
 I
 have two covariates, say x1 and x2, then I do
 fit - glm(y~x1+x2,famliy='binomial')
 But now my covariates form a n*p matrix, say x, so actually each column
 is
 a
 covariate. So I think I should do
 fit - glm(y~x,family='binomial')
 Then I need to predict new data. How should I write the newdata? I tried
 several thing, all failed. The x in the fit is a matrix, but is a vector
 for
 the new data.

 Thank you,
 Annie

[[alternative HTML version deleted]]

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



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


See:
?colnames

Alain



-

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.

2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.

3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Email: highs...@highstat.com
URL: www.highstat.com



-- 
View this message in context: 
http://www.nabble.com/generalized-linear-models-tp24873759p24885065.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] binary operators that implement row and column sweeps of matrices by vectors

2009-08-09 Thread Steven Rytina


Submitted for perusal, comment, improvements, and/or critique. 
The presentation is in 3 sections:  motivation, code, and comment.

 

Motivation:

 

As a new-comer to R from matrix oriented Gauss and Mata, I miss the 
tools for using a vector (and operator) to ‘sweep’ across a matrix.

 

Here is how these work. If M is I rows by J columns, then one entry 
corresponding to each row of M is provided any 1 by I  (row) vector, R. This 
can be swept ‘down’ the columns with a result that is I rows, J columns with 
entries {M[i,j] op R[i]) } where op can be any atomic binary operator including 
comparisons, such as  !=, or arithmetic operators, such as  ^.

 

A J by 1 column vector can be applied analogously to ‘sweep’ 
through the rows.

 

It is natural to implement these as R op M and M op C where R, M, 
and C conform as for matrix multiplication. 



Following Gauss, an arguably analogous outer product is returned 
when 2 vectors are equal length are submitted. Scalars are allowed. And so are 
matrices with identical numbers of  rows and numberrs of columns.

 

Code: 



dop-function(ml,mr,op) {#  inspired by  Gauss dot op, more plainly 
order sensitive



if (!is.matrix(ml))

print(Warning: in dop(), Left 
arg will be coerced to matrix)

if (!is.matrix(mr))

print(Warning: in dop(), Right 
arg will be coerced to matrix)

 

if (is.vector(ml)  ! 
is.matrix(ml))ml-matrix(ml,nrow=1,ncol=length(ml))

#risky business, force 
conversion of Left-hand vector

m.L-as.matrix(ml);m.R-as.matrix(mr); 
#conserve old Left and Right objects for debug

I=nrow(m.L);J=ncol(m.L);K=nrow(m.R);L=ncol(m.R)

 

if ( I == K  J==L)  # standard element-wise 
conformity for binary op

{return(mapply(op,m.L,m.R)); }  else 

# the elses are just for show since the if’s form a partition. Unless my 
testing was mistaken, of course

 if (!( I==1 | J==1 |K==1|L==1))  # reject if 
no vector and not same size

{print( DOT op requires same 
shapes or vector  argument)

return(NA); } 
else

 if ( (I==1  J==1) | (K==1  L==1)) # at least 
one arg is scalar, mapply works

{return(mapply(op,m.L,m.R));}  
else

 if (I==1  L==1  J==K) 
#this and next mimic Gauss convention(s)  

  
{return((matrix(outer(m.R,m.L,op),nrow=J,ncol=J )));} else # r1.*r2' 


# n.b outer returns matrix but matrix() left in for clarity

 if (J==1  K==1  I==L )


{return(matrix(outer(m.L,m.R,op),nrow=I,ncol=I ));}else # r1'.*r2

 if (I==1  J==K) # m.L is row vec, hence sweep 
columns 

{return( (matrix(mapply(op,t(m.L),m.R),nrow=nrow(m.R),ncol=ncol(m.R;}else

 if (J==K  L==1) # m.R is col vec, hence sweep 
rows

{   
return(t(matrix(qq1-mapply(op,t(m.L),m.R),nrow=ncol(m.L),ncol=nrow(m.L;}else
 

 print(c( conformity failure with I,J,K,L= 
,paste(I,J,K,L)));return(NA)

}

 

#a further step is to implement the various binary operators using the %text% 
convention.

# some construction tools

#set.of.ops-c(getGroupMembers(Compare),getGroupMembers(Arith))

#names.for.ops-as.array(c(


eq,gt,lt,ne,ge,le,plus,minus,x,exp,mod,dmod,div))

 

`%eq%`-function(x,y) dop(x,y,op= ==)   

`%gt%`-function(x,y) dop(x,y,op=)

`%lt%`-function(x,y) dop(x,y,op=)

`%ne%`-function(x,y) dop(x,y,op=!=)   

`%ge%`-function(x,y) dop(x,y,op==)   

`%le%`-function(x,y) dop(x,y,op==)   

`%plus%`-function(x,y) dop(x,y,op=+)  

`%minus%`-function(x,y) dop(x,y,op=-) 

`%x%`-function(x,y) dop(x,y,op=*) 

`%exp%`-function(x,y) dop(x,y,op=^)   

`%mod%`-function(x,y) dop(x,y,op=%%)  

`%dmod%`-function(x,y) dop(x,y,op=%/%)

`%div%`-function(x,y) dop(x,y,op=/)   

 

Comments:

 

I have found these constructs very helpful in the past. One 
illustration is using logical comparison for a vector of standards applied to 
some set of variables.

 

There are many different ways to try to achieve these results in R. 
I would love to hear if I have 

Re: [R] binary operators that implement row and column sweeps of matrices by vectors

2009-08-09 Thread Peter Dalgaard

Steven Rytina wrote:


Submitted for perusal, comment, improvements, and/or critique. 
The presentation is in 3 sections:  motivation, code, and comment.

 


Motivation:

 


As a new-comer to R from matrix oriented Gauss and Mata, I miss the

tools for using a vector (and operator) to ‘sweep’ across a matrix.

And you have checked that this is not possible using sweep()??


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

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


Re: [R] binary operators that implement row and column sweeps of matrices by vectors

2009-08-09 Thread Steven Rytina


- Original Message - 
From: Peter Dalgaard p.dalga...@biostat.ku.dk

To: Steven Rytina, Prof. steven.ryt...@mcgill.ca
Cc: r-help@r-project.org
Sent: Sunday, August 09, 2009 6:35 AM
Subject: Re: [R] binary operators that implement row and column sweeps of 
matrices by vectors



Steven Rytina wrote:


Submitted for perusal, comment, improvements, and/or 
critique. The presentation is in 3 sections:  motivation, code, and 
comment.




Motivation:



As a new-comer to R from matrix oriented Gauss and Mata, I 
miss the

tools for using a vector (and operator) to ‘sweep’ across a matrix.

And you have checked that this is not possible using sweep()??


 That was an initial possibility, to be sure. But what was left open was 
how to implement imposing an arbitrary vector of suitable length and how to 
implement strict conformability. My take is that once one has a 'wrapper' 
like mine that classifies the possibilities, there is no great difference in 
using mapply() as I did versus, say, sweep().


   But perhaps that is in error??

   On the other hand, it seems plausible that using sweep() might lead to 
insight into generalizations, like M dimensions swept by K. And while that 
would be cool it doesn't serve any practical purpose I know about.




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

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


Re: [R] Select subset with specific distribution parameters.

2009-08-09 Thread stephen sefick
Could you provide a reproducible example?

On Thu, Aug 6, 2009 at 10:59 AM, sedm1000gdo...@mit.edu wrote:

 This may be a simple problem, but I am looking to select a subset of rows
 from a dataframe that will have the same parameters as all the rows in
 another dataframe.

 e.g. I have a 500 row dataframe with 20 columns. I want to select a subset
 of rows from a larger dataframe that match the distribution of values for
 one or more of the columns within the 500 row dataframe (i.e. within same
 range, but also having same mean/median and overall shape).

 By basic subsetting I can get a set with a similar approximate distribution
 to the 500 row dataset, but not highly similar, and this might be a problem
 for the analysis. Any help would be much appreciated, thanks.

 --
 View this message in context: 
 http://www.nabble.com/Select-subset-with-specific-distribution-parameters.-tp24848201p24848201.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

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] xtable, sweave and resizebox

2009-08-09 Thread Welma Pereira
Duncan,

Thanks a lot! it sorted out the problem. I was too worried about learning
how to use sweave that forgot to try other things :-)

Teysseyre, I saw this doc but my table was large in width like almost not
fitting the paper size..

Its better now but I wonder how to make better tables using xtable like for
example how to use a similar thing to \multirow..does anyone maybe have had
to do that before?

Thanks!
regards,
Welma.


2009/8/7 Duncan Mackay mac...@northnet.com.au

 Hi Welma

 Have you thought about working with latex commands rather than Sweave
 1 reduce the space between the columns the default is 7

 \setlength\tabcolsep{3pt}

 2 I frequently have wide tables so before the chunk
 \begin{small}
 
 Sweave commands
 @
 \end{small}

 Its very late here ... and so to bed

 Regards

 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 ARMIDALE NSW 2351

 At 21:03 7/08/2009, you wrote:

 Content-Type: text/plain
 Content-Disposition: inline
 Content-length: 686


 does anyone know to rezize a table produzed by xtable?  The size of my
 table
 is too big and I would like to resize it like using resizebox but it gives
 an erros when I try using it


 using it its fine

 \SweaveOpts{echo=false}
 results=tex=
 xtable(stats0,caption='Número de transacções dos artigos frequentes e
 infrequentes',label='tab:INEStats')
 @

 but the size is too big

 so I try
 echo=False,results=hide=
 load('stats.Rdata')
 library(xtable)

 \resizebox{\textwidth}{!}{
 \SweaveOpts{echo=false}
 results=tex=
 xtable(stats0,caption='text',label='tab:Stats')
 @
 }

 and it doesn t work anymore

 any hints?

[[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] xtable, sweave and resizebox

2009-08-09 Thread Gabor Grothendieck
latex() in the Hmisc package can group rows using rgroup= and n.group=
arguments.

On Sun, Aug 9, 2009 at 9:08 AM, Welma Pereirawelma.pere...@gmail.com wrote:
 Duncan,

 Thanks a lot! it sorted out the problem. I was too worried about learning
 how to use sweave that forgot to try other things :-)

 Teysseyre, I saw this doc but my table was large in width like almost not
 fitting the paper size..

 Its better now but I wonder how to make better tables using xtable like for
 example how to use a similar thing to \multirow..does anyone maybe have had
 to do that before?

 Thanks!
 regards,
 Welma.


 2009/8/7 Duncan Mackay mac...@northnet.com.au

 Hi Welma

 Have you thought about working with latex commands rather than Sweave
 1 reduce the space between the columns the default is 7

 \setlength\tabcolsep{3pt}

 2 I frequently have wide tables so before the chunk
 \begin{small}
 
 Sweave commands
 @
 \end{small}

 Its very late here ... and so to bed

 Regards

 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 ARMIDALE NSW 2351

 At 21:03 7/08/2009, you wrote:

 Content-Type: text/plain
 Content-Disposition: inline
 Content-length: 686


 does anyone know to rezize a table produzed by xtable?  The size of my
 table
 is too big and I would like to resize it like using resizebox but it gives
 an erros when I try using it


 using it its fine

 \SweaveOpts{echo=false}
 results=tex=
 xtable(stats0,caption='Número de transacções dos artigos frequentes e
 infrequentes',label='tab:INEStats')
 @

 but the size is too big

 so I try
 echo=False,results=hide=
 load('stats.Rdata')
 library(xtable)

 \resizebox{\textwidth}{!}{
 \SweaveOpts{echo=false}
 results=tex=
 xtable(stats0,caption='text',label='tab:Stats')
 @
 }

 and it doesn t work anymore

 any hints?

        [[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] xtable, sweave and resizebox

2009-08-09 Thread Welma Pereira
Hi again,

one last annoying thing: how to deal with %, always when I use sweave to get
a latex document the % comes as a comment and I cannot have % in my tables,
how to sort out this annoying detail?

thanks!
Regards
Welma

2009/8/9 Gabor Grothendieck ggrothendi...@gmail.com

 latex() in the Hmisc package can group rows using rgroup= and n.group=
 arguments.

 On Sun, Aug 9, 2009 at 9:08 AM, Welma Pereirawelma.pere...@gmail.com
 wrote:
  Duncan,
 
  Thanks a lot! it sorted out the problem. I was too worried about learning
  how to use sweave that forgot to try other things :-)
 
  Teysseyre, I saw this doc but my table was large in width like almost not
  fitting the paper size..
 
  Its better now but I wonder how to make better tables using xtable like
 for
  example how to use a similar thing to \multirow..does anyone maybe have
 had
  to do that before?
 
  Thanks!
  regards,
  Welma.
 
 
  2009/8/7 Duncan Mackay mac...@northnet.com.au
 
  Hi Welma
 
  Have you thought about working with latex commands rather than Sweave
  1 reduce the space between the columns the default is 7
 
  \setlength\tabcolsep{3pt}
 
  2 I frequently have wide tables so before the chunk
  \begin{small}
  
  Sweave commands
  @
  \end{small}
 
  Its very late here ... and so to bed
 
  Regards
 
  Duncan Mackay
  Department of Agronomy and Soil Science
  University of New England
  ARMIDALE NSW 2351
 
  At 21:03 7/08/2009, you wrote:
 
  Content-Type: text/plain
  Content-Disposition: inline
  Content-length: 686
 
 
  does anyone know to rezize a table produzed by xtable?  The size of my
  table
  is too big and I would like to resize it like using resizebox but it
 gives
  an erros when I try using it
 
 
  using it its fine
 
  \SweaveOpts{echo=false}
  results=tex=
  xtable(stats0,caption='Número de transacções dos artigos frequentes e
  infrequentes',label='tab:INEStats')
  @
 
  but the size is too big
 
  so I try
  echo=False,results=hide=
  load('stats.Rdata')
  library(xtable)
 
  \resizebox{\textwidth}{!}{
  \SweaveOpts{echo=false}
  results=tex=
  xtable(stats0,caption='text',label='tab:Stats')
  @
  }
 
  and it doesn t work anymore
 
  any hints?
 
 [[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.
 
 


[[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] xtable, sweave and resizebox

2009-08-09 Thread Gabor Grothendieck
See the sanitize.* arguments to print.xtable.

On Sun, Aug 9, 2009 at 10:16 AM, Welma Pereirawelma.pere...@gmail.com wrote:
 Hi again,

 one last annoying thing: how to deal with %, always when I use sweave to get
 a latex document the % comes as a comment and I cannot have % in my tables,
 how to sort out this annoying detail?

 thanks!
 Regards
 Welma

 2009/8/9 Gabor Grothendieck ggrothendi...@gmail.com

 latex() in the Hmisc package can group rows using rgroup= and n.group=
 arguments.

 On Sun, Aug 9, 2009 at 9:08 AM, Welma Pereirawelma.pere...@gmail.com
 wrote:
  Duncan,
 
  Thanks a lot! it sorted out the problem. I was too worried about
  learning
  how to use sweave that forgot to try other things :-)
 
  Teysseyre, I saw this doc but my table was large in width like almost
  not
  fitting the paper size..
 
  Its better now but I wonder how to make better tables using xtable like
  for
  example how to use a similar thing to \multirow..does anyone maybe have
  had
  to do that before?
 
  Thanks!
  regards,
  Welma.
 
 
  2009/8/7 Duncan Mackay mac...@northnet.com.au
 
  Hi Welma
 
  Have you thought about working with latex commands rather than Sweave
  1 reduce the space between the columns the default is 7
 
  \setlength\tabcolsep{3pt}
 
  2 I frequently have wide tables so before the chunk
  \begin{small}
  
  Sweave commands
  @
  \end{small}
 
  Its very late here ... and so to bed
 
  Regards
 
  Duncan Mackay
  Department of Agronomy and Soil Science
  University of New England
  ARMIDALE NSW 2351
 
  At 21:03 7/08/2009, you wrote:
 
  Content-Type: text/plain
  Content-Disposition: inline
  Content-length: 686
 
 
  does anyone know to rezize a table produzed by xtable?  The size of my
  table
  is too big and I would like to resize it like using resizebox but it
  gives
  an erros when I try using it
 
 
  using it its fine
 
  \SweaveOpts{echo=false}
  results=tex=
  xtable(stats0,caption='Número de transacções dos artigos frequentes e
  infrequentes',label='tab:INEStats')
  @
 
  but the size is too big
 
  so I try
  echo=False,results=hide=
  load('stats.Rdata')
  library(xtable)
 
  \resizebox{\textwidth}{!}{
  \SweaveOpts{echo=false}
  results=tex=
  xtable(stats0,caption='text',label='tab:Stats')
  @
  }
 
  and it doesn t work anymore
 
  any hints?
 
         [[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] How do I plot a line followed by two forecast points?

2009-08-09 Thread Jorgy Porgee
Thank you but just fyi, the lines() and points() approach proposed by
Jean earlier solved the problem. Thanks all once again.

On Sat, Aug 8, 2009 at 7:49 PM, Felipe Carrillomazatlanmex...@yahoo.com wrote:
 Try this, it plots two points ahead based on the existing data of a month 
 apart.


 # Sample dates
  xValues - seq.Date(as.Date(1990-01-31), to=as.Date(1992-12-31), 
 by=month)
 # Sample y value
  yValues - seq(0.1, length=length(xValues))
  mydf - data.frame(xValues,yValues);mydf
  mydf[,1]
  library(forecast)
  yValues - as.numeric(yValues)
 Ypredict - forecast(yValues,h=2,level=95)
 Xpredict - forecast(xValues,h=2,level=95);Xpredict

 yValues - as.numeric(Ypredict$mean)
  upper - as.numeric(Ypredict$upper)
  lower - as.numeric(Ypredict$lower)
 xValues - as.Date(Xpredict$mean)

  forecast - data.frame(yValues,upper,lower,xValues)
 forecast[1,4] - '1993-01-31';forecast[2,4] - '1993-02-28'
  forecast
  mydf$upper - mydf$yValues
 mydf$lower - mydf$yValues
 PredictedValues - rbind(mydf, forecast)

 library(ggplot2)
 predict2 - ggplot(PredictedValues,aes(xValues, yValues)) +  
 geom_line(colour=red,size=2)# + geom_point(colour=pink)
 predict2 - predict2 +  geom_smooth(aes(ymin = lower, ymax = upper),stat = 
 identity,colour = pink, fill = lightgoldenrod) + 
 geom_point(colour=goldenrod,size=3)
 predict2 - predict2 +  
 geom_text(data=forecast,label=round(forecast$yValues,1),hjust=1.2,colour=blue,size=3)
   +
  geom_line(data=forecast,colour=green) + 
 geom_point(data=forecast,colour=green,size=3.5) +
   opts(panel.background = theme_rect(fill = white)) + opts(panel.grid.minor 
 = theme_blank())  + opts(panel.grid.major = theme_line(linetype = 
 dotted,colour=grey89))
  print(predict2)


 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA


 --- On Fri, 8/7/09, Clint Bowman cl...@ecy.wa.gov wrote:

 From: Clint Bowman cl...@ecy.wa.gov
 Subject: Re: [R] How do I plot a line followed by two forecast points?
 To: Jorgy Porgee jorgy.por...@gmail.com
 Cc: Jean V Adams jvad...@usgs.gov, r-help@r-project.org
 Date: Friday, August 7, 2009, 1:33 PM
 Because you know a priori the dates
 associated with your forecast points
 you could use the col= in the plot function to change
 colors for the last
 two points (may require some mathmatical gymnastics to
 specify the colors
 desired--I've set up a vector and created an index from
 either the x or y
 values to obtain the desired effect).

 Clint Bowman
     INTERNET:    cl...@ecy.wa.gov
 Air Dispersion Modeler
 INTERNET:    cl...@math.utah.edu
 Air Quality Program
 VOICE:        (360) 407-6815
 Department of Ecology
 FAX:        (360) 407-7534

     USPS:
     PO Box 47600, Olympia, WA 98504-7600
     Parcels:    300 Desmond
 Drive, Lacey, WA 98503-1274

 On Fri, 7 Aug 2009, Jorgy Porgee wrote:

  Hi Jean,
  Thank you for the reply. I do have the forecast points
 before I plot,
  the example below was just for illustration
 purposes..If I am to add
  the forecast points to one y-series data plot however,
 is there a way
  of highlighting them? This is essentially what I'm
 trying to do below
  by plotting 3 separate series on the same graph...
  Any help would be much appreciated..
 
  Regards,
 
  George.
  In addition, I can't add the forecasts to the original
 series because I need
 
  On Fri, Aug 7, 2009 at 8:36 PM, Jean V Adamsjvad...@usgs.gov
 wrote:
  
   Just wait until after you have the forecasts
 before you create the plot.
  
   # Sample dates
   xValues - seq.Date(as.Date(1990-01-31),
 to=as.Date(1992-12-31),
   by=month)
  
   # Sample y value
   yValues - seq(0.1, length=length(xValues))
  
   # Sample forecast one year from xValue's end
 point
   fcastDate -
 seq.Date(from=as.Date(xValues[length(xValues)]), length=2,
   by=year)[2]
   fcast - 20
  
   # The second forecast
   fcastDate2 -
 seq.Date(from=as.Date(fcastDate), length=2, by=year)[2]
   fcast2 - 15
  
   plot(xValues, yValues, type=n,
 xlim=range(c(xValues, fcastDate,
   fcastDate2)), ylim=range(c(yValues, fcast,
 fcast2)))
   lines(xValues, yValues)
   points(fcastDate, fcast, col=red)
   points(fcastDate2, fcast2, col=blue)
  
   Jean
  
  
   -
  
  
   From: Jorgy Porgee jorgy.porgee at
 gmail.com
   Subject: How do I plot a line followed by two
 forecast points?
   Newsgroups: gmane.comp.lang.r.general
   Date: 2009-08-07 15:17:52 GMT (2 hours and 55
 minutes ago)
  
   Good day all,
  
   I'm trying to plot a continuous line plot, which
 is followed by two forecast
   points eg. one forecast point is 12 months out,
 and another 24 months out
   from the last date of the line plot.
  
   In my attempts so far, the second plot (the
 forecast points) is scaled
   against a new axis scale, thus the two plots are
 not directly comparable (I
   need the forecast points to be scaled according
 to the existing y axis).
  
   An example is pasted below. Any ideas on how to
 achieve this would be much
   appreciated.
  
 

[R] How '.' is used?

2009-08-09 Thread Peng Yu
Hi,

I know '.' is not a separator in R as in C++. I am wondering where it
discusses the detailed usage of '.' in R. Can somebody point me a
webpage, a manual or a book that discuss this?

Regards,
Peng

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

2009-08-09 Thread Ted Harding
On 09-Aug-09 16:06:52, Peng Yu wrote:
 Hi,
 I know '.' is not a separator in R as in C++. I am wondering where it
 discusses the detailed usage of '.' in R. Can somebody point me a
 webpage, a manual or a book that discuss this?
 
 Regards,
 Peng

To the best of my knowledge, apart from its specific use as a separator
between the integer and fractional parts of a number, . has no specific
use in R, and you can, for instance, use it just as you would use an
alphanumeric character in a name.

For instance, you could do

  . - 1.2345
  .
  # [1] 1.2345

  . - function(x) x^2
  .(12)
  # [1] 144

So, unless there is something I don't know about, there is hardly
anything to discuss about the detailed usage of '.' in R!

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-09   Time: 17:32:54
-- 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] How '.' is used?

2009-08-09 Thread Douglas Bates
On Sun, Aug 9, 2009 at 11:32 AM, Ted
Hardingted.hard...@manchester.ac.uk wrote:
 On 09-Aug-09 16:06:52, Peng Yu wrote:
 Hi,
 I know '.' is not a separator in R as in C++. I am wondering where it
 discusses the detailed usage of '.' in R. Can somebody point me a
 webpage, a manual or a book that discuss this?

 Regards,
 Peng

 To the best of my knowledge, apart from its specific use as a separator
 between the integer and fractional parts of a number, . has no specific
 use in R, and you can, for instance, use it just as you would use an
 alphanumeric character in a name.

 For instance, you could do

  . - 1.2345
  .
  # [1] 1.2345

  . - function(x) x^2
  .(12)
  # [1] 144

 So, unless there is something I don't know about, there is hardly
 anything to discuss about the detailed usage of '.' in R!

The ',' character is one of the characters allowed in names, hence it
can be used as you have suggested.  There are (at least) two special
usages of the '.' in names.  Following the time-honoured Unix
convention, names that begin with '.' are considered hidden names
and not listed by ls() or objects() unless you set all.names = TRUE in
the call.  Because of this convention it is inadvisable to use names
starting with '.' except when you wish to avoid potential name
conflicts.  The second special use of '.' in a name is in the
construction of the names of S3 method functions.  The method for
generic function foo applied to class bar is named foo.bar.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] howto get the number of columns and column names of multiply data frames

2009-08-09 Thread Frank Schäffer
Hi,
I' ve read in several files with measurements into R data frames(works 
flawlessly). Each dataframe is named by the location of measurement and 
contains hundreds of rows and about 50 columns like this

dataframe1.
date measurment_1   mesurement_n
1
2
3
..
..
..
n

For further processing I need to check whether or not ncol and colnames are 
the same for all dataframes. 
Also I need to add a new column to each dataframe with contain the name of the 
dataframe, so that this column can be treated as factor in later processing 
(after merging some seleted dataframes to one)

I tried out 

for (i in 1:length(ls()){
print(ncol(ls()[i])
}

but this does not work because r returns a character for i and therefore 
NULL as result.
Reading the output of ls() into a list also does not work.

How can I accomplish this task??

Best regards and thanks

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.


Re: [R] howto get the number of columns and column names of multiply data frames

2009-08-09 Thread Steve Lianoglou

Hi,

On Aug 9, 2009, at 11:29 AM, Frank Schäffer wrote:


Hi,
I' ve read in several files with measurements into R data frames(works
flawlessly). Each dataframe is named by the location of measurement  
and

contains hundreds of rows and about 50 columns like this

dataframe1.
date measurment_1   mesurement_n
1
2
3
..
..
..
n


Just as an aside, it's somehow considered more R-idiomatic to store  
all of these tables in a list (of tables) and access them as  
mydata[[1]], mydata[[2]], ..., mydata[[n]]. Assuming the datafiles are  
'filename.1.txt', 'filename.2.txt', etc. You might do this like so:


mydata - lapply(paste('filename', 1:n, 'txt', sep='.'), read.table,  
header=TRUE, sep=...)


To test that all colnames are the same, you could do something like.

names1 - colnames(mydata[[1]])
all(sapply(2:n, function(dat) length(intersect(names1,  
colnames(mydata[[n]]))) == length(names1)))


For further processing I need to check whether or not ncol and  
colnames are

the same for all dataframes.
Also I need to add a new column to each dataframe with contain the  
name of the
dataframe, so that this column can be treated as factor in later  
processing

(after merging some seleted dataframes to one)

I tried out

for (i in 1:length(ls()){
print(ncol(ls()[i])
}

but this does not work because r returns a character for i and  
therefore

NULL as result.
Reading the output of ls() into a list also does not work.

How can I accomplish this task??


If you still want to do it this way, see: ?get

for example:

for (varName in paste('dataframe', 1:n, sep='')) {
  cat(colnames(get(varName)))
}

HTH,
-steve

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

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

2009-08-09 Thread Rebecca Sela
I have two straightforward questions about linking in the man pages for R 
packages:

First, is it possible to link from within parts of the documentation that are 
not the \seealso section?  For example, I would like to have something like:
\arguments{
  \item{correlation}{an optional \code{corStruct} object describing the 
within-group correlation structure; the available classes are given in 
\link{\code{corClasses}}}
}
When the package is compiled, the word corClasses is blue and underlines, but 
nothing happens when you click on it.  

Second, how do I link to a function of the same name in another package?  I 
thought I could use something like:
\seealso{\code{\link[nlme]{ranef}}}
but that gives a Page Not Found.  

Thank you in advance!

Rebecca

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

2009-08-09 Thread Ted Harding
On 09-Aug-09 16:53:32, Douglas Bates wrote:
 On Sun, Aug 9, 2009 at 11:32 AM, Ted
 Hardingted.hard...@manchester.ac.uk wrote:
 On 09-Aug-09 16:06:52, Peng Yu wrote:
 Hi,
 I know '.' is not a separator in R as in C++. I am wondering where it
 discusses the detailed usage of '.' in R. Can somebody point me a
 webpage, a manual or a book that discuss this?

 Regards,
 Peng

 To the best of my knowledge, apart from its specific use as a
 separator
 between the integer and fractional parts of a number, . has no
 specific
 use in R, and you can, for instance, use it just as you would use an
 alphanumeric character in a name.

 For instance, you could do

 _. - 1.2345
 _.
 _# [1] 1.2345

 _. - function(x) x^2
 _.(12)
 _# [1] 144

 So, unless there is something I don't know about, there is hardly
 anything to discuss about the detailed usage of '.' in R!
 
 The ',' character is one of the characters allowed in names, hence it
 can be used as you have suggested.  There are (at least) two special
 usages of the '.' in names.  Following the time-honoured Unix
 convention, names that begin with '.' are considered hidden names
 and not listed by ls() or objects() unless you set all.names = TRUE in
 the call.  Because of this convention it is inadvisable to use names
 starting with '.' except when you wish to avoid potential name
 conflicts.  The second special use of '.' in a name is in the
 construction of the names of S3 method functions.  The method for
 generic function foo applied to class bar is named foo.bar.

As in summary.glm, I suppose! However, this prompts a question.
In the first place, the construction of summary.glm from summary
and glm is, in the first instance, simply using . in its basic
role as a permissible character in a name. Correct?

Next -- and this is the real question -- how does R parse the name
summary.glm? In my naivety, I simply suppose that it looks for
an available function whose name is summary.glm in just the
same way as it looks for stopifnot, or for that matter data.matrix
which is not (as far as I know) a compound of a generic function
data applied to a class matrix. Then . would not have a special
(parseable) role in the name -- it is simply another letter.

But when you do have such a function, like summary.glm, does R
in fact parse it as summary then glm (i.e. look out for the
generic function summary and then specialise it to handle glm).

As I say, I suppose not. And, if not, then the special use of
the character . is simply a programmer's convention for the
construction of the name, and once the name exists the . does
not have a special (parseable) significance for R.

Just seeking clarification ... !
Thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-09   Time: 19:58:32
-- 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] How '.' is used?

2009-08-09 Thread Duncan Murdoch

(Ted Harding) wrote:

On 09-Aug-09 16:53:32, Douglas Bates wrote:
  

On Sun, Aug 9, 2009 at 11:32 AM, Ted
Hardingted.hard...@manchester.ac.uk wrote:


On 09-Aug-09 16:06:52, Peng Yu wrote:
  

Hi,
I know '.' is not a separator in R as in C++. I am wondering where it
discusses the detailed usage of '.' in R. Can somebody point me a
webpage, a manual or a book that discuss this?

Regards,
Peng


To the best of my knowledge, apart from its specific use as a
separator
between the integer and fractional parts of a number, . has no
specific
use in R, and you can, for instance, use it just as you would use an
alphanumeric character in a name.

For instance, you could do

_. - 1.2345
_.
_# [1] 1.2345

_. - function(x) x^2
_.(12)
_# [1] 144

So, unless there is something I don't know about, there is hardly
anything to discuss about the detailed usage of '.' in R!
  

The ',' character is one of the characters allowed in names, hence it
can be used as you have suggested.  There are (at least) two special
usages of the '.' in names.  Following the time-honoured Unix
convention, names that begin with '.' are considered hidden names
and not listed by ls() or objects() unless you set all.names = TRUE in
the call.  Because of this convention it is inadvisable to use names
starting with '.' except when you wish to avoid potential name
conflicts.  The second special use of '.' in a name is in the
construction of the names of S3 method functions.  The method for
generic function foo applied to class bar is named foo.bar.



As in summary.glm, I suppose! However, this prompts a question.
In the first place, the construction of summary.glm from summary
and glm is, in the first instance, simply using . in its basic
role as a permissible character in a name. Correct?
  


Correct.

Next -- and this is the real question -- how does R parse the name
summary.glm? In my naivety, I simply suppose that it looks for
an available function whose name is summary.glm in just the
same way as it looks for stopifnot, or for that matter data.matrix
which is not (as far as I know) a compound of a generic function
data applied to a class matrix. Then . would not have a special
(parseable) role in the name -- it is simply another letter.
  


It doesn't do anything special when parsing.  The special sauce comes 
when the generic summary() function executes UseMethod(summary).  At 
that point, we know the class of the object, and we know the name of the 
generic, so it goes looking for a summary.glm method.


There are some subtleties to how it does that lookup (see the discussion 
in Writing R Extensions about NAMESPACES), but if you had a generic 
function calling UseMethod(data) and it was passed an object of class 
matrix, data.matrix() would be called, even though that doesn't make 
sense.  This is a flaw in the S3 system, and one of the motivations for 
the development of the S4 system.


Duncan Murdoch

But when you do have such a function, like summary.glm, does R
in fact parse it as summary then glm (i.e. look out for the
generic function summary and then specialise it to handle glm).

As I say, I suppose not. And, if not, then the special use of
the character . is simply a programmer's convention for the
construction of the name, and once the name exists the . does
not have a special (parseable) significance for R.

Just seeking clarification ... !
Thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-09   Time: 19:58:32
-- 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.



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


Re: [R] Linking in R package documentation

2009-08-09 Thread Duncan Murdoch

Rebecca Sela wrote:

I have two straightforward questions about linking in the man pages for R 
packages:

First, is it possible to link from within parts of the documentation that are 
not the \seealso section?  For example, I would like to have something like:
\arguments{
  \item{correlation}{an optional \code{corStruct} object describing the 
within-group correlation structure; the available classes are given in 
\link{\code{corClasses}}}
}
  


Yes, you can put \link anywhere.  But you should put things in the other 
order:  \code{\link{corClasses}}, or the link won't work.
When the package is compiled, the word corClasses is blue and underlines, but nothing happens when you click on it.  


Second, how do I link to a function of the same name in another package?  I 
thought I could use something like:
\seealso{\code{\link[nlme]{ranef}}}
but that gives a Page Not Found.  
  


That's close.  The trouble is that linking is slightly inconsistent in 
how it goes across packages:  you can't link to an alias ranef the way 
you normally do, you need to link to the filename of the Rd file 
containing that topic (in this case random.effects).  The reason for 
this is that in current R versions, all the links are built when the 
package is installed, and it may be that the package you refer to will 
be installed later:  so R can't look up the alias yet.  Hopefully we'll 
be able to relax this and allow alias links in a near future version of 
R, maybe even 2.10.0, because there are major changes happening to the 
implementation of the help system.  In at least HTML help, for example, 
it's likely that the alias ranef will be resolved at the time you 
click on the link.  At that point R can determine if you have nlme 
installed (which you almost certainly do), and look up the alias, to 
find the help page to display.


Duncan Murdoch

Thank you in advance!

Rebecca

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

2009-08-09 Thread Ted Harding
On 09-Aug-09 19:31:47, Duncan Murdoch wrote:
 (Ted Harding) wrote:
 [...]
 Next -- and this is the real question -- how does R parse the name
 summary.glm? In my naivety, I simply suppose that it looks for
 an available function whose name is summary.glm in just the
 same way as it looks for stopifnot, or for that matter data.matrix
 which is not (as far as I know) a compound of a generic function
 data applied to a class matrix. Then . would not have a special
 (parseable) role in the name -- it is simply another letter.
   
 
 It doesn't do anything special when parsing.  The special sauce comes 
 when the generic summary() function executes UseMethod(summary).
 At that point, we know the class of the object, and we know the name
 of the generic, so it goes looking for a summary.glm method.
 
 There are some subtleties to how it does that lookup (see the
 discussion in Writing R Extensions about NAMESPACES), but if you had
 a generic function calling UseMethod(data) and it was passed an
 object of class matrix, data.matrix() would be called, even though
 that doesn't make sense.  This is a flaw in the S3 system, and one of
 the motivations for the development of the S4 system.

Many thanks, Duncan. I think that makes it clear! You've prompted
me to read ?UseMethod':

  When a function calling 'UseMethod(fun)' is applied to an object
  with class attribute 'c(first, second)', the system searches
  for a function called 'fun.first' and, if it finds it, applies it
  to the object.  If no such function is found a function called
  'fun.second' is tried.  If no class name produces a suitable
  function, the function 'fun.default' is used, if it exists, or an
  error results.

which is pretty explicit that the role of the . is simply to
construct a name for the system to look for.

One learns ... Thanks.
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-09   Time: 21:22:23
-- 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] howto get the number of columns and column names of multiply data frames

2009-08-09 Thread Don MacQueen

## You can use get()

for ( i in 1:n) {
  nm - paste('dataframe',i,sep='')
  cat( ncol( get(nm)), 'columns in',nm,'\n') )
}


## or
nms - ls(pattern='dataframe')
  for (nm in nms) cat( ncol(get(nm)) , 'columns in',nm,'\n') )
}

(Assuming I have balanced parantheses, that is -- 
my email software doesn't check that like Emacs 
does!)


Storing the dataframes as elements of a list, as 
Steve Lianoglou suggested, lets you avoid using 
the get() function.


You could also use the count.fields() function to 
check whether the files have the correct number 
of columns even before you  read the data it. Or 
make a pass through the files reading in only the 
first line as data, and comparing those as data 
rather than as a names attribute of a dataframe.


-Don

At 5:29 PM +0200 8/9/09, Frank Schäffer wrote:

Hi,
I' ve read in several files with measurements into R data frames(works
flawlessly). Each dataframe is named by the location of measurement and
contains hundreds of rows and about 50 columns like this

dataframe1.
date measurment_1   mesurement_n
1
2
3
..
..
..
n

For further processing I need to check whether or not ncol and colnames are
the same for all dataframes.
Also I need to add a new column to each dataframe with contain the name of the
dataframe, so that this column can be treated as factor in later processing
(after merging some seleted dataframes to one)

I tried out

for (i in 1:length(ls()){
print(ncol(ls()[i])
}

but this does not work because r returns a character for i and therefore
NULL as result.
Reading the output of ls() into a list also does not work.

How can I accomplish this task??

Best regards and thanks

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.



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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


[R] problem adding columns to matrix

2009-08-09 Thread Fabio Murtas

Hi all, i purchased a copy of the book Morphometrics with R by Springer.
at the end of each chapter there are exercises to train what you just  
read and (hope) learned...


so i have this problem:

Define a hypothetical data frame containing five measurments normally  
distributed(size,head,pectoral,area,weight) for four individuals  
(named ind1, ind2, etc). ADD A COLUMN corresponding to the factor sex  
with individual 1  2 being Males and 3  $ being Females.




HERE IS HOW I PROCEDED, getting 2 problems
1) what are those warning messages i got when i generate the m matrix  
(the italian text stand for the numerical expression has 5 elements:  
just the first is used)
2) why when i use cbind to add the s factor wit M,M,F,F,   (sexes) to  
the m matrix i get numerical values 1  2 instead of character values  
M  F?


--
procedure follows:

 a- rnorm(5, 20, 7)
 a
[1] 27.32586 34.07330 21.11710 25.85710 22.68296
 a
[1] 27.32586 34.07330 21.11710 25.85710 22.68296
 b- rnorm(5, 20, 7)

 d- rnorm(5, 20, 7)


 e- rnorm(5, 20, 7)

 m-matrix(a:e, 4,5)
Warning messages:
1: In a:e :
 l'espressione numerica ha 5 elementi: solo il primo è utilizzato
2: In a:e :
 l'espressione numerica ha 5 elementi: solo il primo è utilizzato
3: In matrix(a:e, 4, 5) :
 data length [3] is not a sub-multiple or multiple of the number of  
rows [4]


 m
[,1] [,2] [,3] [,4] [,5]
[1,] 27.32586 28.32586 29.32586 27.32586 28.32586
[2,] 28.32586 29.32586 27.32586 28.32586 29.32586
[3,] 29.32586 27.32586 28.32586 29.32586 27.32586
[4,] 27.32586 28.32586 29.32586 27.32586 28.32586

 m-as.data.frame(m)
 m
   V1   V2   V3   V4   V5
1 27.32586 28.32586 29.32586 27.32586 28.32586
2 28.32586 29.32586 27.32586 28.32586 29.32586
3 29.32586 27.32586 28.32586 29.32586 27.32586
4 27.32586 28.32586 29.32586 27.32586 28.32586
 mode(m)
[1] list
 colnames(m)-c(size,head,pectoral,area,weight)
 mode(m)
[1] list

 m
 size head pectoral area   weight
1 27.32586 28.32586 29.32586 27.32586 28.32586
2 28.32586 29.32586 27.32586 28.32586 29.32586
3 29.32586 27.32586 28.32586 29.32586 27.32586
4 27.32586 28.32586 29.32586 27.32586 28.32586

rownames(m)-paste(ind, 1:4, sep=)


 m
size head pectoral area   weight
ind1 27.32586 28.32586 29.32586 27.32586 28.32586
ind2 28.32586 29.32586 27.32586 28.32586 29.32586
ind3 29.32586 27.32586 28.32586 29.32586 27.32586
ind4 27.32586 28.32586 29.32586 27.32586 28.32586

 s-factor(c(m,m,f,f))


 s
[1] m m f f
Levels: f m
 cbind(m,s)
size head pectoral area   weight s
ind1 27.32586 28.32586 29.32586 27.32586 28.32586 2
ind2 28.32586 29.32586 27.32586 28.32586 29.32586 2
ind3 29.32586 27.32586 28.32586 29.32586 27.32586 1
ind4 27.32586 28.32586 29.32586 27.32586 28.32586 1

--

Thanks in advance


Fabio Murtas
fabio.mur...@gmail.com

Nothing in biology make sense if not in Evolution light

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

2009-08-09 Thread cindy Guo
Hi, All,

I am wondering if there is any package which can give the index of the k
nearest neighbors.

Thank you,

Cindy

[[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] wget parameters

2009-08-09 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi,

Following an example I've received from Phil Spector, I am trying to get 
a remote file by using download file.

The concerned remote server doesn't username and password passed with 
the URL, thus this line fails...

download.file('http://username:passw...@xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02','RG02',method='wget')

I can get a free access file without any problem

download.file('http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample01?xpage=plain','RG01',method='wget')

But, of course, access to a protected one fails...

download.file('http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02?xpage=plain','RG02',method='wget')

*Wget does the trick *when executed from the comman line with the 
following parameters...

wget --http-user=DummyDummy --http-password=dummy --auth-no-challenge 
http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02?xpage=plain



Please, is it possible to pass these parameters to the method wget in 
download.file?

Thank you for your help,

Ricardo

-- 
Ricardo Rodríguez
Your XEN ICT Team


[[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] wget parameters

2009-08-09 Thread [Ricardo Rodriguez] Your XEN ICT Team

Please, accept my apologies for keeping posting in HTML format! Solved!

Greetings,

Ricardo

[Ricardo Rodriguez] Your XEN ICT Team wrote:

Hi,

Following an example I've received from Phil Spector, I am trying to get 
a remote file by using download file.


The concerned remote server doesn't username and password passed with 
the URL, thus this line fails...


download.file('http://username:passw...@xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02','RG02',method='wget')

I can get a free access file without any problem

download.file('http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample01?xpage=plain','RG01',method='wget')

But, of course, access to a protected one fails...

download.file('http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02?xpage=plain','RG02',method='wget')

*Wget does the trick *when executed from the comman line with the 
following parameters...


wget --http-user=DummyDummy --http-password=dummy --auth-no-challenge 
http://xepecnet.environmentalchange.net/xwiki/bin/view/ICT/RGraphicSample02?xpage=plain




Please, is it possible to pass these parameters to the method wget in 
download.file?


Thank you for your help,

Ricardo





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


--
Ricardo Rodríguez
Your XEN ICT Team

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 with a loop (coefficients with lmList)

2009-08-09 Thread Cecilia Carmo

Hi R-helpers.

#I start with the reproducible example:
firm-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10))
year-c(rep(1998:2007,5))
industry-c(rep(1,20),rep(5,10),rep(7,10),rep(9,10))
X1-rnorm(50)
X2-rnorm(50,mean=0.5,sd=0.1)
Y-rnorm(50,mean=0,sd=0.5)
data-data.frame(firm, industry,year,X1,X2,Y)
data

#I need to calculate for all the industries the following 
#coefficients and store it (lmList is from nlme package)
b1 - lmList(Y~X1+X2| year, na.action=na.omit, data, 
subset=industry==1)

b2-summary(b1)
b3-as.data.frame(b2$coefficients)
b4-round(b3,3)
b4  

#Instead of changing the industry in the subset I want to 
do it at once, so I’ve thinking in doing  a loop. Before I 
created an array to store my coefficients:


years-c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007)
industry-sort(unique(data$industry))
coef-c(Estimate.(Intercept),Std. Error.(Intercept),t 
value.(Intercept), Pr(|t|).(Intercept), Estimate.X1, 
Std. Error.X1,t value.X1, Pr(|t|).X1, 
Estimate.X2, Std. Error.X2, t value.X2, 
Pr(|t|).X2)

coefs-array(NaN,dim=c(10,12,4),dimnames=list(years,coef,industry))
coefs

#The loop that I’ve tried was:
for (k in industry){
	b1 - lmList(Y~X1+X2| year, 
na.action=na.omit,data,subset=industry==k)

b2-summary(b1)
b3-as.data.frame(b2$coefficients)
b4-round(b3,3)
coefs[ , , k]-b4[ , ]
}

This doesn't work. The data in the reproducible example as 
many NaN but I think this is not the problem. The problem 
is the R language. Could anyone help me?


Thanks in advance,

Cecília (Universidade de Aveiro – Portugal)

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


Re: [R] nearest neighbors

2009-08-09 Thread milton ruser
Hi cindy,

depends on your data type. It it is points, give a look at spatstat package.

bests
milton

On Sun, Aug 9, 2009 at 5:03 PM, cindy Guo cindy.g...@gmail.com wrote:

 Hi, All,

 I am wondering if there is any package which can give the index of the k
 nearest neighbors.

 Thank you,

 Cindy

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] help with a loop (coefficients with lmList)

2009-08-09 Thread Gabor Grothendieck
Your data has 2 points per regression for each year in industry 1 and
only one point per regression for the other industries so one would
expect many NAs:

 table(data[c(industry, year)])
year
industry 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
   12222222222
   51111111111
   71111111111
   91111111111


On Sun, Aug 9, 2009 at 6:45 PM, Cecilia Carmocecilia.ca...@ua.pt wrote:
 Hi R-helpers.

 #I start with the reproducible example:
 firm-c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10))
 year-c(rep(1998:2007,5))
 industry-c(rep(1,20),rep(5,10),rep(7,10),rep(9,10))
 X1-rnorm(50)
 X2-rnorm(50,mean=0.5,sd=0.1)
 Y-rnorm(50,mean=0,sd=0.5)
 data-data.frame(firm, industry,year,X1,X2,Y)
 data

 #I need to calculate for all the industries the following #coefficients and
 store it (lmList is from nlme package)
 b1 - lmList(Y~X1+X2| year, na.action=na.omit, data, subset=industry==1)
 b2-summary(b1)
 b3-as.data.frame(b2$coefficients)
 b4-round(b3,3)
 b4

 #Instead of changing the industry in the subset I want to do it at once, so
 I’ve thinking in doing  a loop. Before I created an array to store my
 coefficients:

 years-c(1998,1999,2000,2001,2002,2003,2004,2005,2006,2007)
 industry-sort(unique(data$industry))
 coef-c(Estimate.(Intercept),Std. Error.(Intercept),t
 value.(Intercept), Pr(|t|).(Intercept), Estimate.X1, Std.
 Error.X1,t value.X1, Pr(|t|).X1, Estimate.X2, Std. Error.X2, t
 value.X2, Pr(|t|).X2)
 coefs-array(NaN,dim=c(10,12,4),dimnames=list(years,coef,industry))
 coefs

 #The loop that I’ve tried was:
 for (k in industry){
        b1 - lmList(Y~X1+X2| year,
 na.action=na.omit,data,subset=industry==k)
 b2-summary(b1)
 b3-as.data.frame(b2$coefficients)
 b4-round(b3,3)
 coefs[ , , k]-b4[ , ]
 }

 This doesn't work. The data in the reproducible example as many NaN but I
 think this is not the problem. The problem is the R language. Could anyone
 help me?

 Thanks in advance,

 Cecília (Universidade de Aveiro – Portugal)

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

2009-08-09 Thread Paul Murrell

Hi

I don't have a Mac, but looking at the source, it seems that 
Times-Roman is the default serif family, so something like ...


quartz(family=serif)

... might get you what you want(?)

Paul


Daniel J Farrell wrote:

Dear r-help,

I am using R for MacOS (R 2.9.1 GUI 1.28 Tiger build 32-bit (5444))  
and would like to be able to use MacOS system fonts for the labels on  
my plots. So far I have been unsuccessful, to get this to work.


Reading the help I found the quartz() and quartzFonts() commands. In  
an attempt to set the font family I have tried this,


quartz(family=Times-Roman),

and also this,

quartz.options(family=Times-Roman).

This opens a new Quartz window, but the labels are still in the  
default font, when I make a new plot.


I have two question:
(1) Why doesn't the quartz(family=Times-Roman) make the fonts change?

(2) Is it possible to use any MacOS system fonts with R and the Quartz  
device window?


Best regards,

Daniel Farrell

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] problem adding columns to matrix

2009-08-09 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Fabio Murtas
 Sent: Sunday, August 09, 2009 1:51 PM
 To: R-help@r-project.org
 Subject: [R] problem adding columns to matrix
 
 Hi all, i purchased a copy of the book Morphometrics with R 
 by Springer.
 at the end of each chapter there are exercises to train what 
 you just  
 read and (hope) learned...
 
 so i have this problem:
 
 Define a hypothetical data frame containing five measurments 
 normally  
 distributed(size,head,pectoral,area,weight) for four individuals  
 (named ind1, ind2, etc). ADD A COLUMN corresponding to the 
 factor sex  
 with individual 1  2 being Males and 3  $ being Females.
 
 
 
 HERE IS HOW I PROCEDED, getting 2 problems
 1) what are those warning messages i got when i generate the 
 m matrix  
 (the italian text stand for the numerical expression has 5 
 elements:  
 just the first is used)
 2) why when i use cbind to add the s factor wit M,M,F,F,   
 (sexes) to  
 the m matrix i get numerical values 1  2 instead of 
 character values  
 M  F?
 
 --
 
 procedure follows:
 
   a- rnorm(5, 20, 7)
   a
 [1] 27.32586 34.07330 21.11710 25.85710 22.68296
   a
 [1] 27.32586 34.07330 21.11710 25.85710 22.68296
   b- rnorm(5, 20, 7)
  
   d- rnorm(5, 20, 7)
  
  
   e- rnorm(5, 20, 7)
 
   m-matrix(a:e, 4,5)
 Warning messages:
 1: In a:e :
   l'espressione numerica ha 5 elementi: solo il primo è utilizzato
 2: In a:e :
   l'espressione numerica ha 5 elementi: solo il primo è utilizzato
 3: In matrix(a:e, 4, 5) :
   data length [3] is not a sub-multiple or multiple of the number of  
 rows [4]
  
   m
  [,1] [,2] [,3] [,4] [,5]
 [1,] 27.32586 28.32586 29.32586 27.32586 28.32586
 [2,] 28.32586 29.32586 27.32586 28.32586 29.32586
 [3,] 29.32586 27.32586 28.32586 29.32586 27.32586
 [4,] 27.32586 28.32586 29.32586 27.32586 28.32586
 
   m-as.data.frame(m)
   m
 V1   V2   V3   V4   V5
 1 27.32586 28.32586 29.32586 27.32586 28.32586
 2 28.32586 29.32586 27.32586 28.32586 29.32586
 3 29.32586 27.32586 28.32586 29.32586 27.32586
 4 27.32586 28.32586 29.32586 27.32586 28.32586
   mode(m)
 [1] list
   colnames(m)-c(size,head,pectoral,area,weight)
   mode(m)
 [1] list
  
   m
   size head pectoral area   weight
 1 27.32586 28.32586 29.32586 27.32586 28.32586
 2 28.32586 29.32586 27.32586 28.32586 29.32586
 3 29.32586 27.32586 28.32586 29.32586 27.32586
 4 27.32586 28.32586 29.32586 27.32586 28.32586
 
  rownames(m)-paste(ind, 1:4, sep=)
  
  
   m
  size head pectoral area   weight
 ind1 27.32586 28.32586 29.32586 27.32586 28.32586
 ind2 28.32586 29.32586 27.32586 28.32586 29.32586
 ind3 29.32586 27.32586 28.32586 29.32586 27.32586
 ind4 27.32586 28.32586 29.32586 27.32586 28.32586
 
   s-factor(c(m,m,f,f))
  
  
   s
 [1] m m f f
 Levels: f m
   cbind(m,s)
  size head pectoral area   weight s
 ind1 27.32586 28.32586 29.32586 27.32586 28.32586 2
 ind2 28.32586 29.32586 27.32586 28.32586 29.32586 2
 ind3 29.32586 27.32586 28.32586 29.32586 27.32586 1
 ind4 27.32586 28.32586 29.32586 27.32586 28.32586 1
  
 --
 
 
 Thanks in advance
 

Fabio,

For question 1, the warning message is telling you that 

m-matrix(a:e, 4,5)

Is not doing what you think it is.  The syntax a:e creates a sequence, but
it is expecting a to be a single number, not a vector.  So, it is telling
you that it is only going to use the first value from  vector a.  Likewise,
it will only use the first value of vector e for the end value.  So
effectively, you statement gets interpreted as

m-matrix(a[1]:e[1], 4,5)  

Based on the random numbers you generated this created a sequence of
length=3.  You matrix was then created using just those 3 numbers (the first
3 numbers in the first column of your matrix) and recycled them as needed to
fill out the matrix.

You probably should have create the data frame directly, something like

df - data.frame(rbind(a,b,d,e))

As for question 2, I don't know why you got the values 1,2 in your data
frame.  When I ran your R code, the data frame I ended up with had the
values 'm', 'f'.  The values 1,2 are the underlying numeric values of the
factror you created, but why they showed up, I don't know.  It could have to
do with different versions of R, and or operating systems, etc., which you
told us nothing about.  I am using R-2.9.1 on Win XP Pro.

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA  

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


[R] index of intersect()

2009-08-09 Thread Praveen Surendran
Hi all,

 

Is there a way to get the index of elements in intersect(x,y) where x and y
are vectors with few common elements.

 

Appreciate your response.

 

Praveen Surendran.

 


[[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] index of intersect()

2009-08-09 Thread jim holtman
Is this what you want:

 set.seed(1)
 x - sample(letters,15)
 y - sample(letters,15)
 z - intersect(x,y)
 # find index in x
 match(z, x)
[1]  1  4  5  8  9 12 13 15
 # index in y
 match(z,y)
[1] 11 10  7  1 14  9  5  3

 z
[1] g u e m l c y x
 x
 [1] g j n u e s w m l b d c y v x
 y
 [1] m r x i y t e z c u g a f l q



On Sun, Aug 9, 2009 at 8:04 PM, Praveen
Surendranpraveen.surend...@ucd.ie wrote:
 Hi all,



 Is there a way to get the index of elements in intersect(x,y) where x and y
 are vectors with few common elements.



 Appreciate your response.



 Praveen Surendran.




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


[R] Hmisc get.mdb on mac os x 10.5.7 problems

2009-08-09 Thread stephen sefick
I have installed the Hmisc package and the mdb-tools package from
fink.  It is in my it is installed in the /sw/bin as to fink.  I have
looked at the code for get.mdb and called

system('mdb-tables /Users/sefick/Desktop/FTBragg_GeoDataBase_AuburnUNV.mdb')

and got this message

/bin/sh: mdb-tables: command not found

I can run mdb-tables from the command line- why can't I run it from
within R?  This is probably a path issue, and I am not the brightest
star in this area.
thanks,

-- 
Stephen Sefick

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] lattice: simultaneously control aspect outer whitespace

2009-08-09 Thread Deepayan Sarkar
On 8/7/09, Jacob Wegelin jacob.wege...@gmail.com wrote:
 Suppose we wish to achieve the following three aims:
  (1) Control the aspect ratio of our plot (i.e., tweak this till it looks
  great)

  (2) Save the plot as a PDF with zero or minimal white space outside it.

  (3) Preserve this in code, so that in the future the exact same plot can be
  reproduced by simply sourcing the code.

  I can almost achieve (1) and (2) on my MacBook Pro by pointing and clicking,
  as follows:

•   Start with graphics.off().

•   Generate the plot  on the computer screen; then the outer margins are
  pretty thin by default.

•   Use the mouse to adjust the aspect ratio until it looks right.

  The fact that I pointed and clicked precludes (3).

Once you have resized to a suitable size, use

par(din)

to find the current dimensions, and then use these as 'width' and
'height' arguments to pdf().

-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] multiple lty on same panel in xyplot

2009-08-09 Thread Deepayan Sarkar
On 8/7/09, Duncan Mackay mac...@northnet.com.au wrote:
 Hi RUsers

  I like to keep the plots self contained and avoid changing the current
 device parameters by using the par.settings.
  To see what I could achieve by using par settings I tried the following and
 several variants but could not get black points.

  xyplot(yM + yF ~ x,
 panel = panel.superpose,
 type = c(l, p),
 distribute.type = TRUE,
 par.settings = list(superpose.line = list(lty = c(1,2),
   col = c(black,black)),
 superpose.points = list(pch = c(1,1), col =
 c(black,black)),

'superpose.points' should be 'superpose.symbol'.

A convenient shortcut is

   par.settings = simpleTheme(col = black, lty = c(1, 2), pch = 1)

Try

str(simpleTheme(col = black, lty = c(1, 2), pch = 1))

to see what that does.

-Deepayan

 plot.symbol = list(pch = c(1,1), col =
 c(black,black))
 ),
 key = list(text = list(c(male, female)),
lines = Rows(pset$superpose.line, 1:2),
pch = 1,
type = c(l, p)))

  What am I missing? Does the points reference refer to Grid settings?

  Regards

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] label X-Axis by abother variable in R plot

2009-08-09 Thread Frank Zhang

Hi,
 
I would like to plot b, c in one plot, and use a as x-aix. How could I do that? 
Thanks
 
a,   b, c,
20, 2, 3
21, 4, 5
22, 1, 2
24, 3, 5
50, 3, 6
 
 
 
 
 


  
[[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] multiple lty on same panel in xyplot

2009-08-09 Thread Duncan Mackay

Hi Deepayan

Thank you very much for pointing out my mistake.

I had another go now with superpose.symbol and with several other 
combinations to see what could be done. All went well.


Regards

Duncan Mackay


At 13:19 10/08/2009, you wrote:

On 8/7/09, Duncan Mackay mac...@northnet.com.au wrote:
 Hi RUsers

  I like to keep the plots self contained and avoid changing the current
 device parameters by using the par.settings.
  To see what I could achieve by using par settings I tried the 
following and

 several variants but could not get black points.

  xyplot(yM + yF ~ x,
 panel = panel.superpose,
 type = c(l, p),
 distribute.type = TRUE,
 par.settings = list(superpose.line = list(lty = c(1,2),
   col = 
c(black,black)),

 superpose.points = list(pch = c(1,1), col =
 c(black,black)),

'superpose.points' should be 'superpose.symbol'.

A convenient shortcut is

   par.settings = simpleTheme(col = black, lty = c(1, 2), pch = 1)

Try

str(simpleTheme(col = black, lty = c(1, 2), pch = 1))

to see what that does.

-Deepayan

 plot.symbol = list(pch = c(1,1), col =
 c(black,black))
 ),
 key = list(text = list(c(male, female)),
lines = Rows(pset$superpose.line, 1:2),
pch = 1,
type = c(l, p)))

  What am I missing? Does the points reference refer to Grid settings?

  Regards


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


Re: [R] label X-Axis by abother variable in R plot

2009-08-09 Thread Zhiliang Ma
plot(b, c, xaxt=n)
axis(1, at=b, labels=as.character(a))

On Sun, Aug 9, 2009 at 9:33 PM, Frank Zhangfrankyuzh...@yahoo.com wrote:

 Hi,

 I would like to plot b, c in one plot, and use a as x-aix. How could I do 
 that? Thanks

 a,   b, c,
 20, 2, 3
 21, 4, 5
 22, 1, 2
 24, 3, 5
 50, 3, 6








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