Re: [R] ggplot2 / reshape / Question on manipulating data

2007-07-12 Thread hadley wickham
On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
 I'm an R newbie but recently discovered the ggplot2 and reshape
 packages which seem incredibly useful and much easier to use for a
 beginner.  Using the data from the IMDB, I'm trying to see how the
 average movie rating varies by year.  Here is what my data looks like:

  ratings - read.delim(groomed.list, header = TRUE, sep = |, 
  comment.char = )
  ratings - subset(ratings, VoteCount  100)
  head(ratings)
  Title  Histogram VoteCount VoteMean Year
 1!Huff (2004) (TV) 16   299  8.4 2004
 8  'Allo 'Allo! (1982) 000125   829  8.6 1982
 50  .hack//SIGN (2002) 001113   150  7.0 2002
 561-800-Missing (2003) 000103   118  5.4 2003
 66  Greatest Artists (2000) (mini) 00..16   110  7.8 2000
 77 00 Scariest Movie (2004) (mini) 00..000115   256  8.6 2004

Have you tried using the movies dataset included in ggplot?  Or is
there some data that you want that is not in that dataset.

 The above data is not aggregated.  So after playing around with basic
 R functionality, I stumbled across the 'aggregate' function and was
 able to see the information in the manner I desired (average movie
 rating by year).

  byYear - aggregate(ratings$VoteMean, list(Year = ratings$Year), mean)
  plot(byYear)

 Having just discovered gglot2, I wanted to create the same graph but
 augment it with a color attribute based on the total number of votes
 in a year.  So first I tried to see if I could reproduce the above:

  library(ggplot2)
  qplot(Year, x, byYear)

 This did not work as expected because the x-axis contained labels for
 each and every year making it impossible to read whereas the plot
 created with basic R had nice x-axis labels.  How do I get 'qplot' to
 treat the x-axis in a similar manner to 'plot'?

The problem is probably that Year is a factor - and factors are
labelled on every level (even if they overlap - which is a bug).
There's no terribly easy way to fix this, but the following will work:

qplot(as.numeric(as.character(Year)), x, data=byYear)

 After playing around further, I was able to get 'qplot' to work in a
 manner similar to 'plot' with regards to the x-axis labels by using
 'melt' and 'cast'.  The 'qplot' now behaves correctly:

  mratings - melt(ratings, id = c(Title, Year), measure = c(VoteCount, 
  VoteMean))
  byYear2 - cast(mratings, Year ~ variable, mean, subset = variable == 
  VoteMean)
  qplot(Year, VoteMean, data = byYear2)

 How do 'byYear' and 'byYear2' differ?  I am trying to use 'typeof' but
 both seem to be lists.  However, they are clearly different in some
 way because 'qplot' graphs them differently.

Try using str - it's much more helpful, and you should see the
different quickly.

 Finally, I'd like to use a color attribute to 'qplot' to augment each
 point with a color based on the total number of votes for the year.
 Using attributes with 'qplot' seems simple, but I'm having a hard time
 grooming my data appropriately.  I believe this requires aggregation
 by summing the VoteCount column.  Is there a way to cast the data
 using different aggregation functions for various columns?  In my

Not easily, unfortunately.  However, you could do:

cast(mratings, Year ~ variable, c(mean, sum)), subset = variable %in%
c(VoteMean, VoteCount))

which will give you a mean and sum for both.

 case, I want the mean of the VoteMean column, and the sum of the
 VoteCount column.  Then I want to produce a graph showing the average
 movie rating per year but with each point colored to reflect the total
 number of votes for that year.  Any pointers?

Using the built in movies data:

mm - melt(movies, id=1:2, m=c(rating, votes))
msum - cast(mm, year ~ variable, c(mean, sum))

qplot(year, rating_mean, data=msum, colour=votes_sum)
qplot(year, rating_mean, data=msum, colour=votes_sum, geom=line)

Hadley

__
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] ggplot doesnt work in loops?

2007-07-12 Thread Steve Powell
Dear list members
I am still a newbie so might be asking a stupid question, but I can't get
ggplot to work in a loop (or a while statement for that matter).
 
# to take a minimal example - 
mydata$varc = c(1,2,3)
for (i in 1:1){
jpeg(test3.jpg)
plot(mydata$varc)
#ggplot(mydata, aes(x=mydata$varc)) + geom_bar()
dev.off()
}

this produces an empty jpeg, whereas the content of the loop produces the
jpeg correctly.
a standard plot() does work inside the loop.
Any ideas? This is with R 2.4.0 and ggplot2
thanks in advance

Steve Powell

proMENTE social research

__
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] ggplot doesnt work in loops?

2007-07-12 Thread hadley wickham
Hi Steve,

You need to explicitly print the ggplot object:
ggplot(mydata, aes(x=mydata$varc)) + geom_bar()

(this is a R-faq for lattice plots, and ggplot works the same way)

In the latest version of ggplot (0.5.4) you can construct the plot
before hand and modify the aesthetics in each instance of the loop:

p - ggplot(mydata) + geom_bar()
mydata$varc = c(1,2,3)
for (i in 1:1){
jpeg(test3.jpg)
p + aes(x = mydata$varc)
dev.off()
}

(not that this will actually work because you're not using i inside
your loop anywhere)

(and to be strictly correct you should probably use list(x =
as.name(names(mydata)[i]))  instead of the aes call - but I haven't
written any documentation for this yet)

Hadley

On 7/12/07, Steve Powell [EMAIL PROTECTED] wrote:
 Dear list members
 I am still a newbie so might be asking a stupid question, but I can't get
 ggplot to work in a loop (or a while statement for that matter).

 # to take a minimal example -
 mydata$varc = c(1,2,3)
 for (i in 1:1){
 jpeg(test3.jpg)
 plot(mydata$varc)
 #ggplot(mydata, aes(x=mydata$varc)) + geom_bar()
 dev.off()
 }

 this produces an empty jpeg, whereas the content of the loop produces the
 jpeg correctly.
 a standard plot() does work inside the loop.
 Any ideas? This is with R 2.4.0 and ggplot2
 thanks in advance

 Steve Powell

 proMENTE social research

 __
 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] How to get weekly Covariance with R

2007-07-12 Thread Felipe Carrillo
Hi: I am trying to migrate from Systat to R but I am facing my first
 challenge. While I easily can get weekly co-variance for my data, I can't
 seem to acomplish this with R ( I can't figure out how is done) If
 interested in looking a sample of my data, please check the data
 below. In Systat from Week 28 I get a covariance of 1055 fish.
  Thanks in advance
   
Fish Passage  Week number Weekly Covariance0  26
 00  27 00  27  0  27  0  27  0  27 
 0  27  0  27  0  28 10550  28  71  28  
132  28  223  28  224  28  218  28  228  29 
 224  29  488  29  525  29  80  29  417  29 
 82  29  413  30  373  30  914  30  213 
 30  651  30  521  30  979  30  177  31 
 604  31  824  31  1190  31  926  31  1257  31  
1071  31  1709  32  1166  32  704  32  
1424  32  2586  32  1163  32  647  32  



 Felipe D. Carrillo
  Fishery Biologist
  US Fish  Wildlife Service
  Red Bluff, California 96080

   
-


[[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] how to get the p-values from an lm function ?

2007-07-12 Thread Benoit Chemineau
Hi, dear R-users,

I am computing a liner regression by rating category using the 'by' function
as stated below:

tmp - by(projet, rating, function(x) lm(defaults ~ CGDP+CSAVE+SP500, data =
x))

I would like to get not only the coefficients but also their p-values. I
can't find the command in the help pages to get them.

Does anyone have a suggestion ?

Thank you,

Benoit.

[[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 get the p-values from an lm function ?

2007-07-12 Thread hadley wickham
On 7/12/07, Benoit Chemineau [EMAIL PROTECTED] wrote:
 Hi, dear R-users,

 I am computing a liner regression by rating category using the 'by' function
 as stated below:

 tmp - by(projet, rating, function(x) lm(defaults ~ CGDP+CSAVE+SP500, data =
 x))

 I would like to get not only the coefficients but also their p-values. I
 can't find the command in the help pages to get them.

 Does anyone have a suggestion ?

Hi Benoit,

A general approach to find p-values:

m - lm(wt ~ mpg, data=mtcars)

First figure out how to display them on screen:
m # nope
coef(m) # nope
summary(m) # got it

# Then use str to look at the components
str(summary(m))

# And pick out the one want
summary(m)$coef
coef(summary(m)) # slighty better style, but won't work in general

# In general, you may also need to try
str(print(summary(m)))
# as sometimes the print method calculates the data you're looking for

Hadley

__
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] aov() question

2007-07-12 Thread Christophe Pallier
On 7/11/07, Leigh E Alexander [EMAIL PROTECTED] wrote:

 i have a 3 x 4 x 2 repeated measures design.  All of the IVs are within
 subjects.I do also have missing values (unequal N), as I have to
 remove any incorrect trials for each subject.


Hum, you mean there are empty cells in table(sid, tran, block, half)?
That is probably the reason for the error message. It is not clear to me
that 'aov' can handle empty cells in such a design (maybe 'lmer' can)

Christophe








Here is the code I entered and the error message:

 a-aov(log(rt)~(tran*block*half) + Error (sid/ (tran*block*half)),
 data=mydata2)

 Warning message:
 Error() model is singular in: aov(log(rt) ~ (tran * block * half) +
 Error(sid/(tran * block *

 I then do summary(a) and am able to get an output, but I am not sure
 whether or not I can trust that output since I got the error message.
 Any body have any thoughts/solutions for this?

 Also, are there any benefits of you aov() vs. use some of the linear
 model functions or vice versa?

 Thanks for any help you can offer!!

 ~Leigh Alexander

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




-- 
Christophe Pallier (http://www.pallier.org)

[[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 get the p-values from an lm function ?

2007-07-12 Thread Dimitris Rizopoulos
try the following:

tmp - by(projet, rating, function (x) Thursday, 12.July.2007{
fit - lm(defaults ~ CGDP + CSAVE + SP500, data = x)
summary(fit)$coefficients
})


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Benoit Chemineau [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, July 12, 2007 10:51 AM
Subject: [R] how to get the p-values from an lm function ?


 Hi, dear R-users,

 I am computing a liner regression by rating category using the 'by' 
 function
 as stated below:

 tmp - by(projet, rating, function(x) lm(defaults ~ 
 CGDP+CSAVE+SP500, data =
 x))

 I would like to get not only the coefficients but also their 
 p-values. I
 can't find the command in the help pages to get them.

 Does anyone have a suggestion ?

 Thank you,

 Benoit.

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


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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] problems with memory in Mac

2007-07-12 Thread Carlos Guerra
Dear friends,

I am having some doubts about the amount of memory that is being used by 
R in my Mac (MacBook Pro, 2Gig). Is there a way to increase the amount 
of memory used?

When I type:

  mem.limits()

the result is:

nsize vsize
   NANA

and I can't change it, tough my computing in R isn't using all the 
memory at it's disposal.

Best regards,
Carlos

-- 
Carlos GUERRA

Gabinete de Sistemas de Informacao Geografica
Escola Superior Agraria de Ponte de Lima
Mosteiro de Refoios do Lima
4990-706 Ponte de Lima

Tlm: +351 91 2407109
Tlf: +351 258 909779

Reclaim your Inbox...!!!
http://www.mozilla.org/products/thunderbird/

__
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] type III ANOVA for a nested linear model

2007-07-12 Thread S Ellison
The aliasing problem arises in alias(), which is what Anova uses to detect 
aliasing. It is simply the fact that anova more or less blithely ignores the 
NA's that makes anova behave apparently more 'sensibly' than Anova.

But like Carsten, I found this difficult to understand. Unordered factors are 
supposed to be arbitrary. I can understand why A:C behaves differently from A:D 
(where D-factor(rep(1:3,6)). A:C generates a 27-level factor with only 18 
levels populated; A:D has only nine levels. But it is not so simple.

I was goig to suggest using AC-factor(A:C) instead of A %in% C as a fix, as 
this generates a 9-level factor with all levels populated - just as A:D does. 
But 
 alias(lm(resp~A+AC))
generates an alias, where 
 alias(lm(resp~A+A:D))
does not. 

That seemed to me entirely bizarre. table(A,AC) and table(A,A:D) show identical 
balance and nesting. Something, somewhere, is expanding the two differently. 
But what?

model.matrix is the 'culprit', I think. The two model matrices differ; 
model.matrix(resp~A+A:D) has 9 columns, and model.matrix(resp~A+AC) has eleven.

So now I know what has happened. What I don't understand is why, except that 
'that is what model.matrix does with this factor level numbering' (refactoring 
either AC or A:D via as.numeric finally generates identical - and aliased - 
behaviour)) . I think I am going to invoke the law of unintended consequences 
and go find a cold compress.

Steve E

 Peter Dalgaard [EMAIL PROTECTED] 11/07/2007 16:03:13 
A term C %in% A  (or A/C) is not a _specification_ that C is nested in
A, it is a _directive_ to include the terms A and C:A. Now, C:A involves
a term for each combination of A and C, of which many are empty if C is
strictly coarser than A. This may well be what is confusing Anova().

In fact, with this (c(1:3,6:11)) coding of C, A:C is completely
equivalent to C, but if you look at summary(lm()) you will see a lot
of NA coefficients in the A:C case. If you use resp ~ A*B+C, then you
still get a couple of missing coefficients in the C terms because of
collinearity with the A terms. (Notice that this is one case where the
order inside the model formula will matter; C+A*B is not the same.)


***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
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] Subsetting problem

2007-07-12 Thread Mark Difford

Hi Massimo,

Professor Ripley has given you your answer.

It may help you further to know that factor levels aren't automatically
dropped when you subset a data set; you have to do it manually.  Some time
ago I scrounged the following command from Andy Liaw's randomForest package:
it removes all empty factor levels in a subsetted data set.

I subset a great deal, and find it extremely useful.

MyDat[] - lapply(MyDat, function(x) if (is.factor(x)) x[, drop=T] else x)   
## Liaw's code for doing this

Regards,
Mark.

On Thu, 12 Jul 2007, Cressoni, Massimo (NIH/NHLBI) [F] wrote:

 I need to perform the Exact Wilcoxon Mann-Whitney on a subset of my
 database.
 Assuming that IPPO is my data frame and IPPOBIS is the subset my variable
 still
 have 3 different levels and the function wilcox_test (package coin)
 does not accept it.
 I do not know how to overcome this problem.

 ippo - c(rep(A,10),rep(B,10),rep(C,10))
 ippo2 - c(rnorm(10,0,1),rnorm(10,10,10),rnorm(10,10,10))
 IPPO - data.frame(ippo,ippo2)

 IPPOBIS - IPPO[IPPO$ippo == A | IPPO$ippo == B,]

 wilcox_test(ippo2 ~ ippo,data=IPPOBIS,distribution=exact())
 Error in check(itp) : 'object' does not represent a two sample problem
 levels(IPPOBIS$ippo)
 [1] A B C

 Massimo Cressoni

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



-- 
View this message in context: 
http://www.nabble.com/Subsetting-problem-tf4066094.html#a11557188
Sent from the R help mailing list archive at Nabble.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] how to get the p-values from an lm function ?

2007-07-12 Thread Prof Brian Ripley
On Thu, 12 Jul 2007, hadley wickham wrote:

 On 7/12/07, Benoit Chemineau [EMAIL PROTECTED] wrote:
 Hi, dear R-users,

 I am computing a liner regression by rating category using the 'by' function
 as stated below:

 tmp - by(projet, rating, function(x) lm(defaults ~ CGDP+CSAVE+SP500, data =
 x))

 I would like to get not only the coefficients but also their p-values. I
 can't find the command in the help pages to get them.

 Does anyone have a suggestion ?

 Hi Benoit,

 A general approach to find p-values:

 m - lm(wt ~ mpg, data=mtcars)

 First figure out how to display them on screen:
 m # nope
 coef(m) # nope
 summary(m) # got it

 # Then use str to look at the components
 str(summary(m))

 # And pick out the one want
 summary(m)$coef
 coef(summary(m)) # slighty better style, but won't work in general

If x$coef works, coef(x) will almost certainly work at least as well. 
But note that in most cases it is x$coefficients and so x$coef is liable 
to partially match erroneously.

 # In general, you may also need to try
 str(print(summary(m)))
 # as sometimes the print method calculates the data you're looking for

But a print method should always return its input, so

str(summary(m))
str(print(summary(m)))

should be the same.

Reading the help pages would be a very good idea, as they usually not only 
tell you the names of the components of the result but also what they 
mean.

-- 
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] problems with memory in Mac

2007-07-12 Thread Rod
2007/7/12, Carlos Guerra [EMAIL PROTECTED]:
 Dear friends,

 I am having some doubts about the amount of memory that is being used by
 R in my Mac (MacBook Pro, 2Gig). Is there a way to increase the amount
 of memory used?

 When I type:

   mem.limits()

 the result is:

 nsize vsize
NANA

 and I can't change it, tough my computing in R isn't using all the
 memory at it's disposal.

 Best regards,
 Carlos

 --
 Carlos GUERRA

 Gabinete de Sistemas de Informacao Geografica
 Escola Superior Agraria de Ponte de Lima
 Mosteiro de Refoios do Lima
 4990-706 Ponte de Lima

 Tlm: +351 91 2407109
 Tlf: +351 258 909779

 Reclaim your Inbox...!!!
 http://www.mozilla.org/products/thunderbird/

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


read the help ?memory.limit

- Rod.

__
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 p-values from an lm function ?

2007-07-12 Thread hadley wickham
On 7/12/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Thu, 12 Jul 2007, hadley wickham wrote:

  On 7/12/07, Benoit Chemineau [EMAIL PROTECTED] wrote:
  Hi, dear R-users,
 
  I am computing a liner regression by rating category using the 'by' 
  function
  as stated below:
 
  tmp - by(projet, rating, function(x) lm(defaults ~ CGDP+CSAVE+SP500, data 
  =
  x))
 
  I would like to get not only the coefficients but also their p-values. I
  can't find the command in the help pages to get them.
 
  Does anyone have a suggestion ?
 
  Hi Benoit,
 
  A general approach to find p-values:
 
  m - lm(wt ~ mpg, data=mtcars)
 
  First figure out how to display them on screen:
  m # nope
  coef(m) # nope
  summary(m) # got it
 
  # Then use str to look at the components
  str(summary(m))
 
  # And pick out the one want
  summary(m)$coef
  coef(summary(m)) # slighty better style, but won't work in general

 If x$coef works, coef(x) will almost certainly work at least as well.
 But note that in most cases it is x$coefficients and so x$coef is liable
 to partially match erroneously.

I meant in general that x$y, does not correspond to y(x) - I realised
after I wrote it that I was unclear.

  # In general, you may also need to try
  str(print(summary(m)))
  # as sometimes the print method calculates the data you're looking for

 But a print method should always return its input, so

 str(summary(m))
 str(print(summary(m)))

Oh yes, I was getting confused with print functions which compute
values and print them but do not return them.

And that comment has made me realise many of my print methods don't
return x.   - something to fix.
Hadley

__
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] dose-response on a grid

2007-07-12 Thread William Simpson
I have the following problem. I have measured a dose response curve
(binary response, continuous dose) on a grid of x,y positions. I would
like to produce a grey-level plot that shows the LD50 at each (x,y)
position.

I am thinking that I have to do something like
fit-glm(resp ~ x*y + dose, family = binomial)
Corrections welcome.

But from here I don't know how to get LD50, and certainly not at each
x,y, position.

Thanks very much for any help.

Bill

__
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] RWeka control parameters classifiers interface

2007-07-12 Thread strinz
Hi,

  many thanks for the answer.
  It ist true, that for example

  m1 - SMO(Species ~ ., data = iris, control = Weka_control( K = 
weka.classifiers.functions.supportVector.PolyKernel))
  m2 - SMO(Species ~ ., data = iris, control = Weka_control( K = 
weka.classifiers.functions.supportVector.RBFKernel))
  deliver different results
  
  but
  m3 - SMO(Species ~ ., data = iris, control = Weka_control( K = 
weka.classifiers.functions.supportVector.PolyKernel,E=2))
  m4 - SMO(Species ~ ., data = iris, control = Weka_control( K = 
weka.classifiers.functions.supportVector.RBFKernel),G=0.2)

  m3 does not differ from m1 (from the point of view of the setup, irrespective 
of the data!)
  m4 does not differ from m2 (from the point of view of the setup, irrespective 
of the data!)

  which can be seen, when looking at the results:
  m1 # (Linear Kernel, okay )
  m2 # (RBF Kernel, okay)
  m3  # still uses a linear kernel, but should be a x,y^2 kernel
  m4 # G is ignored, resulting in m2


Thx
Bjoern




- original Nachricht 

Betreff: Re: [R] RWeka control parameters classifiers interface
Gesendet: Mi 11 Jul 2007 14:42:10 CEST
Von: Achim Zeileis[EMAIL PROTECTED]

 On Wed, 11 Jul 2007 [EMAIL PROTECTED] wrote:
 
The problem is, that the functions
result=classifier(formula, data, subset, na.action, control =
 Weka_control(mycontrol))
do not seem to be manipulated by the mycontrol- arguments
 
 Yes, they are...not all parameter changes have always an effect on the
 specified learner.
 
Perhaps this should be resepected via the handlers- argument ,
but the documentation in this regard is rather sparse.
 
 Handlers are not needed here.
 
 Re: sparse docs. In case you have not seen that paper already, there is a
 technical report on the ideas behind RWeka:
  
 http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_b
 a6
 
 Re: SMO. Compare
 
 m1 - SMO(Species ~ ., data = iris)
 m2 - SMO(Species ~ ., data = iris, control = Weka_control(
   K = weka.classifiers.functions.supportVector.RBFKernel))
 
 which yield different results so the Weka_control() works.
 
 The same happens if you register the mySMO() interface yourself. I'm not
 sure why the E = ... argument has no influence on the SMO, please check
 the Weka docs for this particular learner.
 
 Best,
 Z
 
 
 

--- original Nachricht Ende 

__
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] time-varying recursive filter - vectorized

2007-07-12 Thread Felix Andrews
A question about vectorized operations (avoiding loops, for speed)...

I need to run a simple recursive (autoregressive) filter with a
time-varying coefficient. It is just a one-step recursive filter, so
it would be an exponential decay if the filter was constant.

I just want to do this, where 'x' is the data and 'w' is the weight to
apply to the previous time step:

x - c(1, 1, 0, 2, 0, 0)
w - c(NA, 0.1, 0.5, 0.4, 0.3, 0.2)
y - x
for (i in seq_along(x)[-1]) y[i] - y[i] + w[i] * y[i-1]
print(y)
[1] 1. 1.1000 0.5500 2.2200 0.6660 0.1332

But, since loops are slow, I would like a vectorized method, like
filter(, method=recursive).

Any ideas?

-- 
Felix Andrews / 安福立
PhD candidate, The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
voice:+86_1051404394 (in China)
mobile:+86_13522529265 (in China)
mobile:+61_410400963 (in Australia)
xmpp:[EMAIL PROTECTED]
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8

__
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] matrix of scatterplots

2007-07-12 Thread livia

Hi, I would like to use the function pairs() to plot a matrix of
scatterplots. For each scatterplot, the data are plotted in circles, can I
add some argument to change the circles into dots?

Could anyone give me some advice?Many thanks
-- 
View this message in context: 
http://www.nabble.com/matrix-of-scatterplots-tf4067527.html#a11558049
Sent from the R help mailing list archive at Nabble.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] How to activate the R commands in SciViews

