Re: [R] multcomp

2007-03-18 Thread talepanda
?glht says
with 'print', 'summary',  'confint', 'coef' and 'vcov'  methods
being available.

try:

example(glht)
summary(glht(amod, linfct = mcp(tension = Tukey)))
confint(glht(amod, linfct = mcp(tension = Tukey)))

On 3/19/07, Nair, Murlidharan T [EMAIL PROTECTED] wrote:
 I used the multcomp package sometime back for doing multiple
 comparisons. I see that it has been updated and the methods like simint
 are no longer supported. When I run the program it prompts to me to use
 glht. How do I get the lower and upper conf int and the pValues using
 glht? Does anyone have an example?

 Thanks ../Murli




   [[alternative HTML version deleted]]

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


Re: [R] Complex superscript plot text

2007-03-16 Thread talepanda
try:

mtext(substitute(R^2 * : * GoodnessOfFits[i],list(i=graphNumber)))

HTH.

On 3/16/07, Bob Farmer [EMAIL PROTECTED] wrote:
 Hi all:

 I would like to create a line of plot margin text (using mtext() ) that
 features both a superscript and a subset of an object.  However, I
 cannot seem to do both things at once, nor have I found a way to paste
 the two results together.

 (I pull the object subset because this is part of a for-next loop to
 make multiple graphs)

 This example doesn't give me what I want from mtext():

 GoodnessOfFits-c(1, 0.75)

 graphNumber-1  #first loop of the for-next loop (not shown)

 x-seq(-10, 10, 1)
 y-(x^2)
 plot(x,y)
 lines(x, predict(lm(y~I(x^2
 mtext(text=
   expression(R^2 * : * GoodnessOfFits[graphNumber]))


 I recognize that in this example, I could extract the R-squared value
 from the model in each loop, however this does not apply to my more
 complicated real scenario.

 Any suggestions?

 Thanks.
 --Bob Farmer

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 on sigmoid curve fitting

2007-03-16 Thread talepanda
you can use nls:

see

?nls

and its example.

HTH.


On 3/16/07, Hufkens Koen [EMAIL PROTECTED] wrote:
 Hi list,

 I was wondering how I should go about fitting a sigmoid curve to a dataset.
 More specifically how I estimate parameters a and b in the following
 equation:

 1 / 1+exp(-(x-a)*b)

 with b the steepness of the sigmoid curve and a the shift of the center of
 the sigmoid curve relative to the center of your dataframe. The fit is in
 function of x, the location within the input vector and y, an ecological
 value.

 So I would like to estimate parameters a and b and a goodness of fit/
 F-value of some kind.

 Any suggestions?

 Kind regards,
 Koen


 --

 Checked by AVG Free Edition.

  11:27


   [[alternative HTML version deleted]]

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


Re: [R] cex in xlab, ylab and zlab of persp

2007-03-15 Thread talepanda
Internally, labs in persp are drawn as when you use text function.
So you cannot change the sizes by cex.lab, but you can change by cex:

persp(x, y, z, cex=1.5)

gives larger labs in persp 3d plot.
Of course there may be some side effect because it may change the size
something other than labs.

HTH

On 3/15/07, Joseph Retzer [EMAIL PROTECTED] wrote:
 I've had no success using what I think is the correct code to change the
 default size of the x, y and z labels in a persp graph (i.e. cex.lab).   Is
 there a particular specification to accomplish this?
 Many thanks,
 Joe Retzer

   [[alternative HTML version deleted]]

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


Re: [R] Problem with factor state when subset()ing a data.frame

2007-02-08 Thread talepanda
Probably, you have to do it by hand.
Exactly, I do not know the reason, but I can imagine.

Once you define factor, the empty factor is not meaningless.


The simple way to do it is refactorize:

 f-factor(1:3)
 f
[1] 1 2 3
Levels: 1 2 3
 factor(f[f!=2])
[1] 1 3
Levels: 1 3

On 2/9/07, Roger Leigh [EMAIL PROTECTED] wrote:
 Hi folks,

 I am running into a problem when calling subset() on a large
 data.frame.  One of the columns contains strings which are used as
 factors.  R seems to automatically factor the column when the
 data.frame is contstructed, and this appears to not get updated when I
 create a subset of the table.

 A minimal testcase to demonstrate the problem follows:


 sample - data.frame(c(A, A, A, A, B, B, B, C, C, C),
  c(5,3,5,3,6,7,8,3,2,6))
 names(sample) - c(ID, Value)

 print(sample)

 sample.filtered - subset(sample, ID != B, select=c(ID, Value))
 # Or sample.filtered - subset(sample, ID != B, select=c(ID, Value),
 drop=T)

 print(sample.filtered)

 plot(sample.filtered)
 plot(sample.filtered$Value ~ sample.filtered$ID)

 print(levels(sample.filtered$ID))
 print(levels(factor(sample.filtered$ID)))

 plot(sample.filtered$Value ~ factor(sample.filtered$ID))


 Am I doing something wrong here, or is this an R bug?  How can I get
 the new data.frame to update the factors, so I don't get redundant
 empty factors on the plot by eliminating the phantom factors?  (I
 also need to remove the unused factors for other analyses, and
 factoring them by hand seems a little redundant.)


 Kind regards,
 Roger

 --
   .''`.  Roger Leigh
  : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
  `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
`-GPG Public Key: 0x25BFB848   Please GPG sign your mail.


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


Re: [R] sorting a matrix by a different colnames order

2007-02-07 Thread talepanda
try:

mx[,new.col.names]

HTH.

On 2/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi R users,
 I would like to know how to sort a matrix according a different order of
 colnames (or rownames) ,e.g.,
 mx = matrix(rnorm(1:20),5,4)
 colnames(mx) = letters[1:4]
 rownames(mx) = letters[1:5]
 mx
  a  b  c   d
 a  0.02362598 -0.7033460  0.8106089 -1.03456219
 b -0.45021522 -1.5769522  0.1770634  0.27997249
 c  1.34732392  0.2956623  2.0027231 -0.85321627
 d  0.82314457  1.2698347 -0.5468151  0.05806375
 e -0.18668401 -0.4210383  0.6263465 -0.18889031

 (new.col.names = sample(letters[1:4]))
 [1] a b d c

 so the new matrix has to be ordered according the new.col.names,i.e.,
  a  b   d  c
 a  0.02362598 -0.7033460  -1.03456219  0.8106089
 b -0.45021522 -1.5769522   0.27997249  0.1770634
 c  1.34732392  0.2956623  -0.85321627  2.0027231
 d  0.82314457  1.2698347   0.05806375 -0.5468151
 e -0.18668401 -0.4210383  -0.18889031  0.6263465

 Hope this is not a basic question

 Thank you for your help.

 Paolo

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


Re: [R] ANOVA Table for Full Linear Model?

2007-02-06 Thread talepanda
summary.lm tells you F, df, and p value.

try:

summary(regression9)


On 2/6/07, Jason R. Finley [EMAIL PROTECTED] wrote:
 Hello,
 I have spent a good deal of time searching for an answer to this but
 have come up empty-handed; I apologize if I missed something that is
 common knowledge.

 I am trying to figure out how to get an ANOVA table that shows the
 sum of squares. degrees of freedom, etc, for the full model versus
 the error (aka residuals).

 Here is an example of the kind of table I'd like to get:

 Analysis of Variance
 Source   DF  SS  MS FP
 Regression1  8654.7  8654.7102.350.000
 Error75  6342.184.6
 Total76 14996.8

 This kind of table is prevalent throughout my statistics textbook,
 and can apparently be easily obtained in other statistical software
 tools.  I'm not saying this as a gripe, but just as evidence that I'm
 not trying to do something obviously bizarre.


 Here is an example of the only kind of ANOVA table for a single
 linear model that I've been able to get using R:

   regression9 - lm(y ~ x1 + x2 + x3, data=data9)
   anova.lm(regression9)
 Analysis of Variance Table

 Response: y
Df Sum Sq Mean Sq F valuePr(F)
 x1 1 8275.4  8275.4 81.8026 2.059e-11 ***
 x2 1  480.9   480.9  4.7539   0.03489 *
 x3 1  364.2   364.2  3.5997   0.06468 .
 Residuals 42 4248.8   101.2
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


 Is there a way to get an ANOVA table with the full linear regression
 model considered as a whole rather than broken down into each
 additional predictor variable?  In other words, is there a way to get
 the former kind of table?

 Again, apologies if I'm missing something basic.
 thanks very much,
 ~jason


 PS - I am on Mac OSX 10.4.8 using R 2.4.1 GUI 1.18 (4038)

 ~
 Jason R. Finley
 Graduate Student, Department of Psychology
 Cognitive Division
 University of Illinois, Urbana-Champaign

 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 http://www.jasonfinley.com/
 ~

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


Re: [R] Rconsole - setting the size and location of Windows help files (Rgui)

2007-02-06 Thread talepanda
For the very good reason that you can have multiple pagers and I at least
do not want them exactly on top of one another.

Yes. and I knew for the first time now that location of new pager is
randomly determined.
I think it is cool way.

On 2/6/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Tue, 6 Feb 2007, talepanda wrote:

  For size, maybe:
 
  # Dimensions(in characters) of the internal pager.
  #pgrows = 25
  #pgcolumns = 80
  pgrows = 48
  pgcolumns = 128
 
  in Rconsole, but location cannot be handled.

 For the very good reason that you can have multiple pagers and I at least
 do not want them exactly on top of one another.

 [...]

 --
 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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 reorder rows in dataframe by text flag

2007-02-06 Thread talepanda
I think several ways can do that.
my code is:

data.frame(t(apply(dat,1,function(x)as.numeric(sub(\\*,,x[sort(1:2,grep(\\*,x)==2)])

HTH

On 2/7/07, Dale Steele [EMAIL PROTECTED] wrote:
 Given two columns of type character in a dataframe of the form:

 col1col2
 31*  66
 0 0*
 102*66
 71*  80
 31   2*
 66   31*
 47   38*

 How do I generate the following dataframe?  Ie. col1 contains row item
  with * and col2 contains row member without *

 col1col2
 31   66
 0 0
 102 66
 71   80
 231
 31  66
 38  47

 Partial ideas thus far
 grep(*,col1,fixed=T)
 as.numeric(gsub(*,,col1))

 Thanks.  --Dale

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 reorder rows in dataframe by text flag

2007-02-06 Thread talepanda
I'm sorry, I forgot my definition of dat.
dat in code of previous post is:

 dat-data.frame(col1=c(31*,0,102*,71*,31,66,47),col2=c(66,0*,66,80,2*,31*,38*))
 dat
  col1 col2
1  31*   66
20   0*
3 102*   66
4  71*   80
5   31   2*
6   66  31*
7   47  38*


On 2/7/07, talepanda [EMAIL PROTECTED] wrote:
 I think several ways can do that.
 my code is:

 data.frame(t(apply(dat,1,function(x)as.numeric(sub(\\*,,x[sort(1:2,grep(\\*,x)==2)])

 HTH

 On 2/7/07, Dale Steele [EMAIL PROTECTED] wrote:
  Given two columns of type character in a dataframe of the form:
 
  col1col2
  31*  66
  0 0*
  102*66
  71*  80
  31   2*
  66   31*
  47   38*
 
  How do I generate the following dataframe?  Ie. col1 contains row item
   with * and col2 contains row member without *
 
  col1col2
  31   66
  0 0
  102 66
  71   80
  231
  31  66
  38  47
 
  Partial ideas thus far
  grep(*,col1,fixed=T)
  as.numeric(gsub(*,,col1))
 
  Thanks.  --Dale
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Histogram of ones.

2007-02-06 Thread talepanda
If I correctly understand,

hist(rep(1, 100), col=lightblue, border=black,breaks=0:10*0.1)

see:
breaks arg in ?hist


On 2/7/07, Dong H. Oh [EMAIL PROTECTED] wrote:
 Dear expeRts,


 I'd like to picture histogram of ones.

 For example,

  hist(rep(1, 100), col=lightblue, border=black)

 A bin is pictured ranging on [0,1] and range of x axis is also [0,1].

 How can I adjust the bin range from [0,1] to [0.9, 1] ?

 I am looking forward to hearing from expeRt.


 Sincerely,

   [[alternative HTML version deleted]]

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

2007-02-05 Thread talepanda
 d-data.frame(id=1:4,x=c(0.1,0.5,0.2,0),y=c(3,1,9,5))
 d
  id   x y
1  1 0.1 3
2  2 0.5 1
3  3 0.2 9
4  4 0.0 5
 d[order(d$y),]
  id   x y
2  2 0.5 1
1  1 0.1 3
4  4 0.0 5
3  3 0.2 9

On 2/6/07, XinMeng [EMAIL PROTECTED] wrote:
 Hello sir:
 How can I sort a dataframe by sorting one of its column?

 e.g.

 dataframe:

 id  x   y
 a  0.1  3
 b  0.5  1
 c  0.2  9
 d  05

 I want the dataframe sorted according to y accending,the result is:

 id  xy
 b   0.5  1
 a   0.1  3
 d   05
 c   0.2  9



 Thanks a lot!

 My best

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


Re: [R] Rconsole - setting the size and location of Windows help files (Rgui)

2007-02-05 Thread talepanda
For size, maybe:

# Dimensions(in characters) of the internal pager.
#pgrows = 25
#pgcolumns = 80
pgrows = 48
pgcolumns = 128

in Rconsole, but location cannot be handled.

On 2/6/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 Using the Rconsole file I can specify the size and location of the Rgui
 windows on NT.
 e.g.
 # Dimensions (in characters) of the console.
 rows = 51
 columns = 100

 How can I specify the size of the help windows that popups
 when I ask for help? e.g. '?help'
 I would like the popup window to have say rows = 51 and columns = 100,
 just like the main window but a different location on the screen.

 In my .Rprofile file I have set 'options(winhelp=FALSE)'.

 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)

 Regards,

 John.

 John Gavin [EMAIL PROTECTED],
 Commodities, FIRC,
 UBS Investment Bank, 2nd floor,
 100 Liverpool St., London EC2M 2RH, UK.
 Phone +44 (0) 207 567 4289
 This communication is issued by UBS AG and/or affiliates to
 institutional investors; it is not for private persons. This is a
 product of a sales or trading desk and not the Research Dept.
 Opinions expressed may differ from those of other divisions of UBS,
 including Research.  UBS may trade as principal in instruments
 identified herein and may accumulate/have accumulated a long or short
 position in instruments or derivatives thereof.  UBS has policies
 designed to negate conflicts of interest.  This e-mail is not an
 official confirmation of terms and unless stated, is not a
 recommendation, offer or solicitation to buy or sell.  Any prices or
 quotations contained herein are indicative only.  Communications
 may be monitored.

  (c) 2006 UBS.  All rights reserved.
 Intended for recipient only and not for further distribution without
 the consent of UBS.

 UBS Limited is a company registered in England  Wales under company
 number 2035362, whose registered office is at 1 Finsbury Avenue,
 London, EC2M 2PP, United Kingdom.

 UBS AG (London Branch) is registered as a branch of a foreign company
 under number BR004507, whose registered office is at
 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.

 UBS Clearing and Execution Services Limited is a company registered
 in England  Wales under company number 03123037, whose registered
 office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 invisible function

2007-01-30 Thread talepanda
Dear R-er:

I want to use invisible function in some packages.

I know that triple colon operater is available.
However, how can I use all invisible functions in some packages.

One solution is , of course, to use ::: in every use, but is there
any workaround?

It is similar to using namespace directive in C++.

using std::cout;
using std::cin;

is triple colon approach, and

using namespace std;

is what I want.




The reason why I want this is to modify function in some packages.

For example, I want to get the SSs in stats::anova.mlm.
This is not difficult, but anova.mlm uses many invisible functions,
so I have to use ::: in every use, or, define, e.g.
Rank-stats:::Rank
etc.
in my scope.


Thanks in advance.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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: two grouping variables, one controls 'col', the other 'pch'

2007-01-28 Thread talepanda
Currently, both color and plotting symbol does not change with the
grouping variable g1, that is, when
g1-rep(5:8,each=64)
,plotxy still generates same plot.

subscripts argument is useful for your purpose.

see:
panel section and details in
 ?xyplot

try:

plot-xyplot(y~x|f,
 groups=g1,
 panel=function(x,y,subscripts,groups,...){
   
panel.superpose(x,y,subscripts,groups,pch=g2[subscripts],col=g1[subscripts],...)
 })

HTH

On 1/29/07, Benjamin Tyner [EMAIL PROTECTED] wrote:
 Say I have

 library(lattice)

 x-runif(256)
 y-runif(256)
 f-gl(16,16)
 g1-rep(1:4,each=64)
 g2-rep(1:4,times=64)

 plot-xyplot(y~x|f,
  groups=g1,
  pch=as.character(1:4),
  panel=function(x,y,subscripts,groups,...){
panel.superpose(x,y,subscripts,groups,...)
  })

 print(plot)

 Currently, both color and plotting symbol change with the grouping
 variable g1. What is the best way to have color change with g1, but
 plotting symbol change with g2 (or vice versa)?

 Thanks,
 Ben

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


Re: [R] Canging the type of point points sizein plots..

2007-01-27 Thread talepanda
try:

plot(1:10,pch=1:10,cex=1:10)

pch specifies the types and cex specifies the sizes of symbols.

On 1/28/07, vinod gullu [EMAIL PROTECTED] wrote:
 I want to plot variation of more than one variable in
 single plot with different point types and points
 sizes . Can someone help me to do that,

 Thanks in advance.
 vinod



 
 Now that's room service!  Choose from over 150,000 hotels

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


Re: [R] defining function into another function

2007-01-26 Thread talepanda
First question: Yes
Second question: z in func.int2 is z in myfunc (z=y^3).

You can easily test:

f0-function(){
  z-1
  f1-function()print(f1)
  f2-function(z){f1();print(z)}
  f2(z)
}
z-0
f0()


R language definition may be helpful

http://cran.r-project.org/doc/manuals/R-lang.html#Scope-of-variables

On 1/26/07, domenico pestalozzi [EMAIL PROTECTED] wrote:
 If I define my function that includes others internal functions, how can I
 define the parameter's functions?
 That is:

 myfunc-function(y){...

 func.int1- function(x){ sum(x}}
 func.int2-function(z){funct.int1(z)^2} .
  }

 Is it possible to use func.int1 into func.into2? or R doesn't identify
 func.int1 into func.into2?

 Another question:
 If I do

  myfunc-function(y){...
  z-y^3

 func.int1- function(x){ sum(x}}
 func.int2-function(z){z^2}
 .
  }

 func.int2 is based on z, but now is z=y^3 or a generical object?


 thanks

 pestalozzi

   [[alternative HTML version deleted]]

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


Re: [R] Substring error

2007-01-25 Thread talepanda
It occurs why start or stop could not be converted into integer of
length  0 by using as.interger().

More presicely,
if( !isInteger(sa) || !isInteger(so) || k == 0 || l == 0 ) # c code
where sa is start, so is stop, k is length(start), l is length(stop)

For example:

substr(orz,character(0),0)
substr(orz,numeric(0),0)
substr(orz,logical(0),0)
substr(orz,integer(0),0)
substr(orz,NULL,0)

produce the error because of k==0


But there seems to be another case which I don't know.


On 1/25/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
 Hi,



 Do anybody know when and why the below error we get?



 Error in substr(x, as.integer(start), as.integer(stop)) :
 invalid substring argument(s) in substr()



 Thanks in advance,

 Shubha


   [[alternative HTML version deleted]]

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


Re: [R] Checking for the existence of an R object

2007-01-24 Thread talepanda
see:

?exists

HTH.

On 1/24/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
 Hi,



 Is there any way to check whether an R object exists or not? Say
 example: a data frame.



 Thanks,

 Shubha


   [[alternative HTML version deleted]]

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


Re: [R] Vector to Matrix transformation

2007-01-24 Thread talepanda
non-elegant solution:

matrix(c(V1,rep(NA,-length(V1)%%5)),nrow=5)

HTH.


On 1/24/07, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
 How to suppress the recycling of items in a matrix..instead NA can be
 filled.
 -Original Message-
 From: Chuck Cleland [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 23, 2007 8:00 PM
 To: Shubha Vishwanath Karanth
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Vector to Matrix transformation

 Shubha Vishwanath Karanth wrote:
  Hi R,
 
  I have a vector V1 of unknown length, say n. I need to convert this
 into
  a matrix C of row size=5, and accordingly the column should be
 updated.
  I tried with:
 
  C=as.matrix(V1,5,n/5)
 
  But it is not working...Could somebody help me on this?

   You could try the following:

 matrix(V1, nrow=5)

   but note what happens when the length of V1 is not a multiple of 5.

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

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

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


Re: [R] Date variable

2007-01-24 Thread talepanda
For Date class, *original* (that is, contents in memory)  is 12853,
and 2005-03-11 is one expression of the original.
So you have to convert from the original to the charecter expression as follows.

 s[1]-format(date)
 s
[1] 2005-03-11 FALSE  FALSE

 s[1]-as.character(date)
 s
[1] 2005-03-11 FALSE  FALSE


BTW, I think
 s = vector(character, length=3)
is more preferable for your purpose.


HTH.


On 1/24/07, stat stat [EMAIL PROTECTED] wrote:
 Dear R users,

   I did following with a date variable

   library(date)
   date = 03/11/05
 date = as.Date(date, format=%m/%d/%y)
 date
 [1] 2005-03-11
 s = vector(length=3)
 s[1] = date
 s[1]
 [1] 12853

   But here I got s[1] as 12853. But this is not that I want. I need s[1] as
 original date.

   Can anyone tell me where is the mistake?

   Thanks and regards,


   
 -
  Here's a new way to find what you're looking for - Yahoo! Answers
   [[alternative HTML version deleted]]




__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 change the dataframe labels' ?

2007-01-24 Thread talepanda
rownames()-  is what you want.

 dat-data.frame(V1=sample(10),V2=sample(10))
 dat
   V1 V2
1   2  5
2   3  8
3   8  4
4   9  6
5   6  2
6   5  7
7  10  3
8   4  9
9   1 10
10  7  1
 dat-dat[order(dat$V2),]
 dat
   V1 V2
10  7  1
5   6  2
7  10  3
3   8  4
1   2  5
4   9  6
6   5  7
2   3  8
8   4  9
9   1 10
 rownames(dat)-1:dim(dat)[1]
## or rownames(dat)-dat$V2
 dat
   V1 V2
1   7  1
2   6  2
3  10  3
4   8  4
5   2  5
6   9  6
7   5  7
8   3  8
9   4  9
10  1 10

HTH

On 1/24/07, domenico pestalozzi [EMAIL PROTECTED] wrote:
 I import a dataframe composed by 2 variables and 14000 cases. Now I need the
 labels of the cases sorted by the second variable V2, but if I sort the
 dataframe according to the second variable:

 mydataframe- mydataframe[order(mydataframe$V2),]

 I notice that the labels are always the same (that is, not ordered by V2).

 How to change them?
 I tried :

 labels(mydataframe)-1:14000

 but it doesn't work.

 Thanks

 domenico

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 change the dataframe labels' ?

2007-01-24 Thread talepanda
I did not know the fact.
Thanks for useful information.


On 1/24/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 Sorry, no: row.names-() is what you want.

 rownames for matrices (and arrays)
 row.names for data frames.

 Using them the other way round usually works but can be very inefficient.
 From R-devel (where the worst inefficiencies are circumvented)

   The extractor functions try to do something sensible for any
   matrix-like object 'x'.  If the object has 'dimnames' the first
   component is used as the row names, and the second component (if
   any) is used for the column names.  For a data frame, 'rownames'
   and 'colnames' are calls to 'row.names' and 'names' respectively,
   but the latter are preferred.


 On Wed, 24 Jan 2007, talepanda wrote:

  rownames()-  is what you want.
 
  dat-data.frame(V1=sample(10),V2=sample(10))
  dat
V1 V2
  1   2  5
  2   3  8
  3   8  4
  4   9  6
  5   6  2
  6   5  7
  7  10  3
  8   4  9
  9   1 10
  10  7  1
  dat-dat[order(dat$V2),]
  dat
V1 V2
  10  7  1
  5   6  2
  7  10  3
  3   8  4
  1   2  5
  4   9  6
  6   5  7
  2   3  8
  8   4  9
  9   1 10
  rownames(dat)-1:dim(dat)[1]
  ## or rownames(dat)-dat$V2
  dat
V1 V2
  1   7  1
  2   6  2
  3  10  3
  4   8  4
  5   2  5
  6   9  6
  7   5  7
  8   3  8
  9   4  9
  10  1 10
 
  HTH
 
  On 1/24/07, domenico pestalozzi [EMAIL PROTECTED] wrote:
  I import a dataframe composed by 2 variables and 14000 cases. Now I need
 the
  labels of the cases sorted by the second variable V2, but if I sort the
  dataframe according to the second variable:
 
  mydataframe- mydataframe[order(mydataframe$V2),]
 
  I notice that the labels are always the same (that is, not ordered by
 V2).
 
  How to change them?
  I tried :
 
  labels(mydataframe)-1:14000
 
  but it doesn't work.
 
  Thanks
 
  domenico
 
 [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] Days of the week?

2007-01-24 Thread talepanda
?Date seems to say that weekdays() is appropriate for that:

weekdays(as.Date(2006-12-01))

see:
?weekdays

On 1/25/07, John McHenry [EMAIL PROTECTED] wrote:
 Hi WizaRds,

 What is the standard way to get the day of the week from a date such
 as as.Date(2006-12-01)? It looks like fCalendar has some functions
 but this requires a change in the R locale to GMT. Is there another way?

 Thanks!

 Jack.


 -
 Be a PS3 game guru.

   [[alternative HTML version deleted]]

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


Re: [R] command-line arguments in R

2007-01-22 Thread talepanda
see:
?commandArgs

or more detail for R startup mechanisms:
?Startup


On 1/22/07, Deepak Chandra [EMAIL PROTECTED] wrote:
 Hi All,

 A  simple and naive question from a newbie.  How can one access command-line
 arguments in R i.e. equivalent of argv in C?
 Have spent a lot of time on finding it.  Also, it will be useful if someone
 can point me out to a resource which I could have used to answer this
 question or similar ones.


 Thanks,
 Deepak

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 disable existing menus in tcltk?

2007-01-22 Thread talepanda
play below after your code and look at tk window:

tkentryconfigure(editMenu,0,state=disable)
tkentryconfigure(editMenu,0,state=active)

tkentryconfigure(topMenu,1,state=disable)
tkentryconfigure(topMenu,1,state=active)

HTH

On 1/22/07, Jarno Tuimala [EMAIL PROTECTED] wrote:
 Hi!

 I've constructed a small menu-driven interface to a couple of R functions
 using the possibilities offered by the tcltk package. When user runs some
 specific analyses, I would then like to disable some of the menus (or menu
 choises) that are not applicable after the performed analysis. I tried to
 modify the state of an existing menu, but it seems that neither
 tkconfigure nor tkentryconfigure contains the state as one of its options.

 Here's a snip of the code. How could I disable, for example, the Edit
 data menu choise after already creating the menu (I want it to be active
 initially)?

 gui-tktoplevel()
 topMenu-tkmenu(gui)
 tkconfigure(gui,menu=topMenu)
 editMenu-tkmenu(topMenu, tearoff=FALSE)
 tkadd(editMenu, command, label=Edit data, command=function() editData())
 tkadd(editMenu, command, label=Preferences, command=function()
 editPref())
 tkadd(topMenu, cascade, label=Edit, menu=editMenu)

 Thanks,
 Jarno Tuimala

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


Re: [R] Query about using try block

2007-01-22 Thread talepanda
Usually (that is, not limited in R language), when error occurs in
try, stacks are rollbacked, so the variables defined in try no longer
exists after calling try.

One non-elegant solution is:

fit-NULL
try ( (fit = lm(y~x, data = data_fitting)), silent =T)
if(!is.null(fit)){
coeffs = as.list(coef(fit))
## other subsequent processes
}

On 1/23/07, lalitha viswanath [EMAIL PROTECTED] wrote:
 Hi
 Thanks for your response.
 However I seem to be doing something wrong regarding
 the try block resulting in yet another error described
 below.

 I have a function that takes in a file name and
 does the fit for the data in that file.
 Hence based on your input, I tried

 try ( (fit = lm(y~x, data = data_fitting)), silent =
 T);


 I left the subsequent lines of my code unchanged.
 coeffs = as.list(coef(fit);
 lambda = exp(coeffs$x)

 After the change using try, when I tried to resume
 processing under R as follows
 source(fitting.R)
 for filename in list { process(filename); }
 It says Cannot find object fit ...(in the line
 trying to get the coefficients...)

 Am I closing the try block in the wrong place?
 This function does some post processing on the
 coefficients returned by coef(fit), puts them in a
 list and sends it to another function.
 (i.e. around 6 lines of code after the call to fit).
 Thanks
 Lalitha
 --- Andreas Hary [EMAIL PROTECTED] wrote:

  Look at ?try
 
  Your code will probably need to be something like
  the following:
 
  fit - list()
  for(fileId in 1:n){
 try(fit[i] - lm(formula,data=???,...), silent=F)
 #or silent=T if you would like to be made aware
  of problems
  }
 
  Best wishes,
 
  Andreas
 
 
 
 
  lalitha viswanath wrote:
   Hi
   I am a newbie to R and am using  the lm function
  to
   fit my data.
   This optimization is to be performed for around
  45000
   files not all of which lend themselves to
   optimization. Some of these will and do crash.
  
   However, How do I ensure that the program simply
  goes
   to the next file in line without exiting the code
  with
   the error
   Error in lm.fit(x, y, offset = offset,
  singular.ok =
   singular.ok, ...) :
   NA/NaN/Inf in foreign function call (arg
  4)
   everytime it encounters troublesome data?
  
   I would greatly appreciate your input as it would
   avoid me having to manually type
   for fileId in (c(4351:46000)) { ... }
   for fileId in (c(5761:46000)) { ... }, etc...
  
   Thanks
   Lalitha
  
  
  
  
 
 
   Now that's room service!  Choose from over 150,000
  hotels
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained,
  reproducible code.
  
 
  --
  =
  Andreas Hary
  Flat 5, 70 Finsbury Park Road
  Lond, N4 2JX, UK
 
  Email:  [EMAIL PROTECTED]
  Mobile: 07906 860 987
 




 
 Want to start your own business?

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


Re: [R] factor()

2007-01-22 Thread talepanda
 TeamInfo
TEAMNAME LEVEL WORKTIME BONUS
1  batch   sunan B  135 9,818
2  batch  Chenqi E  121 6,050
3  batch jiangxu F   97 4,189
4 online  zhouxi F   63 2,720
5 online  chenhe H   36 1,064

## try:

 factor(TeamInfo$TEAM)
[1] batch  batch  batch  online online
Levels: batch online

## or

 attach(TeamInfo)
 factor(TEAM)
[1] batch  batch  batch  online online
Levels: batch online


On 1/23/07, qing [EMAIL PROTECTED] wrote:














 Dear All,

 I am running Windows XP, R 2.4.1, and doing an example about factor().

  read.csv(c:\\TeamInfo.csv)-TeamInfo;
  TeamInfo;
  TEAMNAME LEVEL WORKTIME BONUS
 1   batch   sunan B  135 9,818
 2   batch  Chenqi E  121 6,050
 3   batch jiangxu F   97 4,189
 4  online  zhouxi F   63 2,720
 5  online  chenhe H   36 1,064
 6  online NA
 7  online NA
 8  online NA
 9  online NA
 10 client NA
 11 client NA
 12 client NA
 13 client NA
 14 client NA
  factor(TEAM)-Teamactor;
 Error in typeof(x) : object TEAM not found

 Any help or suggestions that you can provide will be greatly appreciated.

 Qing

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 option in 'barplot'?

2007-01-18 Thread talepanda
Probably, you have to manually create, but it is easy:

# for beside=F
mp - barplot(VADeaths)
text(mp,y-t(apply(VADeaths,2,cumsum)),y) # labels are values itself
# or
mp - barplot(VADeaths)
text(mp,t(apply(VADeaths,2,cumsum)),VADeaths) # labels are cumsum of values

# for besides=T
mp - barplot(VADeaths,beside=T)
text(mp,VADeaths,VADeaths)

## maybe some adjustment is required for y position, then, for example,

mp - barplot(VADeaths,beside=T)
text(mp,VADeaths+3,VADeaths)

HTH

On 1/18/07, Justin Gengler [EMAIL PROTECTED] wrote:
 Hello all,

 When using the 'barplot' function, how would one go about creating
 labels on the top of the bars corresponding to the actual frequency
 values (i.e., the height of the bar).  For histograms, one can use
 the 'LABEL=T' parameter to this effect, but it is not available for
 barplot.  Must one manually create such labels for a barplot (perhaps
 using mtext)?

 Thanks.

 Justin Gengler

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 get the index of entry with max value in an array?

2007-01-17 Thread talepanda
In R language, one solution is:

a-c(3,4,6,2,3)
which(a==max(a))


On 1/18/07, Feng Qiu [EMAIL PROTECTED] wrote:
 Hi all:
  A short question:
  For example,  a=[3,4,6,2,3], obviously the 3rd entry of the array
 has the maxium value, what I want is index of the maxium value: 3. is there
 a neat expression to get this index?

 Thank you!

 Best,

 Feng


   [[alternative HTML version deleted]]

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


Re: [R] Problem with pdf, png, jpeg devices and files named CON on Window s

2007-01-15 Thread talepanda
It's not R problem but specification of windows file system.
see MSDN:

http://msdn2.microsoft.com/en-us/library/aa365247.aspx

On 1/15/07, Brandt, T. (Tobias) [EMAIL PROTECTED] wrote:
 Hi

 I cannot seem to create any files that have the name CON before the file
 extension, i.e. all of the following fail:

  pdf(CON.pdf)
 Error in pdf(CON.pdf) : unable to start device pdf
  jpeg('CON.jpeg')
 Error in jpeg(CON.jpeg) : unable to start device devWindows
  png('CON.png')
 Error in png(CON.png) : unable to start device devWindows
  sink('CON.txt')
 Error in file(file, ifelse(append, a, w)) :
 unable to open connection
 

 Any filename other than this works fine.

  png('ICON.png')
  dev.off()
 null device
   1
  png('CON1.png')
  dev.off()
 null device
   1
  sink('log.txt')
  sink()
 

 Remembering that in the old DOS days, commands like 'copy CON myfile.bat'
 were common, I suspected that this has something to do with CON being a
 reserved word so I tried to create the files manually in Windows explorer.
 Creating files named 'CON.png', 'CON.pdf', 'CON.txt' all work fine. However
 I did notice that Windows won't let me create a file named just CON.
 However since the devices that I'm trying to create have extensions, I don't
 understand why they fail.

 Who can help?

 Thanks
 Tobias


  version
_
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  3.1
 year   2006
 month  06
 day01
 svn rev38247
 language   R
 version.string Version 2.3.1 (2006-06-01)
 

  Sys.info()
   sysname   release
 version  nodename
 Windows  NT 5.1 (build 2600)
 Service Pack 2
   machine login
 user
 x86
 

 
 Nedbank Limited Reg No 1951/09/06. The following link displays the names
 of the Nedbank Board of Directors and Company Secretary. [
 http://www.nedbank.co.za/terms/DirectorsNedbank.htm ]
 This email is confidential and is intended for the addressee only. The
 following link will take you to Nedbank's legal notice. [
 http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]

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


Re: [R] levelplot not adjusting colors

2007-01-12 Thread talepanda
col.region changes both colors in plot and colorkey.

try:

x - seq(pi/4, 5 * pi, length = 100)
y - seq(pi/4, 5 * pi, length = 100)
levelplot(z~x*y) #default
levelplot(z~x*y,col.regions=rainbow(24)) #custom color


On 1/11/07, Bram Kuijper [EMAIL PROTECTED] wrote:
 Hi all,

 I try to make a levelplot from the Trellis graphics package of count
 data given a certain x and y variable.

 The problem is that I can adjust the colorkey colors, but the colors of
 the actual values in the plot will be unchanged if I change the colorkey.

 e.g.
 my_lvl_plot - levelplot(my_z ~ my_x * my_y, colorkey =   
 
 list(col=some_color_vector))

 will result in a levelplot that draws new colors in the colorkey, but
 still draws the default colors in the plotting space.

 anybody ideas how to change also the colors in the plotting space to the
 values depicted in the color key?

 thanks,
 Bram

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


Re: [R] labels outliers in boxplot

2007-01-12 Thread talepanda
because given data is a part of your data, I cannot examine,
however, try:

##out.block-identify(tb_ncs$y,tb_ncs$Slide)
out.block-identify(tb_ncs$Slide,tb_ncs$y)


On 1/11/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Dear R-users,

 Following is part of my data, where slide has 36
 levels and block 48 levels. I have done boxplot for
 each slide on the same graph. There are outliers for
 each slide and I tried to use indentify functtion to
 identify outliers in such a way that when I click on
 an outlier or point, the points will be labelled by
 either their block or ID or by both but without
 success. How can I make it work or are there other
 ways to do it than using identify function?


 Thanks in advance,

 Jenny,

 dat1[1:10,]
 y Slide Block  ID Control
 1   0.03147823 1 1   IgG-human   5
 2  -0.23815974 1 1 LPPAANDVSVLTAAR   0
 3  -0.71926359 1 1 HTKHYRVVSKPAALV   0
 4  -0.14607826 1 1 FVALPAATADAYATT   0
 5   0.89553073 1 1 NYPAMMAHAGDMAGY   0
 6  -0.67587100 1 1 RRALRQIGVLERPVG   0
 7   0.32636034 1 1 DCGTIRVGSFRGRWL   0
 8  -1.44057259 1 1 MAKLSTDELLDAFKE   0
 9  -0.37064338 1 1 LELSDFVKKFEETFE   0
 10 -0.20387233 1 1 VSRRAKVDVLIVHTT   0


  tb_ncs-subset(dat1,dat1$Control==1) ### this
 data contains only negative controls

   par(las=2,mar=c(10.1,4.1,4.1,2.1))

 boxplot(split(tb_ncs$y,tb_ncs$Slide),col=orange,
 cex=.65,
   outline=TRUE,main=Negative control
 response of each patient, cex.main=1, font.main=1,
col.main=blue,
 names=c(1:35,B))
   grid(nx=NA, ny=NULL)
  ### grid over boxplot
   legend(bottomright, B = Buffer +
 sec,text.col=blue)


out.block-
 identify(tb_ncs$y,tb_ncs$Slide)






 _
 Flyger tiden iväg? Fånga dagen med Yahoo! Mails inbyggda

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


Re: [R] labels outliers in boxplot

2007-01-12 Thread talepanda
you can get them from return value, try:

out.id-identify(tb_ncs$Slide,tb_ncs$y)
out.block-tb_ncs[out.id,]$Block

On 1/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Dear talepande,

 Thanks for your suggestion,
 I have already tried to use it, but the identify
 function gave me only  the observation number
 everytime I clicked on any point.What I want is
 instead of obervation numbers it would be block and/or
 slide numbers.

 Any other idea how I can make it works ?

 Thanks
 --- talepanda [EMAIL PROTECTED] skrev:

  because given data is a part of your data, I cannot
  examine,
  however, try:
 
  ##out.block-identify(tb_ncs$y,tb_ncs$Slide)
  out.block-identify(tb_ncs$Slide,tb_ncs$y)
 
 
  On 1/11/07, [EMAIL PROTECTED]
  [EMAIL PROTECTED] wrote:
   Dear R-users,
  
   Following is part of my data, where slide has 36
   levels and block 48 levels. I have done boxplot
  for
   each slide on the same graph. There are outliers
  for
   each slide and I tried to use indentify functtion
  to
   identify outliers in such a way that when I click
  on
   an outlier or point, the points will be labelled
  by
   either their block or ID or by both but without
   success. How can I make it work or are there other
   ways to do it than using identify function?
  
  
   Thanks in advance,
  
  
  
   dat1[1:10,]
   y Slide Block  ID Control
   1   0.03147823 1 1   IgG-human   5
   2  -0.23815974 1 1 LPPAANDVSVLTAAR   0
   3  -0.71926359 1 1 HTKHYRVVSKPAALV   0
   4  -0.14607826 1 1 FVALPAATADAYATT   0
   5   0.89553073 1 1 NYPAMMAHAGDMAGY   0
   6  -0.67587100 1 1 RRALRQIGVLERPVG   0
   7   0.32636034 1 1 DCGTIRVGSFRGRWL   0
   8  -1.44057259 1 1 MAKLSTDELLDAFKE   0
   9  -0.37064338 1 1 LELSDFVKKFEETFE   0
   10 -0.20387233 1 1 VSRRAKVDVLIVHTT   0
  
  
tb_ncs-subset(dat1,dat1$Control==1) ### this
   data contains only negative controls
  
 par(las=2,mar=c(10.1,4.1,4.1,2.1))
  
   boxplot(split(tb_ncs$y,tb_ncs$Slide),col=orange,
   cex=.65,
 outline=TRUE,main=Negative
  control
   response of each patient, cex.main=1,
  font.main=1,
  col.main=blue,
   names=c(1:35,B))
 grid(nx=NA, ny=NULL)
### grid over boxplot
 legend(bottomright, B = Buffer +
   sec,text.col=blue)
  
  
  out.block-
   identify(tb_ncs$y,tb_ncs$Slide)
  
  
  
  
  
  
  
 
 _
   Flyger tiden iväg? Fånga dagen med Yahoo! Mails
  inbyggda
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained,
  reproducible code.
  
 



   
   
   
 _
 Flyger tiden iväg? Fånga dagen med Yahoo! Mails inbyggda
 kalender. Dessutom 250 MB gratis, virusscanning och antispam. Få den på:
 http://se.mail.yahoo.com


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


Re: [R] What command does the cin in R ?

2007-01-12 Thread talepanda
try:

readLines(n=1)-str


On 1/13/07, Tong Wang [EMAIL PROTECTED] wrote:
 Hi all,
   Sorry about the simple question,  but I have searched the web with 
 prompt , input  etc.  and never got the answer .

 thanks a lot

 tong

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


Re: [R] where is the NIR dataset?

2007-01-10 Thread talepanda
NIR seems to be not dataset. It is a member of dataset yarn.
Try:

library(pls)
data(yarn)
str(yarn)

On 1/10/07, Carmen Meier [EMAIL PROTECTED] wrote:
 I did just the download of the pls package, but the NIR dataset is not
 available

  require(pls)
 [1] TRUE
  data(NIR)
 Warning message:
 data set 'NIR' not found in: data(NIR)

 is there another package with the dataset for the examples?

 With regards Carmen

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


Re: [R] where is the NIR dataset?

2007-01-10 Thread talepanda
See changelog of pls 2.0-0

- The 'NIR' and 'sensory' data sets have been renamed to 'yarn' and 'oliveoil'.

you can see it in package source from CRAN

http://cran.r-project.org/src/contrib/Descriptions/pls.html

HTH

On 1/10/07, Carmen Meier [EMAIL PROTECTED] wrote:
 talepanda schrieb:
  NIR seems to be not dataset. It is a member of dataset yarn.
  Try:
 but i seems that it was a dataset NIR:
 have a look to a former question:
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/47269.html
 /  require(pls) /
 /  data(NIR) /
 /  class(NIR) /
 / [1] data.frame /
 / /

 With regards Carmen




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


Re: [R] manipulating elements of lists

2007-01-09 Thread talepanda
Maybe I misunderstand what you want to do, one solution is:

 l1
$a
[1] 1 2

$b
[1] 1 2 3

$c
[1] 1 2 3 4

 l2
  V1 V2
1  d nd
2  c nc
3  b nb
4  a na
 names(l1)-sapply(names(l1),function(n)l2[l2$V1==n,2])
 l1
$na
[1] 1 2

$nb
[1] 1 2 3

$nc
[1] 1 2 3 4



On 1/10/07, Christoph Heibl [EMAIL PROTECTED] wrote:
 I want to manipulate lists as described below:
 Imagine these two lists:

   list1
 $WR7
 [1] 1 2 3 4

 $YH5YH6
 [1] 3 4 5 6 7

 $YH4
 [1] 4 5

 $UC4UC8
 [1] 4 5 6 7 8 9

   list2
V1 V2
 1WR7  Averrhoa
 2 ?   Sarcotheca
 3 YH5YH6  caesia
 4YH4  arbuscula
 5 UC4UC8  rosea
 6  ?  acetosella

 How can I exchange the names(list1) by the entries in the second
 column of list2,
 if (a) length(list1) ≠ length(list2) and (b) the elements of both
 lists are not in the same order? Is there a easy way to do this?

 Thank you!




 

 Christoph Heibl

 PhD student

 'Phylogenetics and phylogeography of endemic Atacama Desert flora'

 Systematic Botany
 Ludwig-Maximilians-Universität München
 Menzinger Str. 67
 D-80638 München
 GERMANY

 phone: +49-(0)89-17861-251
 e-mail:[EMAIL PROTECTED]




__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 plots via sapply or lapply?

2007-01-07 Thread talepanda
try apply() :

par(new=F);
apply(s,2,function(x){plot(x[[1]],x[[2]],type=o);par(new=T)})

On 1/8/07, Antje [EMAIL PROTECTED] wrote:
 Hi all,

 I've got the following problem. I have a vector containing file names. I
 want to read these files as csv and calculate the density-function for
 each file (has just one column with data). Then, I'd like to plot all
 density functions into one window. I did the following to calculate the
 density data:

 s - sapply(filelist, function(x) {
   if(file.exists(x))
   {
   file - read.csv(x, sep=\t, header=F)
   return( list(density(file$V1)$x, density(file$V1)$y))
   }
   })

 Now I would like to plot these x,y data in a similar way but my result
 s is a matrix containing lists...

   File1.csv   File2.csv   File3.csv
 [1,] Numeric,512  Numeric,512 Numeric,512
 [2,] Numeric,512  Numeric,512 Numeric,512

 Now I don't know how to handle the x,y values for each plot into an
 sapply (or lapply, I don't know)

 Any idea? Maybe, I should somehow change the return type?

 Antje

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


Re: [R] ifelse on data frames

2007-01-04 Thread talepanda
It can be explained.

 class(A)
[1] data.frame
 length(A)
[1] 5
 class(A==0)
[1] matrix
 length(A==0)
[1] 10
 class(-A*log(A))
[1] data.frame
 length(-A*log(A))
[1] 5

as you can see, the result of A==0 is matrix with length=10, while the
result of -A*log(A) is still data.frame with length=5.

then, when calling ifelse( [length=10], 0, [length=5] ), internally,
the NO(3rd) argument was repeated by rep(-A*log(A),length.out=10) (try
this).
the result is list with length=10 and each element has 2 sub-elements.

So, the return value of A[(A==0)==FALSE] has 2 sub-elements as you get.

I think what confusing you is the behavior of A==0.

However, when using 'ifelse', I think you should use matrix as the
arguments because data.frame is not consistent with the purpose of
'ifelse'.

On 1/5/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 [Using R 2.2.0 on Windows XP; OK, OK, I will update soon!]

 I have noticed some undesirable behaviour when applying
 ifelse to a data frame. Here is my code:

 A - scan()
  1.00 0.00 0.00  0 0.0
  0.027702 0.972045 0.000253  0 0.0

 A - matrix(A,nrow=2,ncol=5,byrow=T)
 A == 0
 ifelse(A==0,0,-A*log(A))

 A - as.data.frame(A)
 ifelse(A==0,0,-A*log(A))

 and this is the output:

  A - scan()
 1:  1.00 0.00 0.00  0 0.0
 6:  0.027702 0.972045 0.000253  0 0.0
 11:
 Read 10 items
  A - matrix(A,nrow=2,ncol=5,byrow=T)
  A == 0
   [,1]  [,2]  [,3] [,4] [,5]
 [1,] FALSE  TRUE  TRUE TRUE TRUE
 [2,] FALSE FALSE FALSE TRUE TRUE
  ifelse(A==0,0,-A*log(A))
[,1]   [,2][,3] [,4] [,5]
 [1,] 0. 0. 0.000
 [2,] 0.09934632 0.02756057 0.00209537700
 
  A - as.data.frame(A)
  ifelse(A==0,0,-A*log(A))
 [[1]]
 [1] 0. 0.09934632

 [[2]]
 [1]NaN 0.02756057

 [[3]]
 [1] 0

 [[4]]
 [1] NaN NaN

 [[5]]
 [1] 0

 [[6]]
 [1] 0. 0.09934632

 [[7]]
 [1] 0

 [[8]]
 [1] 0

 [[9]]
 [1] 0

 [[10]]
 [1] 0

 

 Is this a bug or a feature? Can the behaviour be explained?

 Regards,  Murray Jorgensen
 --
 Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
 Department of Statistics, University of Waikato, Hamilton, New Zealand
 Email: [EMAIL PROTECTED]Fax 7 838 4155
 Phone  +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 write string dynamicly?

2006-12-28 Thread talepanda
You have to create *formula* object from string and pass it to lda().

See my previous post.

On 12/29/06, Feng Qiu [EMAIL PROTECTED] wrote:
 Hi Gabor:
   Thank you!  But it didn't work. Since lda() takes the variable
 name as the input parameter. So what I was trying to do is make the name
 dynamically. I used sprintf() to generate a variable name, such as V16.
 But it seems that the function doesn't recognize the generated name. For
 example, lda(V16,data=mydata) works, But,
 lda(sprintf(V%d,k),data=mydata) does not work, where k=16.  So I guess the
 name generated by sprintf is not the parameter wanted. But I have no idea
 about it.

 Best,

 Feng


 - Original Message -
 From: Gabor Grothendieck [EMAIL PROTECTED]
 To: Feng Qiu [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Wednesday, December 27, 2006 1:56 PM
 Subject: Re: [R] How to write string dynamicly?


  Try:
 
  lda(iris[-5], iris[,5])
 
  On 12/26/06, Feng Qiu [EMAIL PROTECTED] wrote:
  Hi everyone:
  I'm trying to compose a string dynamicly for the parameter input
  of
  some function. For example:
  In package MASS, function lda() require to input the name of predictor
  variable. Let's say the 16th column is the predictor variable. Then we
  call
  the function like this: lda(V16~., data=mydata). I don't want to
  hard-code
  the call, instead, I would like to use a dynamic expression for this
  parameter so that I can use my program on different set of data.
 I guess there,- are some function that can do this, but I didn't
  find
  it in Introduction to R so far, could someone please tell me this kind
  of
  function? Thank you!
 
  Best,
 
  Feng
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 write string dynamicly?

2006-12-28 Thread talepanda
Generally, you can create formula from string:

 lda(formula(paste(names(iris)[5],~.)),iris)


On 12/29/06, Feng Qiu [EMAIL PROTECTED] wrote:
 Hi Gabor:
   Thank you!  But it didn't work. Since lda() takes the variable
 name as the input parameter. So what I was trying to do is make the name
 dynamically. I used sprintf() to generate a variable name, such as V16.
 But it seems that the function doesn't recognize the generated name. For
 example, lda(V16,data=mydata) works, But,
 lda(sprintf(V%d,k),data=mydata) does not work, where k=16.  So I guess the
 name generated by sprintf is not the parameter wanted. But I have no idea
 about it.

 Best,

 Feng


 - Original Message -
 From: Gabor Grothendieck [EMAIL PROTECTED]
 To: Feng Qiu [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Wednesday, December 27, 2006 1:56 PM
 Subject: Re: [R] How to write string dynamicly?


  Try:
 
  lda(iris[-5], iris[,5])
 
  On 12/26/06, Feng Qiu [EMAIL PROTECTED] wrote:
  Hi everyone:
  I'm trying to compose a string dynamicly for the parameter input
  of
  some function. For example:
  In package MASS, function lda() require to input the name of predictor
  variable. Let's say the 16th column is the predictor variable. Then we
  call
  the function like this: lda(V16~., data=mydata). I don't want to
  hard-code
  the call, instead, I would like to use a dynamic expression for this
  parameter so that I can use my program on different set of data.
 I guess there,- are some function that can do this, but I didn't
  find
  it in Introduction to R so far, could someone please tell me this kind
  of
  function? Thank you!
 
  Best,
 
  Feng
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 write string dynamicly?

2006-12-28 Thread talepanda
Try this:

 lda(formula(paste(names(iris)[5],~.)),iris)

You have to create *formula* object from string and pass it to lda().

On 12/29/06, Feng Qiu [EMAIL PROTECTED] wrote:
 Hi Gabor:
   Thank you!  But it didn't work. Since lda() takes the variable 
 name as the input parameter. So what I was trying to do is make the name 
 dynamically. I used sprintf() to generate a variable name, such as V16. 
 But it seems that the function doesn't recognize the generated name. For 
 example, lda(V16,data=mydata) works, But,
 lda(sprintf(V%d,k),data=mydata) does not work, where k=16.  So I guess the
 name generated by sprintf is not the parameter wanted. But I have no idea 
 about it.
 
 Best,
 
 Feng
 
 
 - Original Message - 
 From: Gabor Grothendieck [EMAIL PROTECTED]
 To: Feng Qiu [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Wednesday, December 27, 2006 1:56 PM
 Subject: Re: [R] How to write string dynamicly?
 
 
  Try:
 
  lda(iris[-5], iris[,5])
 
  On 12/26/06, Feng Qiu [EMAIL PROTECTED] wrote:
  Hi everyone:
  I'm trying to compose a string dynamicly for the parameter input 
  of
  some function. For example:
  In package MASS, function lda() require to input the name of predictor
  variable. Let's say the 16th column is the predictor variable. Then we 
  call
  the function like this: lda(V16~., data=mydata). I don't want to 
  hard-code
  the call, instead, I would like to use a dynamic expression for this
  parameter so that I can use my program on different set of data.
 I guess there,- are some function that can do this, but I didn't 
  find
  it in Introduction to R so far, could someone please tell me this kind 
  of
  function? Thank you!
 
  Best,
 
  Feng
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 write string dynamicly?

2006-12-27 Thread talepanda
Generally, you can create formula from string:

 lda(formula(paste(names(iris)[5],~.)),iris)

On 12/28/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Try:

 lda(iris[-5], iris[,5])

 On 12/26/06, Feng Qiu [EMAIL PROTECTED] wrote:
  Hi everyone:
  I'm trying to compose a string dynamicly for the parameter input
 of
  some function. For example:
  In package MASS, function lda() require to input the name of predictor
  variable. Let's say the 16th column is the predictor variable. Then we
 call
  the function like this: lda(V16~., data=mydata). I don't want to hard-code
  the call, instead, I would like to use a dynamic expression for this
  parameter so that I can use my program on different set of data.
 I guess there,- are some function that can do this, but I didn't
 find
  it in Introduction to R so far, could someone please tell me this kind
 of
  function? Thank you!
 
  Best,
 
  Feng
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dates in R

2006-12-27 Thread talepanda
Try:

as.date(Date1)-as.date(Date2)

On 12/28/06, Brian Edward [EMAIL PROTECTED] wrote:
 Hello all,

 Can somebody point me to references or provide some code on dealing with
 this date issue.  Basically, I have two vectors of values that represent
 dates.  I want to convert these values into a date format and subtract the
 differences to show elapsed time in days.  More specifically, here is the
 example:

 Date1  Date2
 032398061585
 032398061585
 111694101994
 111694101994
 062695021595
 051898111597
 072495040195
 072495040195

 The dates are in the mmddyy format, but when I attempt to format these in R
 with the function, date.mmddyy(Date1), I get very odd results.  Any help on
 this matter would be greatly appreciated!

 Thanks in advance,
 Brian

   [[alternative HTML version deleted]]

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


Re: [R] defining color sequence in image()

2006-12-26 Thread talepanda
one solution is:

img1-matrix(1:5)
img2-matrix(2:5)
col-1:5 # col-c(green,yellow,...)
image(img1,col=col[sort(unique(img1))])
image(img2,col=col[sort(unique(img2))])

On 12/26/06, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote:
 Dear All,

   How can I define a color sequence for each image value? I have several
 images with values varying from 1 to 5, and I would like to assing a fixed
 color for each value (green for 1, yellow for 2...). I used somethink like:

image(img,col=c(green,yellow,...))

   but unfortunately whem I have absent values, the color that I defined for
 each values change.

   Thanks a lot,

   Miltinho
   Brazil

   PS : Merry Christmas!!!

  __


   [[alternative HTML version deleted]]

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