2007-07-12 Thread Liviu Andronic
Hello everybody,

I have a problem similar to that reported by Felipe. I installed R
2.5.0, Rcmdr from CRAN and SciViews-R 0.8-9 (with all the required and
optional components).

When accessing the R Commander menu from within
SciViews, the links cannot be clicked. When pointing at them, the mouse
transforms in a hand (as it normally does, similar to Internet
hyperlinks). However, the links cannot be activated. I had the
impression that in some way SciViews makes use of Internet Explorer in
its GUI, and that the problem was somewhere there. But I could not get
to the bottom of it.

Is there any way to make SciViews correctly use Rcmdr functionality?

Thanks in advance,
Liviu


On 6/20/07, Felipe Carrillo [EMAIL PROTECTED] wrote:
 Please help, I have SciViews(svGUI) and Rcmdr but when the SciViews Console 
 opens the R commander menu don't work. Any ideas anybody?



-- 
Liviu

__
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] Please Help

2007-07-12 Thread Tanya Li
Hello,

I got this email address from
http://tolstoy.newcastle.edu.au/R/e2/help/06/10/2516.html, I got started to
use R recently, Can I ask you a question ?

this is what I am using:
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  4.0
year   2006
month  10
day03
svn rev39566
language   R
version.string R version 2.4.0 (2006-10-03)

I wanna to call R in shell( bash ) , write all R commands in the shell
script and make it a cron job to execute automatically.

do you know how to do this ?

Looking forward to hearing from you, thanks a million.

Tanya Li
-- 
Regards

Xiaohui Li

[[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] matrix of scatterplots

2007-07-12 Thread Adaikalavan Ramasamy
m - matrix( rnorm(300), nc=3 )
pairs(m, pch=20)

or pairs(m, pch=.)

See help(par) for more details.


livia wrote:
 Hi, I would like to use the function pairs() to plot a matrix of
 scatterplots. For each scatterplot, the data are plotted in circles, can I
 add some argument to change the circles into dots?
 
 Could anyone give me some advice?Many thanks

__
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 activate the R commands in SciViews

2007-07-12 Thread Philippe Grosjean
As explained on the web page from where you downloaded SciViews 0.8-9, 
this version is not compatible with R 2.5.0.
Best,

Philippe Grosjean
..∞}))
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

Liviu Andronic wrote:
 Hello everybody,
 
 I have a problem similar to that reported by Felipe. I installed R
 2.5.0, Rcmdr from CRAN and SciViews-R 0.8-9 (with all the required and
 optional components).
 
 When accessing the R Commander menu from within
 SciViews, the links cannot be clicked. When pointing at them, the mouse
 transforms in a hand (as it normally does, similar to Internet
 hyperlinks). However, the links cannot be activated. I had the
 impression that in some way SciViews makes use of Internet Explorer in
 its GUI, and that the problem was somewhere there. But I could not get
 to the bottom of it.
 
 Is there any way to make SciViews correctly use Rcmdr functionality?
 
 Thanks in advance,
 Liviu
 
 
 On 6/20/07, Felipe Carrillo [EMAIL PROTECTED] wrote:
 Please help, I have SciViews(svGUI) and Rcmdr but when the SciViews Console 
 opens the R commander menu don't work. Any ideas anybody?

 


__
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] lead

2007-07-12 Thread Aydemir, Zava \(FID\)
Hi,
 
is there any function in R that shifts elements of a vector to the
opposite direction of what Lag()  of the Hmisc package does? (something
like, Lag(x, shift = -1) )
 
Thanks
 
Zava


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

__
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] elementary statistics with R (rkward?)

2007-07-12 Thread John Kane

--- Donatas G. [EMAIL PROTECTED] wrote:

 Hi, I am trying to learn some basic statistics stuff
 but I cannot find any
 elementary statistics exercises using R language.
 Using RKward would be even
 better...
 
 I need that in analysing sociological data, obtained
 through questionnairres -
 findind corelations between variables, relations
 between different types of
 data, etc.
 
 Could anyone recommend simple tutorials/exercises,
 available on www for me to
 work on?
 
 I realize it would be much simple to do this
 introductory stuff with spss, that
 everyone around me is using here in Lithuania, but
 I'd really like to learn to
 do it with R instead...
 
 -- 
 Donatas G.

http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html  is
not a bad place to start.   John Verzani's notes on
Simple R
http://www.math.csi.cuny.edu/Statistics/R/simpleR/ may
also help but his book is better.  

Peter Dalgarrd's book Introductory Statistics with R
is also very good.

__
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] dose-response on a grid

2007-07-12 Thread Christian Ritz
Hi Bill,

have a look at the following artificial example:

## Loading the package 'drc' (on CRAN)
library(drc)

## Generating dataset with four dose-response curves
finneyx4 - rbind(finney71, finney71, finney71, finney71)

## Generating artificial points (x,y)
## different pairs for each of the 4 curves in the above dataset
finneyx4$x - rep(1, 24)
finneyx4$y - rep(1:4, c(6, 6, 6, 6))

## Fitting the two-parameter log-logistic model (logistic regression)
m1 - drm(affected/total ~ dose, as.factor(x):as.factor(y), weights = total,
data = finneyx4, fct = LL.2(), type = binomial)

## Calculating ED50/LD50 for each location (they are all the same for this 
dataset)
ED(m1, 50)


You could try the same approach for your data!


Christian

__
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] Please Help

2007-07-12 Thread Adaikalavan Ramasamy
This is the R-help mailing list. See help(BATCH).

You will need to write the required R commands in a separate script, say 
script.R and then execute it as

  R --no-save  script.R  logfile

You may need to augment the code above to include directory paths etc. 
There are other useful documentations at http://www.r-project.org/

Regards, Adai





Tanya Li wrote:
 Hello,
 
 I got this email address from
 http://tolstoy.newcastle.edu.au/R/e2/help/06/10/2516.html, I got started to
 use R recently, Can I ask you a question ?
 
 this is what I am using:
 platform   i686-pc-linux-gnu
 arch   i686
 os linux-gnu
 system i686, linux-gnu
 status
 major  2
 minor  4.0
 year   2006
 month  10
 day03
 svn rev39566
 language   R
 version.string R version 2.4.0 (2006-10-03)
 
 I wanna to call R in shell( bash ) , write all R commands in the shell
 script and make it a cron job to execute automatically.
 
 do you know how to do this ?
 
 Looking forward to hearing from you, thanks a million.
 
 Tanya Li

__
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] [Fwd: Re: How to activate the R commands in SciViews]

2007-07-12 Thread Philippe Grosjean
Well.. plans are there from a long time to rewrite SciViews completely
and make it platform independent (to work on Linux/Unix and MacOS X, as
well as Windows). I have done some work in this direction when time
permitted, but I am pretty busy with other work. During the holidays, I
will continue to work in this direction. I will try to package a first
running version of SciViews compatible with latest R and Rcmdr for
Windows and Linux for next September. At least, I *have* to do so,
because I *need* it for one of my teachings which will be done in a
different University (where all machines are running with Linux)!

So, my advice would be to check the web site again in September/October
for some news. Unfortunately, I cannot promise more. Sorry for the long
delays. I do my best, and the second programmer (Eric Lecoutre) has left
the project a long time ago... so, I am alone on this!

Best,

Philippe Grosjean

..∞}))
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

Liviu Andronic wrote:
 Thank you for the pointer.
 
 On the SciViews official site
 (http://www.sciviews.org/SciViews-R/index.html) I could not find any
 indications on this incompatibility. At any rate, I would have two
 questions related to the future of SciViews-R.
 
 Are there any developments planned in some near future that would make
 SciViews compatible with recent versions of R and Rcmdr? At the
 Unviversity of Social Sciences of Toulouse, for example, the most
 recent version of R is installed. And for statistics introductory
 classes, SciViews would be an important advantage. R should be
 downgraded to which version for the two to be compatible?
 
 Secondly, is there any chance that SciViews become available on Linux,
 again in some not so distant future? That is, would the tcltk2 package
 be ported to other OS's and would SciViews be subsequently enhanced to
 build on such systems? Last time I checked the net, no interesting
 information was available as to such developments. Maybe there is some
 beta version of tcltk2 that I don't know of..
 
 Regards,
 Liviu
 
 On 7/12/07, Philippe Grosjean [EMAIL PROTECTED] wrote:
 As explained on the web page from where you downloaded SciViews 0.8-9,
 this version is not compatible with R 2.5.0.
 Best,

 Philippe Grosjean
 ..∞}))
   ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
   ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
   ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..

 Liviu Andronic wrote:
  Hello everybody,
 
  I have a problem similar to that reported by Felipe. I installed R
  2.5.0, Rcmdr from CRAN and SciViews-R 0.8-9 (with all the required and
  optional components).
 
  When accessing the R Commander menu from within
  SciViews, the links cannot be clicked. When pointing at them, the mouse
  transforms in a hand (as it normally does, similar to Internet
  hyperlinks). However, the links cannot be activated. I had the
  impression that in some way SciViews makes use of Internet Explorer in
  its GUI, and that the problem was somewhere there. But I could not get
  to the bottom of it.
 
  Is there any way to make SciViews correctly use Rcmdr functionality?
 
  Thanks in advance,
  Liviu
 
 
  On 6/20/07, Felipe Carrillo [EMAIL PROTECTED] wrote:
  Please help, I have SciViews(svGUI) and Rcmdr but when the SciViews 
 Console opens the R commander menu don't work. Any ideas anybody?
 
 
 

 
 


-- 
..∞}))
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

__
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] matrix of scatterplots

2007-07-12 Thread livia

Thank you very much for your help.

Adaikalavan Ramasamy wrote:
 
 m - matrix( rnorm(300), nc=3 )
 pairs(m, pch=20)
 
 or pairs(m, pch=.)
 
 See help(par) for more details.
 
 
 livia wrote:
 Hi, I would like to use the function pairs() to plot a matrix of
 scatterplots. For each scatterplot, the data are plotted in circles, can
 I
 add some argument to change the circles into dots?
 
 Could anyone give me some advice?Many thanks
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/matrix-of-scatterplots-tf4067527.html#a11558687
Sent from the R help mailing list archive at Nabble.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] How to activate the R commands in SciViews

2007-07-12 Thread Liviu Andronic
Thank you for the pointer.

On the SciViews official site
(http://www.sciviews.org/SciViews-R/index.html) I could not find any
indications on this incompatibility. At any rate, I would have two
questions related to the future of SciViews-R.

Are there any developments planned in some near future that would make
SciViews compatible with recent versions of R and Rcmdr? At the
Unviversity of Social Sciences of Toulouse, for example, the most
recent version of R is installed. And for statistics introductory
classes, SciViews would be an important advantage. R should be
downgraded to which version for the two to be compatible?

Secondly, is there any chance that SciViews become available on Linux,
again in some not so distant future? That is, would the tcltk2 package
be ported to other OS's and would SciViews be subsequently enhanced to
build on such systems? Last time I checked the net, no interesting
information was available as to such developments. Maybe there is some
beta version of tcltk2 that I don't know of..

Regards,
Liviu

On 7/12/07, Philippe Grosjean [EMAIL PROTECTED] wrote:
 As explained on the web page from where you downloaded SciViews 0.8-9,
 this version is not compatible with R 2.5.0.
 Best,

 Philippe Grosjean
 ..∞}))
   ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
   ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
   ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..

__
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] eMail results out of R

2007-07-12 Thread thomas.schwander
Hi everyone,

I did my homework and read the posting guideline :-)

I want to eMail the results of a computing automatically. So I get the results 
(the parameters of a garch process) and I want to eMail them to another person. 
How can I do that?

Thx

__

Thomas Schwander

MVV Energie
Konzern-Risikocontrolling

Telefon 0621 - 290-3115
Telefax 0621 - 290-3664

E-Mail: [EMAIL PROTECTED] .  Internet: www.mvv.de
MVV Energie AG . Augustaanlage 67 . 68159 Mannheim
Handelsregister-Nr. HRB 1780, Amtsgericht Mannheim
Vorsitzender des Aufsichtsrates: Oberbürgermeister Gerhard  Widder
Vorstand: Dr. Rudolf Schulten (Vorsitzender) . Dr. Werner Dub . Hans-Jürgen 
Farrenkopf 




[[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] lead

2007-07-12 Thread Adaikalavan Ramasamy
How about

  revLag - function(x, shift=1) rev( Lag(rev(x), shift) )

  x - 1:5
  revLag(x, shift=2)


As a matter of fact, here is a generalized version of Lag to include 
negative shifts.

myLag - function (x, shift = 1){

 xLen - length(x)
 ret - as.vector(character(xLen), mode = storage.mode(x))
 attrib - attributes(x)
 if (!is.null(attrib$label))
 atr$label - paste(attrib$label, lagged, shift, observations)

 if (shift == 0) return(x)

 if( xLen = abs(shift) ) return(ret)

 if (shift  0) x - rev(x)
 retrange = 1:abs(shift)
 ret[-retrange] - x[1:(xLen - abs(shift))]
 if (shift  0) ret - rev(ret)

 attributes(ret) - attrib
 return(ret)
}

and some test examples:

myLag(1:5, shift=2)
  [1] NA NA  1  2  3

myLag(letters[1:4], shift=2)
[1] a b

myLag(factor(letters[1:4]), shift=2)
  [1] NA NA ab
  Levels: a b c d

myLag(1:5, shift=-2)
  [1]  3  4  5 NA NA

myLag(letters[1:4], shift=-2)
  [1] c d   

myLag(factor(letters[1:4]), shift=-2)
  [1] cdNA NA
  Levels: a b c d

Regards, Adai




Aydemir, Zava (FID) wrote:
 Hi,
  
 is there any function in R that shifts elements of a vector to the
 opposite direction of what Lag()  of the Hmisc package does? (something
 like, Lag(x, shift = -1) )
  
 Thanks
  
 Zava
 
 
 This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
 
 __
 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] XAML

2007-07-12 Thread gordon . morrison
Hi

I wonder if anyone has had any thoughts about rendering R graphical output
into XAML?



Gordon M. Morrison
HSBC Bank plc
8 Canada Square
London
E14 5HQ

-
SAVE PAPER - THINK BEFORE YOU PRINT!

This transmission has been issued by a member of the HSBC Group
HSBC for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.

__
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] type III ANOVA for a nested linear model

2007-07-12 Thread Mendiburu, Felipe \(CIP\)
Dear Carsten

In this test, factor B would be representing to a factor of block or repetition 
according to as the levels of A, B, and C are in the data. Factor C this nested 
in A, then the model should include: B, A and C nested in A, the difference it 
is the error.

Model:
B   1
A   2
C(A)6
Error   (2+6)*1 = 8
Total

mydata-read.table(mydata.txt,header=T)
mydata[,1]- as.factor(mydata[,1])
mydata[,2]- as.factor(mydata[,2])
mydata[,3]- as.factor(mydata[,3])
model - aov(resp ~ B + A + C/A, mydata)
summary(model)
Df Sum Sq Mean Sq F valuePr(F)
B1 915.21  915.21 89.6476 1.274e-05 ***
A2  33.12   16.56  1.6223   0.25621
C6 199.50   33.25  3.2570   0.06316 .  
Residuals8  81.67   10.21

Best regards,

Felipe de Mendiburu
Statistician



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Carsten Jaeger
Sent: Tuesday, July 10, 2007 6:15 AM
To: R help list
Subject: [R] type III ANOVA for a nested linear model


Hello,

is it possible to obtain type III sums of squares for a nested model as
in the following:

lmod - lm(resp ~ A * B + (C %in% A), mydata))

I have tried

library(car)
Anova(lmod, type=III)

but this gives me an error (and I also understand from the documentation
of Anova as well as from a previous request
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64477.html) that it is
not possible to specify nested models with car's Anova).

anova(lmod) works, of course.

My data (given below) is balanced so I expect the results to be similar
for both type I and type III sums of squares. But are they *exactly* the
same? The editor of the journal which I'm sending my manuscript to
requests what he calls conventional type III tests and I'm not sure if
can convince him to accept my type I analysis.

R mydata
  A B C  resp
1 1 1  1 34.12
2 1 1  2 32.45
3 1 1  3 44.55
4 1 2  1 20.88
5 1 2  2 22.32
6 1 2  3 27.71
7 2 1  6 38.20
8 2 1  7 31.62
9 2 1  8 38.71
102 2  6 18.93
112 2  7 20.57
122 2  8 31.55
133 1  9 40.81
143 1 10 42.23
153 1 11 41.26
163 2  9 28.41
173 2 10 24.07
183 2 11 21.16

Thanks a lot,

Carsten

__
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] p-value from survreg

2007-07-12 Thread Terry Therneau
The question was how to get the p-value from the fit below, as an S object
 
sr-survreg(s~groups, dist=gaussian)
Coefficients:
(Intercept)  groups
-0.02138485  0.03868351

Scale= 0.01789372

Loglik(model)= 31.1   Loglik(intercept only)= 25.4
Chisq= 11.39 on 1 degrees of freedom, p= 0.00074
n= 16
 


  In general, good places to start are 
 names(sr)
 help(survreg.object)  
 ssr - summary(sr)
 names(ssr)
As someone else pointed out, it's also easy to look at the print.survreg
function and see how the value was created -- one of the things I love
about S.

Unfortunately, doing the above myself showed that I have let the documentation
page for survreg.object get seriously out of date -- quite embarassing as
that is logically the first place to start.

As to the print function creating things on the fly: there is an area where
there is no good answer.  Does one make the return object from a fit such
that it contains only minimal data, or add in all of the other computations
that can be derived from these?  The Chambers and Hastie book Statistical
Models in S, which was the starting point for model objects, leaned towards
the former, and this still influences many functions.  Often the summary
function will fill in these derived values, the std and t-tests for
the individual coefficients for instance.

Terry T.

__
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] Fitting a Gamma Curve

2007-07-12 Thread TIMMMAY

Hi there, I hope someone can help me before I tear all my hair out. I have a
set transition intensities and when plotted the curve looks like a gamma
density. I want to fit a gamma density curve to these intensities. It is
just a curve fitting problem but whats causing the trouble is that I need to
use least squares minimization to calculate the parameters for the gamma
curve. How do I do this??? 

The curve will be a truncated gamma function so it will have 3 paramaters a,
b, c. I tried to do the following 

nls(lograte ~ log(c) + a*log(b) + (a-1)*log(age)+b*(age)-lgamma(a),
start=list(a=1,b=1,c=1)), where lograte, and age are my data. a,b the gamma
parameters and c the parameter we need because we are fitting a truncated
distribution.

I also tried defining 
fn = function(p) sum((log(y)-log(dgamma(x,p[1],p[2])*p[3]))^2)
a residual sum of squares and using nlm to minimise this and find paramaters
but this doesnt work either. Can anyone help me ?? Please :)

-- 
View this message in context: 
http://www.nabble.com/Fitting-a-Gamma-Curve-tf4068543.html#a11561404
Sent from the R help mailing list archive at Nabble.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] lead

2007-07-12 Thread Gabor Grothendieck
The lag.zoo method of lag in the zoo package supports positive, negative
and multiple lags and has an na.pad= argument.  (zoo also has a
lag.zooreg method, not shown, for zooreg objects):

 library(zoo)
 z - zoo(11:15)
 z
 1  2  3  4  5
11 12 13 14 15
 lag(z, na.pad = TRUE)
 1  2  3  4  5
12 13 14 15 NA
 lag(z, 1, na.pad = TRUE) # same
 1  2  3  4  5
12 13 14 15 NA

 # negative lag
 lag(z, -1, na.pad = TRUE)
 1  2  3  4  5
NA 11 12 13 14

 # mulitple lags
 lag(z, 1:3, na.pad = TRUE)
  lag1 lag2 lag3
1   12   13   14
2   13   14   15
3   14   15   NA
4   15   NA   NA
 lag(z, -(1:3), na.pad = TRUE)
  lag-1 lag-2 lag-3
211NANA
31211NA
4131211
5141312

vignette(zoo) # more info on zoo


On 7/12/07, Aydemir, Zava (FID) [EMAIL PROTECTED] wrote:
 Hi,

 is there any function in R that shifts elements of a vector to the
 opposite direction of what Lag()  of the Hmisc package does? (something
 like, Lag(x, shift = -1) )

 Thanks

 Zava
 

 This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

 __
 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] Package for .632 (and .632+) bootstrap and the cross-validation of ROC Parameters

2007-07-12 Thread spime


Hi users,

I need to calculate .632 (and .632+) bootstrap and the cross-validation of
area under curve (AUC) to compare my models. Is there any package for the
same. I know about 'ipred' and using it i can calculate misclassification
errors. 

Please help. It's urgent. 
-- 
View this message in context: 
http://www.nabble.com/Package-for-.632-%28and-.632%2B%29-bootstrap-and-the-cross-validation-of-ROC-Parameters-tf4068544.html#a11561405
Sent from the R help mailing list archive at Nabble.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] p-value from survreg

2007-07-12 Thread hadley wickham
On 7/12/07, Terry Therneau [EMAIL PROTECTED] wrote:
 The question was how to get the p-value from the fit below, as an S object

 sr-survreg(s~groups, dist=gaussian)
 Coefficients:
 (Intercept)  groups
 -0.02138485  0.03868351

 Scale= 0.01789372

 Loglik(model)= 31.1   Loglik(intercept only)= 25.4
 Chisq= 11.39 on 1 degrees of freedom, p= 0.00074
 n= 16


 
   In general, good places to start are
  names(sr)
  help(survreg.object)
  ssr - summary(sr)
  names(ssr)
 As someone else pointed out, it's also easy to look at the print.survreg
 function and see how the value was created -- one of the things I love
 about S.

 Unfortunately, doing the above myself showed that I have let the documentation
 page for survreg.object get seriously out of date -- quite embarassing as
 that is logically the first place to start.

 As to the print function creating things on the fly: there is an area where
 there is no good answer.  Does one make the return object from a fit such
 that it contains only minimal data, or add in all of the other computations
 that can be derived from these?  The Chambers and Hastie book Statistical
 Models in S, which was the starting point for model objects, leaned towards
 the former, and this still influences many functions.  Often the summary
 function will fill in these derived values, the std and t-tests for
 the individual coefficients for instance.

I think this is where it's nice to have a separate function that does
the filling in - then you can have the best of both worlds.  That's
the role that summary often plays.

Hadley

__
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] ggplot2 / reshape / Question on manipulating data

2007-07-12 Thread Pete Kazmier
hadley wickham [EMAIL PROTECTED] writes:

 On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
 I'm an R newbie but recently discovered the ggplot2 and reshape
 packages which seem incredibly useful and much easier to use for a
 beginner.  Using the data from the IMDB, I'm trying to see how the
 average movie rating varies by year.  Here is what my data looks like:

  ratings - read.delim(groomed.list, header = TRUE, sep = |, 
  comment.char = )
  ratings - subset(ratings, VoteCount  100)
  head(ratings)
  Title  Histogram VoteCount VoteMean Year
 1!Huff (2004) (TV) 16   299  8.4 2004
 8  'Allo 'Allo! (1982) 000125   829  8.6 1982
 50  .hack//SIGN (2002) 001113   150  7.0 2002
 561-800-Missing (2003) 000103   118  5.4 2003
 66  Greatest Artists (2000) (mini) 00..16   110  7.8 2000
 77 00 Scariest Movie (2004) (mini) 00..000115   256  8.6 2004

 Have you tried using the movies dataset included in ggplot?  Or is
 there some data that you want that is not in that dataset.

It's funny that you mention this because I had intended to write this
email about a month ago but was delayed due to other reasons.  In any
case, when I was typing this up last night, I wanted to recreate my
steps but I could not find the IMDB movie data I had used originally.
I searched everywhere to no avail so I downloaded the data myself and
groomed it.  Only now do I remember that I had used the movies dataset
included in ggplot.

 How do 'byYear' and 'byYear2' differ?  I am trying to use 'typeof' but
 both seem to be lists.  However, they are clearly different in some
 way because 'qplot' graphs them differently.

 Try using str - it's much more helpful, and you should see the
 different quickly.

Thanks!  This is the function I've been looking for in my quest to
learn about internal data types of R.  Too bad it has such a terrible
name! 

 Using the built in movies data:

 mm - melt(movies, id=1:2, m=c(rating, votes))
 msum - cast(mm, year ~ variable, c(mean, sum))

 qplot(year, rating_mean, data=msum, colour=votes_sum)
 qplot(year, rating_mean, data=msum, colour=votes_sum, geom=line)

Great!  This is exactly what I was looking to do.  By the way, does
any of your documentation use the movie dataset as an example?  I'm
curious what else I can do with the dataset.  For example, how can I
use ggplot's facets to see the same information by type of movie?  I'm
unsure of how to manipulate the binary variables into a single
variable so that it can be treated as levels.

Thanks!
Pete

__
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] eMail results out of R

2007-07-12 Thread Scillieri, John
We use a program called Blat (www.blat.net) on Windows to email out
results of overnight runs. If you're on Unix/Linux you can definitely do
a similar thing using one of the hundreds of command line utils.

The R code is similar to below:

sendEmail - function(from, to, subject, body)
{
  BLAT - PATH TO BLAT.EXE
  MAILSERVER - your mail server here;
  
  command - paste(BLAT, -, -to, dQuote(to), -server, 
MAILSERVER, -s, dQuote(subject), -f, dQuote(from))

  system(command, input=body)
}

HTH,

John Scillieri


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, July 12, 2007 9:53 AM
To: r-help@stat.math.ethz.ch
Subject: [R] eMail results out of R

Hi everyone,

I did my homework and read the posting guideline :-)

I want to eMail the results of a computing automatically. So I get the
results (the parameters of a garch process) and I want to eMail them to
another person. How can I do that?

Thx
 This e-mail and any attachments are confidential, may contain legal,
professional or other privileged information, and are intended solely for the
addressee.  If you are not the intended recipient, do not use the information
in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP2

__
R-help@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] eMail results out of R

2007-07-12 Thread Duncan Murdoch
On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
 Hi everyone,
 
 I did my homework and read the posting guideline :-)
 
 I want to eMail the results of a computing automatically. So I get the 
 results (the parameters of a garch process) and I want to eMail them to 
 another person. How can I do that?


This will depend on the system you're using.  If the command emailit 
would work from the command line on your system, then

system(emailit)

should work from within R.  Writing that command is the hard part, of 
course.

Duncan Murdoch

__
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] eMail results out of R

2007-07-12 Thread Romain Francois
Hi,

There is a paper in the April 2007 issue of R News that might be of help 
here.
http://##cran mirror##/doc/Rnews/Rnews_2007-1.pdf

Romain

Duncan Murdoch wrote:
 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
   
 Hi everyone,

 I did my homework and read the posting guideline :-)

 I want to eMail the results of a computing automatically. So I get the 
 results (the parameters of a garch process) and I want to eMail them to 
 another person. How can I do that?
 


 This will depend on the system you're using.  If the command emailit 
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of 
 course.

 Duncan Murdoch
   
-- 
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123

__
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] eMail results out of R

2007-07-12 Thread Stéphane Dray
Here is a small function that I used on Debian. It requires exim4 :

send.mail-function(addr='[EMAIL PROTECTED]',subject='A 
message from R',
text=paste(I have finished to work 
,Sys.time(),coll=)){
# send an email
# it requires the reconfiguration of exim4
# you have to connect as root and
# then type dpkg-reconfigure exim4config
   
mail.cmd-paste(mail ,
-s \,subject,\ ,
addr,
  EOT \n,
text,\n,
EOT,
sep=,collapse=)
 system(mail.cmd,intern=FALSE)
  }

Cheers,

Romain Francois wrote:
 Hi,

 There is a paper in the April 2007 issue of R News that might be of help 
 here.
 http://##cran mirror##/doc/Rnews/Rnews_2007-1.pdf

 Romain

 Duncan Murdoch wrote:
   
 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
   
 
 Hi everyone,

 I did my homework and read the posting guideline :-)

 I want to eMail the results of a computing automatically. So I get the 
 results (the parameters of a garch process) and I want to eMail them to 
 another person. How can I do that?
 
   
 This will depend on the system you're using.  If the command emailit 
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of 
 course.

 Duncan Murdoch
   
 


-- 
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

__
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] Difference in linear regression results for Stata and R

2007-07-12 Thread kdestler

Hi
I recently imported data from r into Stata.  I then ran the linear
regression model I've been working on, only to discover that the results are
somewhat (though not dramatically different).  the standard errors vary more
between the two programs than do the coefficients themselves.  Any
suggestions on what I've done that causes this mismatch?

Thanks,
Kate
-- 
View this message in context: 
http://www.nabble.com/Difference-in-linear-regression-results-for-Stata-and-R-tf4069072.html#a11563283
Sent from the R help mailing list archive at Nabble.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] Stepwise GLM selection by LRT?

2007-07-12 Thread Lutz Ph. Breitling
Thank you very much for the prompt reply. Seems like I had not fully
understood what the k-parameter to stepAIC is doing.
Your suggested approach looks indeed fine to me, actually I do not
quite understand why you say that it's only an approximation to the
LRT?

Best wishes-
Lutz

On 7/11/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 Check out the stepAIC function in MASS package.  This is a nice tool, where
 you can actually implement any penalty even though the function's name has
 AIC in it because it is the default.  Although this doesn't do an LRT test
 based variable selection, you can sort of approximate it by using a penalty
 of k = qchisq(1-p, df=1), where p is the p-value for variable selection.
 This penalty means that a variable enters/exits an existing model, when the
 absolute value of change in log-likelihood is greater than qchisq(1-p,
 df=1). For p = 0.1, k = 2.71, and for p=0.05, k = 3.84.  Is this whhant
 you'd like to do?

 Ravi.

 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



 
 


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Lutz Ph. Breitling
 Sent: Wednesday, July 11, 2007 3:06 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Stepwise GLM selection by LRT?

 Dear List,

 having searched the help and archives, I have the impression that
 there is no automatic model selection procedure implemented in R that
 includes/excludes predictors in logistic regression models based on
 LRT P-values. Is that true, or is someone aware of an appropriate
 function somewhere in a custom package?

 Even if automatic model selection and LRT might not be the most
 appropriate methods, I actually would like to use these in order to
 simulate someone else's modeling approach...

 Many thanks for all comments-
 Lutz
 -
 Lutz Ph. Breitling
 German Cancer Research Center
 Heidelberg/Germany

 __
 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] eMail results out of R

2007-07-12 Thread Ted Harding
On 12-Jul-07 13:52:56, [EMAIL PROTECTED] wrote:
 Hi everyone,
 
 I did my homework and read the posting guideline :-)
 
 I want to eMail the results of a computing automatically. So I get the
 results (the parameters of a garch process) and I want to eMail them to
 another person. How can I do that?
 
 Thx

As well as the answers from John Scillieri and Duncan Murdoch:
if it does happen that you're using a Unix/Linux system, then
the appropriate variant of the following illustration will work
(the 'mail' command should always be present on variants of these
systems):

In the little project I'm working on in R at the moment,
I have variables x1 and x2 (each length-50 numeric vectors).

So I can, in R, do:

  sink(file=myoutput)
  cbind(x1,x2)
  sink()
  system(mail ted -s \Test No 2\  myoutput)

which has stored the 2-column output from cbind(x1,x2) in the
file myoutput, and then used the 'mail' command to mail its
contents to 'ted' with subject 'Test No 2' (I used a multi-word
subject to illustrate the quotes the command line will need,
to avoid splitting the subject into separate tokens).

See ?sink for how to use the sink() command.

Then 'ted' duly received an email with contents:

===
Date: Thu, 12 Jul 2007 17:10:44 +0100
From: Ted Harding [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Test No 2

   x1   x2
 [1,]  0.37282844  0.002743146
 [2,]  0.93293155 -0.108009247
 ...
[49,] -0.08681427  0.828313288
[50,] -0.23621908  0.385269729
===

You can of course encapsulate something like the above sequence
of commands into an R function, depending on how you organise the
storage of the results you want to email.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jul-07   Time: 17:25:05
-- XFMail --

__
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] eMail results out of R

2007-07-12 Thread Prof Brian Ripley
On Thu, 12 Jul 2007, Duncan Murdoch wrote:

 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
 Hi everyone,

 I did my homework and read the posting guideline :-)

But failed to follow it, and not telling us the OS makes this very much 
harder to answer adequately.

 I want to eMail the results of a computing automatically. So I get the 
 results (the parameters of a garch process) and I want to eMail them to 
 another person. How can I do that?


 This will depend on the system you're using.  If the command emailit
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of
 course.

But bug.report() will give you a good start on command-line oriented 
systems which have mailx (the POSIX mail client).  (mailx is more standard 
than mail that a couple of others have referred to.)

The adventurous could use make.socket and friends to talk to the sendmail 
daemon on a Unix-alike.

Windows is somewhat harder: 'blat' provides a command-line mail client 
that talks to a SMTP server elsewhere.  If you use MS Exchange you will 
need to find other ways to talk to it (DCOM?)

Long ago we talked about have a mailer() function in R, but making one 
that was close to universal proved to be far too difficult for its 
utility.

-- 
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] eMail results out of R

2007-07-12 Thread Ted Harding
On 12-Jul-07 16:10:46, Stéphane Dray wrote:
 Here is a small function that I used on Debian. It requires exim4 :
 
 send.mail-function(addr='[EMAIL PROTECTED]',subject='A 
 message from R',
 text=paste(I have finished to work 
 ,Sys.time(),coll=)){
 # send an email
 # it requires the reconfiguration of exim4
 # you have to connect as root and
 # then type dpkg-reconfigure exim4config

I'm a bit puzzled by this. On any Unix/Linux system (unless
something has changed very recently which I haven't heard about),
the 'mail' command simply works, for any user (without having
to become root); does not require exim4 (or any particular version
of any particular mail agent--so long as something has to be set up
so that email can be sent at all), and (for the purpose of using
'mail' from R) does not require exim4 or any other mail agent to
be re-configured. The email will be sent From: the user who
is running R.

In the example I posted just now, I just used 'mail' in R's
system() command without doing anything special. The mail transfer
agent in my case is 'sendmail', but it's a standard configuration
and nothing special has been done.



 mail.cmd-paste(mail ,
 -s \,subject,\ ,
 addr,
   EOT \n,
 text,\n,
 EOT,
 sep=,collapse=)
  system(mail.cmd,intern=FALSE)
   }
 
 Cheers,
 
 Romain Francois wrote:
 Hi,

 There is a paper in the April 2007 issue of R News that might be of
 help 
 here.
 http://##cran mirror##/doc/Rnews/Rnews_2007-1.pdf

 Romain

 Duncan Murdoch wrote:
   
 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
   
 
 Hi everyone,

 I did my homework and read the posting guideline :-)

 I want to eMail the results of a computing automatically. So I get
 the results (the parameters of a garch process) and I want to eMail
 them to another person. How can I do that?
 
   
 This will depend on the system you're using.  If the command
 emailit 
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of
 course.

 Duncan Murdoch
   
 
 
 
 -- 
 Stéphane DRAY ([EMAIL PROTECTED] )
 Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
 43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
 Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
 http://biomserv.univ-lyon1.fr/~dray/
 
 __
 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.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jul-07   Time: 18:03:20
-- XFMail --

__
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] error problem with glht

2007-07-12 Thread Peter Furey

Can anyone help me? 
I'm having problems with the following code where I want to test the null
hypothesis that regression slopes are the same among regressions. Here's the
code I've written with comments that include the final error I get. ...

initial.dir - getwd()
library(systemfit)
library(multcomp)

basdata - read.table(data_into7_test.txt, header=TRUE,sep=)

#show basdata 
basdata

#output from above looks like this ...
# basin Order   lnLcl  lnArea
#1SFK 6  3.46322000  5.19766000
#2SFK 6  3.51767000  5.11809000
#3SFK 6  3.79962000  5.79118000
#4SFK 6  2.90242000  4.09768000
#5SFK 4  1.92408000  2.31617000
# 
#21   NFK 6  3.88342000  5.50927000
#22   NFK 6  3.84522000  5.13474000
#23   NFK 6  3.4913  5.28586000
# 

#linear model fit and analysis of variance
fit_area_1 - lm(lnArea~Order*basin,data=basdata)
anova_area_1 - anova(fit_area_1)

#get coefficients, covariance matrix, terms
coef(fit_area_1)
vcov(fit_area_1)
terms(fit_area_1)

#perform multiple comparisons to test null hypothesis that
#linear model fits are the same among basins
fit1_mc - glht(anova_area_1,linfct=mcp(basin=Tukey))

#the line above gives ...
#Error in terms.default(object) : no terms component
#Error in factor_contrasts(model) : no model.matrix method for model found!


I appreciate any help offered. 
Cheers,   Pete

--

Peter Furey
Research Scientist
Northwest Research Associates / CORA
3380 Mitchell Lane
Boulder, CO  80301

Also affiliated with:
Cooperative Institute for Research in Environmental Sciences (CIRES)
University of Colorado, Boulder

__
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] ggplot doesnt work in loops?

2007-07-12 Thread hadley wickham
On 7/12/07, hadley wickham [EMAIL PROTECTED] wrote:
 Hi Steve,

 You need to explicitly print the ggplot object:
 ggplot(mydata, aes(x=mydata$varc)) + geom_bar()

 (this is a R-faq for lattice plots, and ggplot works the same way)

 In the latest version of ggplot (0.5.4) you can construct the plot
 before hand and modify the aesthetics in each instance of the loop:

 p - ggplot(mydata) + geom_bar()
 mydata$varc = c(1,2,3)
 for (i in 1:1){
 jpeg(test3.jpg)
 p + aes(x = mydata$varc)
 dev.off()
 }

 (not that this will actually work because you're not using i inside
 your loop anywhere)

 (and to be strictly correct you should probably use list(x =
 as.name(names(mydata)[i]))  instead of the aes call - but I haven't
 written any documentation for this yet)

Actually a better solution (will be included in the next version of ggplot) is:

aes_string - function(...) structure(lapply(list(...), as.name),
class=uneval)

p + aes_string(x = names(mydata)[i])

It converts aes(x = x, y=y) to aes(x=x, y=y).  The first is easy
to generate programmatically, the second is less to type.

Hadley

__
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] contour and filled contour plots

2007-07-12 Thread Andrea Storto
Hello,

I'm trying to overlap a contour and a filled.contour:
as I read in a previous post this can be done
calling contour() in the plot.axes of filled.contour.

When I do it (see example below) the contour is placed
instead of the color bar, while the filled.contour
is not drawn at all, which is the right way?

Thanks

Andrea



postscript(covtd.xy.eps, width=6.5, height=5.5,
 horizontal=FALSE, onefile=FALSE, paper = special) 
filled.contour(plot.axes={ contour(seq(1,nlev),seq(1,nlev),real2) },
seq(1,nlev),seq(1,nlev),real2,levels=c(-40,-20,-15,-10,-7.5,-5,-2.5,-1.5,-0.5,0.5,1.5,2.5,5,7.5,10,15,20,40),xlab=Model
 
levels,ylab=Model levels,
color = colorRampPalette(c(blue, white, 
red)),main=expression(paste(Unit: ,10^-6, ,K%.%s^-1)))
dev.off()

__
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] Package for .632 (and .632+) bootstrap and the cross-validation of ROC Parameters

2007-07-12 Thread Frank E Harrell Jr
spime wrote:
 
 Hi users,
 
 I need to calculate .632 (and .632+) bootstrap and the cross-validation of
 area under curve (AUC) to compare my models. Is there any package for the
 same. I know about 'ipred' and using it i can calculate misclassification
 errors. 
 
 Please help. It's urgent. 

See the validate* functions in the Design package.

Note that some simulations (see http://biostat.mc.vanderbilt.edu/rms) 
indicate that the advantages of .632 and .632+ over the ordinary 
bootstrap are highly dependent on the choice of the accuracy measure 
being validated.  The bootstrap variants seem to have advantages mainly 
if an improper, inefficient, discontinuous scoring rule such as the 
percent classified correct is used.

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

__
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] Generating bivariate or multivariate data with known parameter values

2007-07-12 Thread thelozee_x



David Kaplan-2 wrote:
 
 Greetings,
 
 I'm interested in generating data from various bivariate or 
 mulitivariate distributions (e.g. gamma, t, etc), where I can specify 
 the parameter values, including the correlations among the variables.  I 
 haven't been able to dig anything up on the faq, but I probably missed 
 something.  A nudge in the right direction would be appreciated.
 
 David
 
 
 -- 
 
 David Kaplan, Ph.D.
 Professor
 Department of Educational Psychology
 University of Wisconsin - Madison
 Educational Sciences, Room 1061
 1025 W. Johnson Street
 Madison, WI 53706
 
 email: [EMAIL PROTECTED]
 Web:   http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
 Phone: 608-262-0836
 Fax:   608-262-0843
 
 __
 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.
 
 

i'm interesting to use multivariate gamma distributed gamma data, in
 copula packages, you say that it can generate bivariate gamma
 distribution, i have try this and succes. my question, 
1. are the copula can be used for generating multivariate gamma
 distributed gamma data?
2. when i try to generating bivariate gamma, can i set the correlation?
 for knowing, i have try many combination of parameters, but the result
 is taht correlation value is about 0.5.

thankyou very much for your responses.

dian
-- 
View this message in context: 
http://www.nabble.com/-R--Generating-bivariate-or-multivariate-data-with-known-parameter-values-tf2405919.html#a11560289
Sent from the R help mailing list archive at Nabble.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] Error in dyn.load()

2007-07-12 Thread Tae-Hoon Chung
Hi, All;

I tried to load the 'genetics' library but it failed with the  
following message. Can you help me with this? Thanks in advance.

  library(genetics)
Loading required package: gdata
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library '/Library/Frameworks/R.framework/ 
Versions/2.5/Resources/library/gtools/libs/ppc/gtools.so':
   dlopen(/Library/Frameworks/R.framework/Versions/2.5/Resources/ 
library/gtools/libs/ppc/gtools.so, 6): Library not loaded: /Library/ 
Frameworks/R.framework/Versions/2.4/Resources/lib/libR.dylib
   Referenced from: /Library/Frameworks/R.framework/Versions/2.5/ 
Resources/library/gtools/libs/ppc/gtools.so
   Reason: Incompatible library version: gtools.so requires version  
2.4.0 or later, but libR.dylib provides version 2.2.0
Error: package 'gdata' could not be loaded

I am using Mac OS X R 2.5.0. The libraries, 'genetics' v1.2.1,  
'gtools' v2.3.1, and 'gdata' v2.3.1 are already installed.

Tae-Hoon Chung

Post-Doctoral Researcher
Computational Biology Division, TGEN
445 N 5th St. Phoenix, AZ 85004 USA
O: 1-602-343-8724
F: 1-602-343-8840



[[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] multiple plots in a graph

2007-07-12 Thread Ajay Singh
Hi,
I have to generate 10 cdfs in a graph. I need to compare the cdf's 
nature by plotting ten cdfs in a graph. Thus, I need multiple plots in a 
graph.
I would appreciate if you could give some solution to the problem asap.

Thanking you,

Sincerely,

Ajay.

-- 
Ajay Singh
Research Scientist,
SOM, IIT-Bombay, Powai,
MUMBAI-400076, MH (INDIA).

__
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] calculating percent error from 2 vectors

2007-07-12 Thread Scott Bearer
Hello,

I believe this is an easy scripting problem, but one I am stumbling on.

I have a known vector of 3 colors with nrow=10:
known-c(red, blue, red, red, yellow, blue, yellow, blue,
blue, yellow)

and a model output vector:
modelout-c(red, red, red, blue, yellow, blue, blue, red,
blue, yellow)

I would like to determine the proportion (in)correctly identified for each
color.  In other words:
% correct red=
% correct blue=
% correct yellow=

How would I code this (assuming the actual dataset is more complex)?

Any help would be much appreciated.

Thank you,
Scott

__
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] Interpreting a string as a variable in a column header

2007-07-12 Thread rosa clements
This must be a very simple question, but I can't find any information
on it elsewhere, sorry. When extracting information from a list using
column headers, how do I get R to interpret something as a variable
rather than a string? For example:

xx$YAL002

works, but this doesn't:

gene - YAL002
xx$gene

neither do

xx$parse(gene)
xx$eval(gene)
xx$eval(parse(gene))

or a variety of other constructions I have tried.

Background: I have a table of information about yeast genes, and I
also have a list of yeast genes and their GO terms (xx) from the YEAST
package that I downloaded. I want to go through all the genes in my
table and look up their GO terms in the list from the YEAST package.
They might not contain exactly the same genes (ideally they should,
but I'd be surprised if they do) and I don't think they're in the same
order, so I do want to use the column names, but there are a lot of
them so I'm not typing them all out individually. It might be possible
to turn the GO data into something other than a list, but the help
page recommends using xx - as.list(YEASTGO) and doesn't make any
other suggestions, so I should probably do as I'm told.

Thanks for any help or suggestions of where to look,

Rosa

__
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] ggplot2 / histogram / y-axis

2007-07-12 Thread Pete Kazmier
Is there a way in ggplot to make a histogram with the left-hand y-axis
label as frequency, and a right-hand y-axis label as percentage?

Thanks!
Pete

__
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] Compute rank within factor groups

2007-07-12 Thread Ken Williams
Hi,

I have a data.frame which is ordered by score, and has a factor column:

  Browse[1] wc[c(report,score)]
  report score
  9 ADEA  0.96
  8 ADEA  0.90
  11 Asylum_FED9  0.86
  3 ADEA  0.75
  14 Asylum_FED9  0.60
  5 ADEA  0.56
  13 Asylum_FED9  0.51
  16 Asylum_FED9  0.51
  2 ADEA  0.42
  7 ADEA  0.31
  17 Asylum_FED9  0.27
  1 ADEA  0.17
  4 ADEA  0.17
  6 ADEA  0.12
  10ADEA  0.11
  12 Asylum_FED9  0.10
  15 Asylum_FED9  0.09
  18 Asylum_FED9  0.07
  Browse[1] 

I need to add a column indicating rank within each factor group, which I
currently accomplish like so:

  wc$rank - 0
  for(report in as.character(unique(wc$report))) {
wc[wc$report==report,]$rank - 1:sum(wc$report==report)
  }

I have to wonder whether there's a better way, something that gets rid of
the for() loop using tapply() or by() or similar.  But I haven't come up
with anything.

I've tried these:

  by(wc, wc$report, FUN=function(pr){pr$rank - 1:nrow(pr)})

  by(wc, wc$report, FUN=function(pr){wc[wc$report %in% pr$report,]$rank -
1:nrow(pr)})

But in both cases the effect of the assignment is lost, there's no $rank
column generated for wc.

Any suggestions?

 -Ken

__
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] ggplot2 / reshape / Question on manipulating data

2007-07-12 Thread hadley wickham
On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
 hadley wickham [EMAIL PROTECTED] writes:

  On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
  I'm an R newbie but recently discovered the ggplot2 and reshape
  packages which seem incredibly useful and much easier to use for a
  beginner.  Using the data from the IMDB, I'm trying to see how the
  average movie rating varies by year.  Here is what my data looks like:
 
   ratings - read.delim(groomed.list, header = TRUE, sep = |, 
   comment.char = )
   ratings - subset(ratings, VoteCount  100)
   head(ratings)
   Title  Histogram VoteCount VoteMean Year
  1!Huff (2004) (TV) 16   299  8.4 2004
  8  'Allo 'Allo! (1982) 000125   829  8.6 1982
  50  .hack//SIGN (2002) 001113   150  7.0 2002
  561-800-Missing (2003) 000103   118  5.4 2003
  66  Greatest Artists (2000) (mini) 00..16   110  7.8 2000
  77 00 Scariest Movie (2004) (mini) 00..000115   256  8.6 2004
 
  Have you tried using the movies dataset included in ggplot?  Or is
  there some data that you want that is not in that dataset.

 It's funny that you mention this because I had intended to write this
 email about a month ago but was delayed due to other reasons.  In any
 case, when I was typing this up last night, I wanted to recreate my
 steps but I could not find the IMDB movie data I had used originally.
 I searched everywhere to no avail so I downloaded the data myself and
 groomed it.  Only now do I remember that I had used the movies dataset
 included in ggplot.

  How do 'byYear' and 'byYear2' differ?  I am trying to use 'typeof' but
  both seem to be lists.  However, they are clearly different in some
  way because 'qplot' graphs them differently.
 
  Try using str - it's much more helpful, and you should see the
  different quickly.

 Thanks!  This is the function I've been looking for in my quest to
 learn about internal data types of R.  Too bad it has such a terrible
 name!

  Using the built in movies data:
 
  mm - melt(movies, id=1:2, m=c(rating, votes))
  msum - cast(mm, year ~ variable, c(mean, sum))
 
  qplot(year, rating_mean, data=msum, colour=votes_sum)
  qplot(year, rating_mean, data=msum, colour=votes_sum, geom=line)

 Great!  This is exactly what I was looking to do.  By the way, does
 any of your documentation use the movie dataset as an example?  I'm
 curious what else I can do with the dataset.  For example, how can I
 use ggplot's facets to see the same information by type of movie?  I'm
 unsure of how to manipulate the binary variables into a single
 variable so that it can be treated as levels.

A lot of the examples do use the movies data, but I don't think any of
it is particularly revealing.  You might want to look at the results
for the 2007 infovis visualisation challenge
(http://www.apl.jhu.edu/Misc/Visualization/) which uses similar data.
Submission isn't complete yet, but you can see my teams entry at
http://had.co.nz/infovis-2007/.  There are lots of interesting stories
to pursue.

I think I will update the movies data to include the first genre as
another column.  That will make it easier to facet by genre

Hadley

__
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] Interpreting a string as a variable in a column header

2007-07-12 Thread Greg Snow
Use xx[[gene]] instead of xx$gene (the $ is a shorthand for [[ with some
extra magic to be more convenient, the magic is getting in your way, so
go back to the [[ syntax (make sure you double the braces)).

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of rosa clements
 Sent: Thursday, July 12, 2007 11:39 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Interpreting a string as a variable in a column header
 
 This must be a very simple question, but I can't find any 
 information on it elsewhere, sorry. When extracting 
 information from a list using column headers, how do I get R 
 to interpret something as a variable rather than a string? 
 For example:
 
 xx$YAL002
 
 works, but this doesn't:
 
 gene - YAL002
 xx$gene
 
 neither do
 
 xx$parse(gene)
 xx$eval(gene)
 xx$eval(parse(gene))
 
 or a variety of other constructions I have tried.
 
 Background: I have a table of information about yeast genes, 
 and I also have a list of yeast genes and their GO terms (xx) 
 from the YEAST package that I downloaded. I want to go 
 through all the genes in my table and look up their GO terms 
 in the list from the YEAST package.
 They might not contain exactly the same genes (ideally they 
 should, but I'd be surprised if they do) and I don't think 
 they're in the same order, so I do want to use the column 
 names, but there are a lot of them so I'm not typing them all 
 out individually. It might be possible to turn the GO data 
 into something other than a list, but the help page 
 recommends using xx - as.list(YEASTGO) and doesn't make any 
 other suggestions, so I should probably do as I'm told.
 
 Thanks for any help or suggestions of where to look,
 
 Rosa
 
 __
 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] calculating percent error from 2 vectors

2007-07-12 Thread Greg Snow
Try something like:

 mytable - table(known, modelout)
 prop.table( mytable, 1 )

Also look at ?addmargins and the CrossTable function in the gmodels
package.

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Scott Bearer
 Sent: Thursday, July 12, 2007 11:32 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] calculating percent error from 2 vectors
 
 Hello,
 
 I believe this is an easy scripting problem, but one I am 
 stumbling on.
 
 I have a known vector of 3 colors with nrow=10:
 known-c(red, blue, red, red, yellow, blue, 
 yellow, blue, blue, yellow)
 
 and a model output vector:
 modelout-c(red, red, red, blue, yellow, blue, 
 blue, red, blue, yellow)
 
 I would like to determine the proportion (in)correctly 
 identified for each color.  In other words:
 % correct red=
 % correct blue=
 % correct yellow=
 
 How would I code this (assuming the actual dataset is more complex)?
 
 Any help would be much appreciated.
 
 Thank you,
 Scott
 
 __
 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] Resolved: Error in dyn.load()

2007-07-12 Thread Tae-Hoon Chung
Hi, All;

I simply upgraded my R from version 2.5.0 to 2.5.1 and the whole  
problems disappeared.
So I am closing the question myself. It could have been the R version  
problem.

Tae-Hoon Chung

Post-Doctoral Researcher
Computational Biology Division, TGEN
445 N 5th St. Phoenix, AZ 85004 USA
O: 1-602-343-8724
F: 1-602-343-8840



[[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] Compute rank within factor groups

2007-07-12 Thread Greg Snow
Look at ?ave and try something like:

 wc$rank - ave( wc$score, wc$report, FUN=rank )

This works even if the dataframe is not pre sorted.

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Ken Williams
 Sent: Thursday, July 12, 2007 12:09 PM
 To: R-help@stat.math.ethz.ch
 Subject: [R] Compute rank within factor groups
 
 Hi,
 
 I have a data.frame which is ordered by score, and has a 
 factor column:
 
   Browse[1] wc[c(report,score)]
   report score
   9 ADEA  0.96
   8 ADEA  0.90
   11 Asylum_FED9  0.86
   3 ADEA  0.75
   14 Asylum_FED9  0.60
   5 ADEA  0.56
   13 Asylum_FED9  0.51
   16 Asylum_FED9  0.51
   2 ADEA  0.42
   7 ADEA  0.31
   17 Asylum_FED9  0.27
   1 ADEA  0.17
   4 ADEA  0.17
   6 ADEA  0.12
   10ADEA  0.11
   12 Asylum_FED9  0.10
   15 Asylum_FED9  0.09
   18 Asylum_FED9  0.07
   Browse[1] 
 
 I need to add a column indicating rank within each factor 
 group, which I currently accomplish like so:
 
   wc$rank - 0
   for(report in as.character(unique(wc$report))) {
 wc[wc$report==report,]$rank - 1:sum(wc$report==report)
   }
 
 I have to wonder whether there's a better way, something that 
 gets rid of the for() loop using tapply() or by() or similar. 
  But I haven't come up with anything.
 
 I've tried these:
 
   by(wc, wc$report, FUN=function(pr){pr$rank - 1:nrow(pr)})
 
   by(wc, wc$report, FUN=function(pr){wc[wc$report %in% 
 pr$report,]$rank -
 1:nrow(pr)})
 
 But in both cases the effect of the assignment is lost, 
 there's no $rank column generated for wc.
 
 Any suggestions?
 
  -Ken
 
 __
 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] Stepwise GLM selection by LRT?

2007-07-12 Thread Prof Brian Ripley
On Thu, 12 Jul 2007, Lutz Ph. Breitling wrote:

 Thank you very much for the prompt reply. Seems like I had not fully
 understood what the k-parameter to stepAIC is doing.
 Your suggested approach looks indeed fine to me, actually I do not
 quite understand why you say that it's only an approximation to the
 LRT?

So this is computing AIC_k = -2L + kp.  If you compare models with p and 
p+q parameters, this is equvalent to comparing 2 log LR with kq and so for 
q=1 the Wilks' LRT is found for k = qchisq(1-p, df=1) (which is just a 
squared Normal).

However, no one said q would always be one, and stepAIC steps in terms, 
not individual coefficients.  Therein lies one of the approximations 
(another is in the asympototic distribution theory of the test).


 Best wishes-
 Lutz

 On 7/11/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 Check out the stepAIC function in MASS package.  This is a nice tool, where
 you can actually implement any penalty even though the function's name has
 AIC in it because it is the default.  Although this doesn't do an LRT test
 based variable selection, you can sort of approximate it by using a penalty
 of k = qchisq(1-p, df=1), where p is the p-value for variable selection.
 This penalty means that a variable enters/exits an existing model, when the
 absolute value of change in log-likelihood is greater than qchisq(1-p,
 df=1). For p = 0.1, k = 2.71, and for p=0.05, k = 3.84.  Is this whhant
 you'd like to do?

 Ravi.

 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



 
 


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Lutz Ph. Breitling
 Sent: Wednesday, July 11, 2007 3:06 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Stepwise GLM selection by LRT?

 Dear List,

 having searched the help and archives, I have the impression that
 there is no automatic model selection procedure implemented in R that
 includes/excludes predictors in logistic regression models based on
 LRT P-values. Is that true, or is someone aware of an appropriate
 function somewhere in a custom package?

 Even if automatic model selection and LRT might not be the most
 appropriate methods, I actually would like to use these in order to
 simulate someone else's modeling approach...

 Many thanks for all comments-
 Lutz
 -
 Lutz Ph. Breitling
 German Cancer Research Center
 Heidelberg/Germany

 __
 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] ggplot2 / histogram / y-axis

2007-07-12 Thread hadley wickham
On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
 Is there a way in ggplot to make a histogram with the left-hand y-axis
 label as frequency, and a right-hand y-axis label as percentage?

Not currently.  I did a quick exploration to see if it was feasible to
draw another axis on with grid, but it doesn't look like it's
possible:

p - qplot(rating, data=movies, geom=histogram)

# Map aesthetics to data
data - p$layers[[1]]$make_aesthetics(p)
# Calculate statistic by hand (we'll need this to get the scales right)
binned - StatBin$calculate(data=data, p$scales)

n - nrow(movies)

# Manually recreate the y scale
sp - scale_y_continuous()
sp$train(binned$count)

# rescale the labels
labels - formatC(sp$breaks() / n, digits=2)

# Have to do without labels because of bug in grid
print(p, pretty=FALSE)
downViewport(panel_1_1)
grid.draw(ggaxis(sp$breaks(), as.list(labels), right, sp$frange()))

# Why don't labels line up? - I'm not sure
# How could you make space for the extra axis? - Not sure either
# How would this worked for a facetted graphic - not well


Also how were you expecting the axes/gridlines to line up?  Would both
axes be labelled nicely (with whole numbers) and the secondary axis
wouldn't have gridlines; or would the second axis match the lines of
the primary, even though the number wouldn't be so attractive?

Hadley

__
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 in a graph

2007-07-12 Thread Uwe Ligges


Ajay Singh wrote:
 Hi,
 I have to generate 10 cdfs in a graph. I need to compare the cdf's 
 nature by plotting ten cdfs in a graph. Thus, I need multiple plots in a 
 graph.
 I would appreciate if you could give some solution to the problem asap.


  plot(ecdf(rnorm(10)))
  plot(ecdf(rnorm(12)), add=TRUE, col.points=red, col.hor=red)

etc...


Uwe Ligges


 Thanking you,
 
 Sincerely,
 
 Ajay.


__
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] is.null doesn't work

2007-07-12 Thread Atte Tenkanen

Seems to work, if I unlist the argument at first ;-)

Atte

 Hi,
 
 What's wrong here?:
 
  v=c(`-`,`+`,1,`^`,`^`,NA,NA,X,9,X,2)
  i2=16
  v[i2]
 [[1]]
 NULL
 
  is.null(v[i2])
 [1] FALSE
 
 Is it a bug or have I misunderstood something?
 
 Atte Tenkanen
 University of Turku, Finland


__
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] calculating percent error from 2 vectors

2007-07-12 Thread Ted Harding
On 12-Jul-07 17:32:03, Scott Bearer wrote:
 Hello,
 
 I believe this is an easy scripting problem, but one I am stumbling on.
 
 I have a known vector of 3 colors with nrow=10:
 known-c(red, blue, red, red, yellow, blue, yellow,
 blue,
 blue, yellow)
 
 and a model output vector:
 modelout-c(red, red, red, blue, yellow, blue, blue,
 red,
 blue, yellow)
 
 I would like to determine the proportion (in)correctly identified for
 each
 color.  In other words:
 % correct red=
 % correct blue=
 % correct yellow=
 
 How would I code this (assuming the actual dataset is more complex)?

For your example:

 tbl-table(known,modelout)

 tbl
modelout
knownblue red yellow
  blue   22   0 
  red12   0 
  yellow 10   2 

 dim(tbl)
[1] 3 3

 for(i in (1:dim(tbl)[1])){print(sum(tbl[i,-i])/sum(tbl[i,]))}
[1] 0.5
[1] 0.333
[1] 0.333

and you can modify the print command produce a desired format,
e.g. using rownames(tbl)[i] for the successive colour names.

Hoping this helps (as a start),
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jul-07   Time: 20:15:34
-- XFMail --

__
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] Compute rank within factor groups

2007-07-12 Thread jim holtman
Is this what you are looking for:

 x
report score
9 ADEA  0.96
8 ADEA  0.90
11 Asylum_FED9  0.86
3 ADEA  0.75
14 Asylum_FED9  0.60
5 ADEA  0.56
13 Asylum_FED9  0.51
16 Asylum_FED9  0.51
2 ADEA  0.42
7 ADEA  0.31
17 Asylum_FED9  0.27
1 ADEA  0.17
4 ADEA  0.17
6 ADEA  0.12
10ADEA  0.11
12 Asylum_FED9  0.10
15 Asylum_FED9  0.09
18 Asylum_FED9  0.07
 x$rank - ave(x$score, x$report, FUN=rank)
 x
report score rank
9 ADEA  0.96 10.0
8 ADEA  0.90  9.0
11 Asylum_FED9  0.86  8.0
3 ADEA  0.75  8.0
14 Asylum_FED9  0.60  7.0
5 ADEA  0.56  7.0
13 Asylum_FED9  0.51  5.5
16 Asylum_FED9  0.51  5.5
2 ADEA  0.42  6.0
7 ADEA  0.31  5.0
17 Asylum_FED9  0.27  4.0
1 ADEA  0.17  3.5
4 ADEA  0.17  3.5
6 ADEA  0.12  2.0
10ADEA  0.11  1.0
12 Asylum_FED9  0.10  3.0
15 Asylum_FED9  0.09  2.0
18 Asylum_FED9  0.07  1.0



On 7/12/07, Ken Williams [EMAIL PROTECTED] wrote:
 Hi,

 I have a data.frame which is ordered by score, and has a factor column:

  Browse[1] wc[c(report,score)]
  report score
  9 ADEA  0.96
  8 ADEA  0.90
  11 Asylum_FED9  0.86
  3 ADEA  0.75
  14 Asylum_FED9  0.60
  5 ADEA  0.56
  13 Asylum_FED9  0.51
  16 Asylum_FED9  0.51
  2 ADEA  0.42
  7 ADEA  0.31
  17 Asylum_FED9  0.27
  1 ADEA  0.17
  4 ADEA  0.17
  6 ADEA  0.12
  10ADEA  0.11
  12 Asylum_FED9  0.10
  15 Asylum_FED9  0.09
  18 Asylum_FED9  0.07
  Browse[1]

 I need to add a column indicating rank within each factor group, which I
 currently accomplish like so:

  wc$rank - 0
  for(report in as.character(unique(wc$report))) {
wc[wc$report==report,]$rank - 1:sum(wc$report==report)
  }

 I have to wonder whether there's a better way, something that gets rid of
 the for() loop using tapply() or by() or similar.  But I haven't come up
 with anything.

 I've tried these:

  by(wc, wc$report, FUN=function(pr){pr$rank - 1:nrow(pr)})

  by(wc, wc$report, FUN=function(pr){wc[wc$report %in% pr$report,]$rank -
 1:nrow(pr)})

 But in both cases the effect of the assignment is lost, there's no $rank
 column generated for wc.

 Any suggestions?

  -Ken

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



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

What is the problem you are trying to solve?

__
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] is.null doesn't work

2007-07-12 Thread Atte Tenkanen
Hi,

What's wrong here?:

 v=c(`-`,`+`,1,`^`,`^`,NA,NA,X,9,X,2)
 i2=16
 v[i2]
[[1]]
NULL

 is.null(v[i2])
[1] FALSE

Is it a bug or have I misunderstood something?

Atte Tenkanen
University of Turku, Finland

__
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] how to estimate treatment-interaction contrasts

2007-07-12 Thread szhan
Hello, R experts,
Sorry for asking this question again again since I really want a help!

I have a two-factor experiment data and like to calculate estimates of
interation contrasts say factor A has levels of a1, a2, and B has
levels of b1, b2, b3, b4, and b5 with 3 replicates. I am not sure the
constrast estimate I got is right using the script below:

score-c(7.2,6.5,6.9,6.4,6.9,6.1,6.9,5.3,7.2,5.7,5.1,5.9,7.6,6.9,6.8,
7.2,6.6,6.9,6.4,6.0,6.0,6.9,6.9,6.4,7.5,7.7,7.0,8.6,8.8,8.3)

A - gl(2, 15, labels=c(a1, a2))
B - rep(gl(5, 3, labels=c(b1, b2, b3, b4, b5)), 2)

contrasts(B)-cbind(c(-4,rep(1,4)),c(rep(-3,2),rep(2,3)),
+  c(rep(-2,3),rep(3,2)),c(rep(-1,4), rep(4,1)))
fit1 - aov(score ~ A*B)
summary(fit1, split=list(B=1:4), expand.split = TRUE)
   Df Sum Sq Mean Sq F valuePr(F)
A1 3.2013  3.2013 15.1483 0.0009054 ***
B4 8.7780  2.1945 10.3841 0.0001019 ***
 B: C1  1 0.0301  0.0301  0.1424 0.7099296
 B: C2  1 2.0335  2.0335  9.6221 0.0056199 **
 B: C3  1 1.2469  1.2469  5.9004 0.0246876 *
 B: C4  1 5.4675  5.4675 25.8715 5.637e-05 ***
A:B  4 5.3420  1.3355  6.3194 0.0018616 **
 A:B: C11 0.7207  0.7207  3.4105 0.0796342 .
 A:B: C21 2.6068  2.6068 12.3350 0.0021927 **
 A:B: C31 1.9136  1.9136  9.0549 0.0069317 **
 A:B: C41 0.1008  0.1008  0.4771 0.4976647
Residuals   20 4.2267  0.2113
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Now I like to get interaction contrast estimate for b1 and b2 vs b3, b4 and b5
cont - c(1, -1)[A] * c(-3, -3, 2, 2, 2)[B]

estimat-sum(cont*score) # value of the contrast estimate for A:B C2

 estimat
[1] -24.1

I am not sure the estimate for A:B C2 contrast  (-24.1) is correct
because the F value given the output above(12.3350) does not equal to
those I calculate below (15.2684):

t.stat - sum(cont*score)/se.contrast(fit1, as.matrix(cont))
 t.stat^2
Contrast 1
 15.2684

Could you please help me calculate the correct the estimate of
interaction contrast and corresponding F value?
Thanks in advance!
Joshua

__
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] ggplot2 / histogram / y-axis

2007-07-12 Thread Pete Kazmier
hadley wickham [EMAIL PROTECTED] writes:

 On 7/12/07, Pete Kazmier [EMAIL PROTECTED] wrote:
 Is there a way in ggplot to make a histogram with the left-hand y-axis
 label as frequency, and a right-hand y-axis label as percentage?

 Not currently.  I did a quick exploration to see if it was feasible to
 draw another axis on with grid, but it doesn't look like it's
 possible:

Thank you for trying.

 Also how were you expecting the axes/gridlines to line up?  Would both
 axes be labelled nicely (with whole numbers) and the secondary axis
 wouldn't have gridlines; or would the second axis match the lines of
 the primary, even though the number wouldn't be so attractive?

I hadn't thought that far ahead.  Depending on the audience, I render
histograms differently, and was curious if I could just put both on a
single graph.  However, you bring up some interesting questions in
terms of the presentation.

On another note, and feel free to defer me to the documentation which
I'm still in the process of reading, but will I be able to take
advantage of some of Tufte's recommendations in terms of the typical
histogram and/or scatterplots (pp126-134 in Visual Display of
Quantitative Information)?

For example, with histograms, he would eliminates the use of
coordinate lines in favor of using a white grid to improve the
data/ink ratio.  Likewise in scatterplots, he uses range-frames and
dot-dash-plots.  Will I be able to use ggplot for these types of
enhancements?  

Thanks,
Pete

__
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] Compute rank within factor groups

2007-07-12 Thread Greg Snow
Why are you using order instead of rank?

If the data is pre sorted then they tend to give the same result (unless
there are ties), but if your data is not presorted, then the results
will be different.

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

 -Original Message-
 From: Ken Williams [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, July 12, 2007 2:50 PM
 To: Greg Snow; R-help@stat.math.ethz.ch
 Subject: Re: [R] Compute rank within factor groups
 
 
 
 
 On 7/12/07 3:42 PM, Ken Williams [EMAIL PROTECTED] wrote:
 
  I ended up using:
  
   wc$rank - ave( wc$score, wc$report,
   FUN=function(x) order(x, decreasing=TRUE) )
  
  Which gives me the 1-based rank integers I was looking for.
 
 Of course, immediately after sending I realized a simpler way:
 
   wc$rank - ave( -wc$score, wc$report, FUN=order )
 
 And as a newbie I think I get to be blissfully ignorant of 
 which one is faster. =)
 
 
 --
 Ken Williams
 Research Scientist
 The Thomson Corporation
 Eagan, MN
 


__
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] automatically generating and accessing data frames of varying dimensions

2007-07-12 Thread Drescher, Michael (MNR)
Hi All,

I want to automatically generate a number of data frames, each with an
automatically generated name and an automatically generated number of
rows. The number of rows has been calculated before and is different for
all data frames (e.g. c(4,5,2)). The number of columns is known a priori
and the same for all data frames (e.g. c(3,3,3)). The resulting data
frames could look something like this:

 auto.data.1
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0

 auto.data.2
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0
5  0  0  0

 auto.data.3
  X1 X2 X3
1  0  0  0
2  0  0  0

Later, I want to fill the elements of the data frames with values read
from somewhere else, automatically looping through the previously
generated data frames.

I know that I can automatically generate variables with the right number
of elements with something like this:

 auto.length - c(12,15,6)
 for(i in 1:3) {
+ nam - paste(auto.data,i, sep=.)
+ assign(nam, 1:auto.length[i])
+ }
 auto.data.1
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 auto.data.2
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
 auto.data.3
[1]  1 2 3 4 5 6

But how do I turn these variables into data frames or give them any
dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
not seem to work. I also seem not to be able to access the variables
with something like auto.data.i since:

 auto.data.i
Error: object auto.data.i not found

Thus, how would I be able to automatically write to the elements of the
data frames later in a loop such as ...

 for(i in 1:3) {
+ for(j in 1:nrow(auto.data.i)) {   ### this obviously does not work
since 'Error in nrow(auto.data.i) : object auto.data.i not found'
+ for(k in 1:ncol(auto.data.i)) {
+ auto.data.i[j,k] - 'some value'
+ }}}

Thanks a bunch for all your help.

Best, Michael


Michael Drescher
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
1235 Queen St East
Sault Ste Marie, ON, P6A 2E3
Tel: (705) 946-7406
Fax: (705) 946-2030

__
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] JRI problem on 64bit Linux

2007-07-12 Thread chuckanut
Sorry if this isn't the correct list, but I couldn't find any mailing
lists on the JRI site.  I am able to install JRI on a 32 bin linux
machine without any problem, but I am unable to isntall on a 64 bit
machine.  I have R installed with the correct option, R_HOME is set up
and libR.so is in there.  However, I get the following error when
running ./configure, any help is appreciated

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for java... /usr/java/jdk1.5.0_11/bin/java
checking for javac... /usr/java/jdk1.5.0_11/bin/javac
checking for javah... /usr/java/jdk1.5.0_11/bin/javah
checking for jar... /usr/java/jdk1.5.0_11/bin/jar
checking whether Java interpreter works... yes
checking for Java environment... in /usr/java/jdk1.5.0_11
checking for /usr/java/jdk1.5.0_11/include/jni.h... yes
checking for /usr/java/jdk1.5.0_11/include/./jni_md.h... no
checking for /usr/java/jdk1.5.0_11/include/linux/jni_md.h... yes
checking whether JNI programs can be compiled... configure: error:
Cannot compile a simple JNI program. See config.log for details.

__
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] Compute rank within factor groups

2007-07-12 Thread Peter Dalgaard
Ken Williams wrote:
 Hi,

 I have a data.frame which is ordered by score, and has a factor column:

   Browse[1] wc[c(report,score)]
   report score
   9 ADEA  0.96
   8 ADEA  0.90
   11 Asylum_FED9  0.86
   3 ADEA  0.75
   14 Asylum_FED9  0.60
   5 ADEA  0.56
   13 Asylum_FED9  0.51
   16 Asylum_FED9  0.51
   2 ADEA  0.42
   7 ADEA  0.31
   17 Asylum_FED9  0.27
   1 ADEA  0.17
   4 ADEA  0.17
   6 ADEA  0.12
   10ADEA  0.11
   12 Asylum_FED9  0.10
   15 Asylum_FED9  0.09
   18 Asylum_FED9  0.07
   Browse[1] 

 I need to add a column indicating rank within each factor group, which I
 currently accomplish like so:

   wc$rank - 0
   for(report in as.character(unique(wc$report))) {
 wc[wc$report==report,]$rank - 1:sum(wc$report==report)
   }

 I have to wonder whether there's a better way, something that gets rid of
 the for() loop using tapply() or by() or similar.  But I haven't come up
 with anything.

 I've tried these:

   by(wc, wc$report, FUN=function(pr){pr$rank - 1:nrow(pr)})

   by(wc, wc$report, FUN=function(pr){wc[wc$report %in% pr$report,]$rank -
 1:nrow(pr)})

 But in both cases the effect of the assignment is lost, there's no $rank
 column generated for wc.

 Any suggestions?
   
There's a little known and somewhat unfortunately named function called 
ave() which does just that sort of thing.

  ave(wc$score, wc$report, FUN=rank)
 [1] 10.0  9.0  8.0  8.0  7.0  7.0  5.5  5.5  6.0  5.0  4.0  3.5  3.5  
2.0  1.0
[16]  3.0  2.0  1.0

__
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] automatically generating and accessing data frames of varying dimensions

2007-07-12 Thread Julian Burgos
Replace

assign(nam, 1:auto.length[i])

with


assign(nam,data.frame(matrix(1:auto.length[i], ncol=3)))

Verify if the matrix (and hence the data frame) is filled the way you 
intended.  Otherwise, use the argument byrow=T.

Julian M. Burgos

Fisheries Acoustics Research Lab
School of Aquatic and Fishery Science
University of Washington


Drescher, Michael (MNR) wrote:
 Hi All,

 I want to automatically generate a number of data frames, each with an
 automatically generated name and an automatically generated number of
 rows. The number of rows has been calculated before and is different for
 all data frames (e.g. c(4,5,2)). The number of columns is known a priori
 and the same for all data frames (e.g. c(3,3,3)). The resulting data
 frames could look something like this:

 auto.data.1
   X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0

 auto.data.2
   X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0
 5  0  0  0

 auto.data.3
   X1 X2 X3
 1  0  0  0
 2  0  0  0

 Later, I want to fill the elements of the data frames with values read
 from somewhere else, automatically looping through the previously
 generated data frames.

 I know that I can automatically generate variables with the right number
 of elements with something like this:

 auto.length - c(12,15,6)
 for(i in 1:3) {
 + nam - paste(auto.data,i, sep=.)
 + assign(nam, 1:auto.length[i])
 + }
 auto.data.1
  [1]  1  2  3  4  5  6  7  8  9 10 11 12
 auto.data.2
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
 auto.data.3
 [1]  1 2 3 4 5 6

 But how do I turn these variables into data frames or give them any
 dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
 not seem to work. I also seem not to be able to access the variables
 with something like auto.data.i since:

 auto.data.i
 Error: object auto.data.i not found

 Thus, how would I be able to automatically write to the elements of the
 data frames later in a loop such as ...

 for(i in 1:3) {
 + for(j in 1:nrow(auto.data.i)) { ### this obviously does not work
 since 'Error in nrow(auto.data.i) : object auto.data.i not found'
 + for(k in 1:ncol(auto.data.i)) {
 + auto.data.i[j,k] - 'some value'
 + }}}

 Thanks a bunch for all your help.

 Best, Michael


 Michael Drescher
 Ontario Forest Research Institute
 Ontario Ministry of Natural Resources
 1235 Queen St East
 Sault Ste Marie, ON, P6A 2E3
 Tel: (705) 946-7406
 Fax: (705) 946-2030

 __
 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] (no subject)

2007-07-12 Thread Drescher, Michael (MNR)
Hi All,

I want to automatically generate a number of data frames, each with an
automatically generated name and an automatically generated number of
rows. The number of rows has been calculated before and is different for
all data frames (e.g. c(4,5,2)). The number of columns is known a priori
and the same for all data frames (e.g. c(3,3,3)). The resulting data
frames could look something like this:

 auto.data.1
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0

 auto.data.2
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0
5  0  0  0

 auto.data.3
  X1 X2 X3
1  0  0  0
2  0  0  0

Later, I want to fill the elements of the data frames with values read
from somewhere else, automatically looping through the previously
generated data frames.

I know that I can automatically generate variables with the right number
of elements with something like this:

 auto.length - c(12,15,6)
 for(i in 1:3) {
+ nam - paste(auto.data,i, sep=.)
+ assign(nam, 1:auto.length[i])
+ }
 auto.data.1
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 auto.data.2
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
 auto.data.3
[1]  1 2 3 4 5 6

But how do I turn these variables into data frames or give them any
dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
not seem to work. I also seem not to be able to access the variables
with something like auto.data.i since:

 auto.data.i
Error: object auto.data.i not found

Thus, how would I be able to automatically write to the elements of the
data frames later in a loop such as ...

 for(i in 1:3) {
+ for(j in 1:nrow(auto.data.i)) {   ### this obviously does not work
since 'Error in nrow(auto.data.i) : object auto.data.i not found'
+ for(k in 1:ncol(auto.data.i)) {
+ auto.data.i[j,k] - 'some value'
+ }}}

Thanks a bunch for all your help.

Best, Michael


Michael Drescher
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
1235 Queen St East
Sault Ste Marie, ON, P6A 2E3
Tel: (705) 946-7406
Fax: (705) 946-2030

__
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] is.null doesn't work

2007-07-12 Thread Douglas Bates
On 7/12/07, Atte Tenkanen [EMAIL PROTECTED] wrote:

 Seems to work, if I unlist the argument at first ;-)

 Atte

  Hi,

  What's wrong here?:

   v=c(`-`,`+`,1,`^`,`^`,NA,NA,X,9,X,2)
   i2=16
   v[i2]
  [[1]]
  NULL

   is.null(v[i2])
  [1] FALSE

  Is it a bug or have I misunderstood something?

v[2] is a list with a single element which happens to be NULL.
v[[2]], on the other hand, is NULL.

A subset of a list, obtained with [, is a list.  An element of a
list, obtained with [[, is the native type of that element.

  Atte Tenkanen
  University of Turku, Finland
 

 __
 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] sub-function default arguments

2007-07-12 Thread Talbot Katz
Hi.

I have defined a function, f1, that calls another function, f2.  Inside f1 
an intermediate variable called nm1 is created; it is a matrix.  f2 takes a 
matrix argument, and I defined f2 (schematically) as follows:

f2-function(nmArg1=nm1,...){nC-ncol(nmArg1); ... }

so that it expects nm1 as the default value of its argument.  f1 is defined 
(schematically) as:

f1-function(...){result1-f2(); ... }

When I ran f1 I got the following error message:

Error in ncol(nmArg1) : object nm1 not found.

If I redefine f1 schematically as:

f1-function(...){result1-f2(nmArg1=nm1); ... }

it runs okay.  If I have nm1 defined outside of f1 and I run result1-f2() 
it also runs okay.  So f2 doesn't seem to pick up the default argument value 
inside the function f1, even when the default argument is defined inside f1. 
  Is there a way to have the subfunction default arguments recognized inside 
of a function (perhaps a better protocol for using defaults than what I 
did?), or do I just have to spell them out explicitly?

Thanks!

--  TMK  --
212-460-5430home
917-656-5351cell

__
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] sub-function default arguments

2007-07-12 Thread Duncan Murdoch
On 12/07/2007 7:23 PM, Talbot Katz wrote:
 Hi.
 
 I have defined a function, f1, that calls another function, f2.  Inside f1 
 an intermediate variable called nm1 is created; it is a matrix.  f2 takes a 
 matrix argument, and I defined f2 (schematically) as follows:
 
 f2-function(nmArg1=nm1,...){nC-ncol(nmArg1); ... }
 
 so that it expects nm1 as the default value of its argument.  f1 is defined 
 (schematically) as:
 
 f1-function(...){result1-f2(); ... }
 
 When I ran f1 I got the following error message:
 
 Error in ncol(nmArg1) : object nm1 not found.
 
 If I redefine f1 schematically as:
 
 f1-function(...){result1-f2(nmArg1=nm1); ... }
 
 it runs okay.  If I have nm1 defined outside of f1 and I run result1-f2() 
 it also runs okay.  So f2 doesn't seem to pick up the default argument value 
 inside the function f1, even when the default argument is defined inside f1. 
   Is there a way to have the subfunction default arguments recognized inside 
 of a function (perhaps a better protocol for using defaults than what I 
 did?), or do I just have to spell them out explicitly?

Defaults to arguments are evaluated in the evaluation frame of the 
function being called, f2 in your case.  Since nm1 is meaningless within 
f2, you get the error.

If you want nm1 to be meaningful within f2, you could define f2 within 
f1, e.g.

f1-function(...){
   nm1 - something
   f2 - function (...) {}
   result1-f2(nmArg1=nm1)
   ...
}

(which is the best way to do it), or you could explicitly manipulate the 
environment of f2 (which is an ugly way), or you could store nm1 in some 
place that's visible to both f1 and f2 and use - when you set it from 
within f1 (another ugly way, but sometimes less ugly than my second 
suggestion).

Duncan Murdoch

__
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] (no subject)

2007-07-12 Thread jim holtman
Is this what you want to do:

 auto.length - c(12,15,6)
 for(i in 1:3) {
+ nam - paste(auto.data,i, sep=.)
+ assign(nam, as.data.frame(matrix(1:auto.length[i], ncol=3)))
+ }
 auto.data.1
  V1 V2 V3
1  1  5  9
2  2  6 10
3  3  7 11
4  4  8 12
 auto.data.2
  V1 V2 V3
1  1  6 11
2  2  7 12
3  3  8 13
4  4  9 14
5  5 10 15
 # output the data
 for(i in 1:3){
+ cat(x - paste('auto.data.', i, sep=''), '\n')
+ print(get(x))
+ }
auto.data.1
  V1 V2 V3
1  1  5  9
2  2  6 10
3  3  7 11
4  4  8 12
auto.data.2
  V1 V2 V3
1  1  6 11
2  2  7 12
3  3  8 13
4  4  9 14
5  5 10 15
auto.data.3
  V1 V2 V3
1  1  3  5
2  2  4  6



On 7/12/07, Drescher, Michael (MNR) [EMAIL PROTECTED] wrote:
 Hi All,

 I want to automatically generate a number of data frames, each with an
 automatically generated name and an automatically generated number of
 rows. The number of rows has been calculated before and is different for
 all data frames (e.g. c(4,5,2)). The number of columns is known a priori
 and the same for all data frames (e.g. c(3,3,3)). The resulting data
 frames could look something like this:

  auto.data.1
  X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0

  auto.data.2
  X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0
 5  0  0  0

  auto.data.3
  X1 X2 X3
 1  0  0  0
 2  0  0  0

 Later, I want to fill the elements of the data frames with values read
 from somewhere else, automatically looping through the previously
 generated data frames.

 I know that I can automatically generate variables with the right number
 of elements with something like this:

  auto.length - c(12,15,6)
  for(i in 1:3) {
 + nam - paste(auto.data,i, sep=.)
 + assign(nam, 1:auto.length[i])
 + }
  auto.data.1
  [1]  1  2  3  4  5  6  7  8  9 10 11 12
  auto.data.2
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
  auto.data.3
 [1]  1 2 3 4 5 6

 But how do I turn these variables into data frames or give them any
 dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
 not seem to work. I also seem not to be able to access the variables
 with something like auto.data.i since:

  auto.data.i
 Error: object auto.data.i not found

 Thus, how would I be able to automatically write to the elements of the
 data frames later in a loop such as ...

  for(i in 1:3) {
 + for(j in 1:nrow(auto.data.i)) {   ### this obviously does not work
 since 'Error in nrow(auto.data.i) : object auto.data.i not found'
 + for(k in 1:ncol(auto.data.i)) {
 + auto.data.i[j,k] - 'some value'
 + }}}

 Thanks a bunch for all your help.

 Best, Michael


 Michael Drescher
 Ontario Forest Research Institute
 Ontario Ministry of Natural Resources
 1235 Queen St East
 Sault Ste Marie, ON, P6A 2E3
 Tel: (705) 946-7406
 Fax: (705) 946-2030

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



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

What is the problem you are trying to solve?

__
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] is.null doesn't work

2007-07-12 Thread jim holtman
'v' appears to be a list:

  v=c(`-`,`+`,1,`^`,`^`,NA,NA,X,9,X,2)
  i2=16
  v[i2]
[[1]]
NULL

 str(v)
List of 11
 $ :function (e1, e2)
 $ :function (e1, e2)
 $ : num 1
 $ :function (e1, e2)
 $ :function (e1, e2)
 $ : logi NA
 $ : logi NA
 $ : chr X
 $ : num 9
 $ : chr X
 $ : num 2

because you used backquotes(`) on the '-'; notice the difference:

 str(c(`-`,1))
List of 2
 $ :function (e1, e2)
 $ : num 1
 str(c('-',1))
 chr [1:2] - 1





On 7/12/07, Atte Tenkanen [EMAIL PROTECTED] wrote:
 Hi,

 What's wrong here?:

  v=c(`-`,`+`,1,`^`,`^`,NA,NA,X,9,X,2)
  i2=16
  v[i2]
 [[1]]
 NULL

  is.null(v[i2])
 [1] FALSE

 Is it a bug or have I misunderstood something?

 Atte Tenkanen
 University of Turku, Finland

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



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

What is the problem you are trying to solve?

__
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] automatically generating and accessing data frames of varying dimensions

2007-07-12 Thread Gabor Grothendieck
Its desirable to put the data frames into a list so they can be easily
iterated over in the future.  Try this:

auto.length - 2:4 # replace with desired row lengths
f - function(names, nr) {
x - rep(0, nr)
data.frame(X1 = x, X2 = x, X3 = x)
}
auto.names - paste(auto.data, seq_along(auto.length), sep = .)
mapply(f, auto.names, auto.length, SIMPLIFY = FALSE)


On 7/12/07, Drescher, Michael (MNR) [EMAIL PROTECTED] wrote:
 Hi All,

 I want to automatically generate a number of data frames, each with an
 automatically generated name and an automatically generated number of
 rows. The number of rows has been calculated before and is different for
 all data frames (e.g. c(4,5,2)). The number of columns is known a priori
 and the same for all data frames (e.g. c(3,3,3)). The resulting data
 frames could look something like this:

  auto.data.1
  X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0

  auto.data.2
  X1 X2 X3
 1  0  0  0
 2  0  0  0
 3  0  0  0
 4  0  0  0
 5  0  0  0

  auto.data.3
  X1 X2 X3
 1  0  0  0
 2  0  0  0

 Later, I want to fill the elements of the data frames with values read
 from somewhere else, automatically looping through the previously
 generated data frames.

 I know that I can automatically generate variables with the right number
 of elements with something like this:

  auto.length - c(12,15,6)
  for(i in 1:3) {
 + nam - paste(auto.data,i, sep=.)
 + assign(nam, 1:auto.length[i])
 + }
  auto.data.1
  [1]  1  2  3  4  5  6  7  8  9 10 11 12
  auto.data.2
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
  auto.data.3
 [1]  1 2 3 4 5 6

 But how do I turn these variables into data frames or give them any
 dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
 not seem to work. I also seem not to be able to access the variables
 with something like auto.data.i since:

  auto.data.i
 Error: object auto.data.i not found

 Thus, how would I be able to automatically write to the elements of the
 data frames later in a loop such as ...

  for(i in 1:3) {
 + for(j in 1:nrow(auto.data.i)) {   ### this obviously does not work
 since 'Error in nrow(auto.data.i) : object auto.data.i not found'
 + for(k in 1:ncol(auto.data.i)) {
 + auto.data.i[j,k] - 'some value'
 + }}}

 Thanks a bunch for all your help.

 Best, Michael


 Michael Drescher
 Ontario Forest Research Institute
 Ontario Ministry of Natural Resources
 1235 Queen St East
 Sault Ste Marie, ON, P6A 2E3
 Tel: (705) 946-7406
 Fax: (705) 946-2030

 __
 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] R and HTTP get 'has file changed'

2007-07-12 Thread Dirk Eddelbuettel

Is there a way, maybe using Duncan TL's RCurl, to efficiently test whether
an URL such as 

http://$CRAN/src/contrib/ 

has changed?  I.e. one way is via a test of a page in that directory as per
(sorry about the long line, and this would be on Linux with links and awk
installed)

strptime(system(links -width 160 -dump 
http://cran.r-project.org/src/contrib/ | awk '/PACKAGES.html/ {print $3,$4}\', 
intern=TRUE), %d-%b-%Y %H:%M)
   [1] 2007-07-12 18:16:00


and one can then compare the POSIXt with a cached value --- but requesting
the header would presumably be more efficient.

Is there are way to request the 'has changed' part of the http 1.1 spe
directly in R?

Thanks, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
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] R and HTTP get 'has file changed'

2007-07-12 Thread Seth Falcon
Hi Dirk,

Dirk Eddelbuettel [EMAIL PROTECTED] writes:
 Is there a way, maybe using Duncan TL's RCurl, to efficiently test whether
 an URL such as 

   http://$CRAN/src/contrib/ 

 has changed?  I.e. one way is via a test of a page in that directory as per
 (sorry about the long line, and this would be on Linux with links and awk
 installed)

 strptime(system(links -width 160 -dump 
 http://cran.r-project.org/src/contrib/ | awk '/PACKAGES.html/ {print 
 $3,$4}\', intern=TRUE), %d-%b-%Y %H:%M)
[1] 2007-07-12 18:16:00
 

 and one can then compare the POSIXt with a cached value --- but requesting
 the header would presumably be more efficient.

 Is there are way to request the 'has changed' part of the http 1.1 spe
 directly in R?

Here's a way to use RCurl obtain HTTP headers:

h - basicTextGatherer()
junk - getURI(url, writeheader=h$update, header=TRUE, nobody=TRUE)
h - h$value()

If you want to check many URLs, I think you will find the following
much faster as opposed to looping the above:

h - multiTextGatherer(urls)
junk - getURIAsynchronous(urls, write=h, header=TRUE, nobody=TRUE)
yourInfo - sapply(h, function(x) something(x$value()))

I've used this in the pkgDepTools package to retrieve package download
sizes.

Cheers,

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
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] R and HTTP get 'has file changed'

2007-07-12 Thread Dirk Eddelbuettel

On 12 July 2007 at 19:46, Seth Falcon wrote:
| Hi Dirk,
| 
| Dirk Eddelbuettel [EMAIL PROTECTED] writes:
|  Is there a way, maybe using Duncan TL's RCurl, to efficiently test whether
|  an URL such as 
| 
|  http://$CRAN/src/contrib/ 
| 
|  has changed?  I.e. one way is via a test of a page in that directory as per
|  (sorry about the long line, and this would be on Linux with links and awk
|  installed)
| 
|  strptime(system(links -width 160 -dump 
http://cran.r-project.org/src/contrib/ | awk '/PACKAGES.html/ {print $3,$4}\', 
intern=TRUE), %d-%b-%Y %H:%M)
| [1] 2007-07-12 18:16:00
|  
| 
|  and one can then compare the POSIXt with a cached value --- but requesting
|  the header would presumably be more efficient.
| 
|  Is there are way to request the 'has changed' part of the http 1.1 spe
|  directly in R?
| 
| Here's a way to use RCurl obtain HTTP headers:
| 
| h - basicTextGatherer()
| junk - getURI(url, writeheader=h$update, header=TRUE, nobody=TRUE)
| h - h$value()

Sweet:

 library(RCurl)
 h - basicTextGatherer()
 junk - getURI(http://cran.r-project.org/src/contrib/PACKAGES.html;, 
 writeheader=h$update, header=TRUE, nobody=TRUE)
 h - h$value()
 h
[1] HTTP/1.1 200 OK\r\nDate: Fri, 13 Jul 2007 02:58:03 GMT\r\nServer: 
Apache/2.2.3 (Debian)\r\nLast-Modified: Thu, 12 Jul 2007 16:16:08 GMT\r\nETag: 
\a7c11e-21f34-4fe68200\\r\nAccept-Ranges: bytes\r\nContent-Length: 
139060\r\nContent-Type: text/html\r\n\r\n
 

So I can just filter the Date and Last-Modified fields from here, without
having to worry the particular header request. Nice!

| If you want to check many URLs, I think you will find the following

I don't. I just want something 'light and easy' as the script (to feed
CRANberries) may get run a few times from crontan and should stop early if
no new data will be there to be processed.

Thanks!

Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
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] ICC

2007-07-12 Thread Luka Ležaić
Hello all.

I'm working on a PhD thesis analyzing reproducibility/repeatability of a
nuclear medicine examination. I have two sets of data (50 patients each)
and 3 observers. In each case (patient), two variables are evaluated,
first with a range of 0..100 and second 1..3. Each case is also evaluated
twice by each observer (for additional intraobserver reproducibility).

I'm using R package psy to calculate ICC (the other method I'm using is
repeatability). My question with ICC is: how do I evaluate if the
difference between observers (and patient groups) is statistically
significant?

I have been searching through the R archives, but I haven't been able to
find an answer.

Thank you,

Luka Lezaic


-- 
Nobody is perfect. My name is nobody.


-
This mail was scanned by BitDefender
For more informations please visit http://www.bitdefender.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] imposing constraints on the covariance matrix of random effects in lme4?

2007-07-12 Thread JVVerkuilen
Hello all,

I am using lme4 to fit some mixed logistic regressions. I need to
impose an identification constraint of the following form:

(1sig12)
(sig12  sig22)

and have not figured out how to do it, i.e., sig11 = 1 but the rest of
the parameters are free to vary. Is this possible and, if so, how?

I've been looking through the archive and help to no avail, but
perhaps I'm just missing something.

Thanks for any help,

Jay
-- 
JVVerkuilen. PhD
[EMAIL PROTECTED]

If you've been playing poker for half an hour and you still don't
know who the patsy is, you're the patsy. --Warren Buffett

__
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] automatically generating and accessing data frames of varyingdimensions

2007-07-12 Thread Bill.Venables
I'm not sure why you want to do it this way (it would probably help if
we had a more complete picture of what you were really trying to do, but
here are a few possibilities for the questions you ask.

1. generating data frames.

rw - c(4,5,2)
cl - c(3,3,3)

for(i in 1:length(rw))
assign(paste(auto.data, i, sep=.),
as.data.frame(array(0, dim=c(rw[i], cl[i]), 
dimnames = list(NULL, paste(X, 1:cl[i],
sep=)

check: 

 auto.data.1
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0
 auto.data.2
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0
5  0  0  0
 auto.data.3
  X1 X2 X3
1  0  0  0
2  0  0  0

2. filling them up (... are you sure you want to do it this way?)

The simplest way is probably through an intermediary

for(nam in paste(auto.data, 1:3, sep=.)) { # loop over the names
  tmp - get(nam)
  for(i in 1:nrow(tmp))
for(j in 1:ncol(tmp))
  tmp[i, j] - i+j-i*j # 'some value'
  assign(nam, tmp)
  rm(tmp)
}

check:

 auto.data.1
  X1 X2 X3
1  1  1  1
2  1  0 -1
3  1 -1 -3
4  1 -2 -5
 auto.data.2
  X1 X2 X3
1  1  1  1
2  1  0 -1
3  1 -1 -3
4  1 -2 -5
5  1 -3 -7
 auto.data.3
  X1 X2 X3
1  1  1  1
2  1  0 -1
 

It may work, but I have to say, though, I'm almost sure this is a
mistake.  There has to be a better way using the facilities that R
provides for avoiding heavy loops like this.

Just a hunch...

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Drescher, Michael
(MNR)
Sent: Friday, 13 July 2007 9:19 AM
To: r-help@stat.math.ethz.ch
Subject: [R] automatically generating and accessing data frames of
varyingdimensions

Hi All,

I want to automatically generate a number of data frames, each with an
automatically generated name and an automatically generated number of
rows. The number of rows has been calculated before and is different for
all data frames (e.g. c(4,5,2)). The number of columns is known a priori
and the same for all data frames (e.g. c(3,3,3)). The resulting data
frames could look something like this:

 auto.data.1
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0

 auto.data.2
  X1 X2 X3
1  0  0  0
2  0  0  0
3  0  0  0
4  0  0  0
5  0  0  0

 auto.data.3
  X1 X2 X3
1  0  0  0
2  0  0  0

Later, I want to fill the elements of the data frames with values read
from somewhere else, automatically looping through the previously
generated data frames.

I know that I can automatically generate variables with the right number
of elements with something like this:

 auto.length - c(12,15,6)
 for(i in 1:3) {
+ nam - paste(auto.data,i, sep=.)
+ assign(nam, 1:auto.length[i])
+ }
 auto.data.1
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 auto.data.2
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
 auto.data.3
[1]  1 2 3 4 5 6

But how do I turn these variables into data frames or give them any
dimensions? Any commands such as 'as.matrix', 'data.frame', or 'dim' do
not seem to work. I also seem not to be able to access the variables
with something like auto.data.i since:

 auto.data.i
Error: object auto.data.i not found

Thus, how would I be able to automatically write to the elements of the
data frames later in a loop such as ...

 for(i in 1:3) {
+ for(j in 1:nrow(auto.data.i)) {   ### this obviously does not work
since 'Error in nrow(auto.data.i) : object auto.data.i not found'
+ for(k in 1:ncol(auto.data.i)) {
+ auto.data.i[j,k] - 'some value'
+ }}}

Thanks a bunch for all your help.

Best, Michael


Michael Drescher
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
1235 Queen St East
Sault Ste Marie, ON, P6A 2E3
Tel: (705) 946-7406
Fax: (705) 946-2030

__
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] legend and x,y cordinate values

2007-07-12 Thread Ajay Singh
Hi,

I have two problems in R.

1. I need 10 cdfs on a graph, the graph needs to have legend. Can you let 
me know how to get legend on the graph?

2. In ecdf plot, I need to know the x and y co-ordinates. I have to get 
corresponding y coordinate values to x coordinate value so that I could be 
able to know the particular percentile value to the x-coordinate value. 
Can you let me know how could I be able the corresponding values of x to 
the y coordinates?

Thanking you,
Looking forward to your kind response,
Sincerely,
Ajay.
-- 
Ajay Singh
Research Scientist,
SOM, IIT-Bombay, Powai,
MUMBAI-400076, MH (INDIA).

__
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] JRI problem on 64bit Linux

2007-07-12 Thread Prof Brian Ripley
Our experience (and that of several others) is that you need Java 1.6 on 
x86_64 Linux for any of the JNI-using R packages to work correctly.  E.g. 
the CRAN check machine is using 1.6.

On Thu, 12 Jul 2007, chuckanut wrote:

 Sorry if this isn't the correct list, but I couldn't find any mailing
 lists on the JRI site.

Please see the posting guide: that asks you to ask the maintainer (who 
knows about the problems).

 I am able to install JRI on a 32 bin linux
 machine without any problem, but I am unable to isntall on a 64 bit
 machine.  I have R installed with the correct option, R_HOME is set up
 and libR.so is in there.  However, I get the following error when
 running ./configure, any help is appreciated

You need to read config.log: we can't read it for you as it is on your 
machine.

 checking build system type... x86_64-unknown-linux-gnu
 checking host system type... x86_64-unknown-linux-gnu
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ANSI C... none needed
 checking how to run the C preprocessor... gcc -E
 checking for egrep... grep -E
 checking for ANSI C header files... yes
 checking for java... /usr/java/jdk1.5.0_11/bin/java
 checking for javac... /usr/java/jdk1.5.0_11/bin/javac
 checking for javah... /usr/java/jdk1.5.0_11/bin/javah
 checking for jar... /usr/java/jdk1.5.0_11/bin/jar
 checking whether Java interpreter works... yes
 checking for Java environment... in /usr/java/jdk1.5.0_11
 checking for /usr/java/jdk1.5.0_11/include/jni.h... yes
 checking for /usr/java/jdk1.5.0_11/include/./jni_md.h... no
 checking for /usr/java/jdk1.5.0_11/include/linux/jni_md.h... yes
 checking whether JNI programs can be compiled... configure: error:
 Cannot compile a simple JNI program. See config.log for details.
^^

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