[R] prediction interval for multiple future observations

2007-08-21 Thread Vlad Skvortsov
Hi!

'?predict.lm' says that the prediction intervals returned by predict() 
are for single observation only. Is there a way to specify the desired 
number of observations to construct the interval for?

R version 2.4.1 (2006-12-18)

-- 
Vlad Skvortsov, [EMAIL PROTECTED], http://vss.73rus.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] prediction interval for multiple future observations

2007-08-21 Thread Vladimir Eremeev



Vlad Skvortsov wrote:
 
 '?predict.lm' says that the prediction intervals returned by predict() 
 are for single observation only. Is there a way to specify the desired 
 number of observations to construct the interval for?
 

You can generate the desired sequence of new values using seq or sequence
and submit them to predict.lm in the newdata argument.
-- 
View this message in context: 
http://www.nabble.com/prediction-interval-for-multiple-future-observations-tf4303243.html#a12249044
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] rv package, rvnorm function

2007-08-21 Thread Gregor Gorjanc
John P. Burkett burkett at uri.edu writes:
 In an attempt to learn to use the rv package, I have been working
 through the examples in Jouni Kerman and Andrew Gelman's Using Random
 Variables to Manipulate and Summarize Simulations in R (July 4, 2007).

Perhaps Jouni can help you?

__
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] prediction interval for multiple future observations

2007-08-21 Thread Prof Brian Ripley
On Mon, 20 Aug 2007, Vlad Skvortsov wrote:

 Hi!

 '?predict.lm' says that the prediction intervals returned by predict()
 are for single observation only. Is there a way to specify the desired
 number of observations to construct the interval for?

What it says in full is

  The prediction intervals are for a single observation at each case
  in 'newdata' (or by default, the data used for the fit) with error
  variance(s) 'pred.var'.

I think you misunderstand: predict.lm returns a prediction interval for 
each row of 'newdata'.  The comment in part means that those intervals are 
to be considered individually, and not as a joint prediction region for 
all the future observations.  If you want, say, a prediction interval for 
the average of 10 indepedent observations at a case, use 'pred.var' to 
specify the error variance.

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


[R] R mailinglist ETH website now with trusted certificate

2007-08-21 Thread Martin Maechler
Some of you, notably I think users of MS Internet Explorer,
may be happy to learn that since yesterday,
the web server of the R mailing lists
https://stat.ethz.ch/
now runs an ``official'' / trusted certificate as opposed to the
inofficial one (Math deparment ETH) that we have had for years
instead.

In particular, this should make access to the (first but by far
not only) mailing list archives more convenient to you,
e.g. for this month, for R-help,
https://stat.ethz.ch/pipermail/r-help/2007-August/thread.html

In parallel, the R Foundation is getting (buying) certificates
for several R-project.org servers, notably also the subversion
(R source) server, and these will hopefully be put in place as
well with the next few weeks.

Martin Maechler,
ETH Zurich  R core

__
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] Ansari vs wilcoxon vs ks test

2007-08-21 Thread Niki
Hi all,

This is a statistics question, I hope someone out there will be able to help
me.

 

I have one population (oligonucleotide probes spotted on a Nimblegen array).


I measured parameter one (intensity after hybridisation) and I have
selected a subpopulation of the initial (one tenth of the initial) according
to a threshold value.

 

I now measure parameter two of the original population (GC content). The
distribution of the population for this value is roughly bell-shaped. 

I want to see if the subpopulation I selected in the previous step shares
the same characteristics with regards to the GC content with the entire
population or if selecting for parameter one has messed with parameter
two.

 

What I thought was to compare the distributions of this second attribute of
the two populations.

 

I believe that the ansari-bradley, wilcoxon and Kolmogorov-Smirnov tests
perform such tests but -after searching- I am not sure which is more
appropriate (if any).

I realize that ansari-bradley and ks are more sensitive to the actual shape
of the curve while wilcoxon focuses on testing for a shift of the median. I
can not figure out though what is the difference between ansari-bradley and
ks . Is there any important difference in the assumptions of these three
tests that I should consider before choosing?

 

Finally, and I apologize for the naivity of the question, all the ks.test(),
wilcox.test () and ansari.test() expect the raw measurements for the
populations and I do not need to pre-process  in any way, right?

 

ANY suggestion please?

 

Niki


[[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] Partial comparison in string vector

2007-08-21 Thread Vladimir Eremeev

Hi!

seq(along=x) %in% grep(e,x)



Steve Powell-4 wrote:
 
 I have a vector of strings
 x=c(w,ex,ee)
 And I want to get a logical vector showing the positions where my search
 string e matches the elements partially, i.e. is at least the left-hand
 part of the target strings, i.e. I want to get a vector FALSE TRUE TRUE.
 

-- 
View this message in context: 
http://www.nabble.com/Partial-comparison-in-string-vector-tf4304145.html#a12251593
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] Regulatory Computing with R

2007-08-21 Thread anthony . rossini
Dear all - 

Cody and Bert have some amusing points. 

The problems with R that Cody states are no different than those that any 
organization has with any programming work.  Period.

We've mostly solved them through appropriate approaches, addressing 
through quality management, some of the issues raised by Cody with respect 
to 3-rd party packages, etc. 

Quality Management != Absolute Quality.

It's about risk management, as David's presentation of our work at UseR 
hopefully explained. 

It's about common sense. 

Combined, this can result in reasonable statements like (real names used 
in artificial examples to make a point):

Martin M does X with R, I trust Martin, therefore I trust X done 
with R because the risk of wrong results in Y will have a low impact.

If Y happened to have an impact of $500m, then a reasonable approach might 
be to reconsider and find an additional expert, say Doug B, to confirm.

Alternatively, if you don't believe in expert opinions (or subjective 
probability, or mechanistic modeling), and feel like an empirical 
frequentist, you might just get a team of monkeys to verify that X in R 
seems correct, based on a project management strategy that incorporates 
someone's favorite IT risk mitigation approach.

With respect to Bert's points about 21CFR Part 11, please read the 
documents on the R WWW with respect to such things for a pretty informed 
opinion as to what is really happening.

I may not speak for Novartis, but it is possible that we'll be using a 
non-commercial version of R at some point in the future and we've been 
looking into the risk management strategies.   Some people are annoyed at 
the packages we will not let people use, but code review suggests that we 
really don't want people to use them (risk management, again).  The 
supporting infrastructure will be nice, but it'll also be a PITA to build.

But it really is just a matter of codification of common sense -- you 
should always put anything that you want to reproduce under version 
control, you should always have test cases to confirm that the 
implementations that you are using work in a few average cases (no one can 
cover every corner case) and you should make sure that you align your data 
and computer code with your reporting workflow. It's the 
implementation of common sense that seems to be hard, as most R-help 
readers should be aware of by now.  I can't claim to implement it all the 
time, as readers of this list are probably additionally aware.

Best regards / Mit freundlichen Grüssen, 
Anthony (Tony) Rossini
Novartis Pharma AG
MODELING  SIMULATION
Group Head a.i., -- EU Statistical Modeling
CHBS, WSJ-027.1.012
Novartis Pharma AG
Lichtstrasse 35
CH-4056 Basel
Switzerland
Phone: +41 61 324 4186
Fax: +41 61 324 3039
Cell: +41 79 367 4557 (to send an SMS from Lotus Notes put the following: 
[EMAIL PROTECTED] in the To box : - only the content of the 
subject is sent)
Email : [EMAIL PROTECTED]

[[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] Vectors in R (WAS Re: Does anyone.... worth a warning?!? No warning at all)

2007-08-21 Thread Stephen Tucker

Dear Ted (and community), 

You raise a very interesting point - namely, what should and should
not be called a vector in R (it's neither a class or mode,
formally). I don't know which version of the R Language Definition you
were quoting from, but mine (Version 2.5.1 DRAFT), says:

Vectors can be thought of as contiguous cells containing data.

(doesn't say homogeneous in the version that I have). In that sense
it's more analagous to 'lists' in Python, Scheme, etc. (with the
additional benefit that the names attribute for R vectors allows you
to use them also as 'dictionaries' or 'hash tables'), and less like
the 1-D array used in mathematics. (Incidentally, the array class in
Python is like the matrix and array classes in R, which do require
specification of row or column).

In any case, the quote above is more consistent with my understanding
of the basic data objects in R, as atomic vectors and lists are
both contiguous cells containing data, only that they differ in the
value of their mode attributes. I think it can be a bit confusing
when they are introduced separately (e.g., in the R Language
Definition document with headings, Vectors and Lists in section
2.1) - though I think its origin lies in the pedagogy of the
language. For instance, introductory documents often show off R as a
calculator and draw the analogy between the vector notation used in
mathematics and the application of +() [as an operator rather than a
function] on a pair of numeric vectors in R. This is probably due to
the background of the audience these documents are intended to address
(Python/Scheme, perhaps more computer science; R/S, more statistics or
mathematics perhaps). I think this is a bit unfortunate as students
can get stuck with the idea that there are (atomic) vectors, and then
another thing called a list - and then later he/she is told that a
list is a vector as well, and has to reconcile this new bit of
information - while conceptually they are similar except that a
certain set of functions (e.g., the arithemetic operators and string
functions) cannot be applied to vectors of mode list, but many other
functions (e.g., extraction, subsetting, replacement) can be applied
in the same way.

This article was very elucidating:

Statistical programming with R, Part 3: Reusable and object-oriented
programming
http://www.ibm.com/developerworks/linux/library/l-r3.html

In it, David Mertz says:

'The main thing to keep in mind about R data is that everything is a
vector. Even objects that look superficially distinct from vectors --
matrices, arrays, data.frames, etc. -- are really just vectors with
extra (mutable) attributes that tell [generic functions in] R to treat
them in special ways.'

So matrices, arrays, lists, data frames, (and even factors) are all
vectors (used henceforth in the sense of contiguous cells as are
lists in Python/Scheme), with additional attributes attached. When
these attributes are removed, print() will allow us to view them to us
as 1-D objects (a sequence of values; not necessarily a 1-D row or
column matrix).

One defining attribute besides mode and length is the class
attribute, which determines the dispatch method for a generic
function. For instance, the [() and [-() functions allow N-D
subscripting notation for matrix, array, and data.frame classes,
but as they are also still vectors (contiguous cells), and therefore
can be subscripted as stated, cells are accessed through indexing
operations such as x[5].

This is important in it that it allows one to use many functions not
immediately thought of as applicable to data frames (which is a list,
which is a vector, etc.
http://tolstoy.newcastle.edu.au/R/help/00b/2390.html); for me that
would be functions like append(), replace(), etc. For example:

 df - data.frame(a=1:5,c=11:15,d=16:20)
 append(df,list(b=6:10),1)
$a
[1] 1 2 3 4 5

$b
[1]  6  7  8  9 10

$c
[1] 11 12 13 14 15

$d
[1] 16 17 18 19 20

 replace(df,c(FALSE,TRUE,FALSE),list(b=21:25))
  a  c  d
1 1 21 16
2 2 22 17
3 3 23 18
4 4 24 19
5 5 25 20

append() returns a list because c() is invoked internally, and this
removes all extra attributes except names (including class,
row.names, etc.). So, retaining the intrinsic mode list, the
append function returns a class list object by default ['If the
object does not have a class attribute, it has an implicit class,
matrix, array or the result of mode(x)', says ?class] when applied
to a data frame.

On the other hand, replace() still returns a data frame because only
[.-data.frame() is invoked so the returned object retains the class
of data.frame.

Even factors, which fails the is.vector() test, are actually vectors
(IMHO). The R Language definition says, 

Factors are currently implemented using an integer array [which is a
vector] to specify the actual levels and a second array of names [in
the levels attribute] that are mapped to the integers.

As an example, the following behavior is also predictable in that if
we know how each function 

[R] Stacked Bar

2007-08-21 Thread Deb Midya
Hi R Users!
 
Thanks in advance.
 
I am using R-2.5.1 on Windows XP.
 
I am trying to do a stacked bar plot, but could not get through the following 
problem. The code is given below.
   
  1. How can I provide 15 different colors for each method with 15 Rows?
   
  2. How can I put the legend in a particular position (eg., in the top or 
bottom or right or left)? How can I put legend using a number of rows (eg., 
using two or three rows)? 
  
Once again thank you very much for your time.
 
Regards,
 
Debabrata (Deb)
Statistician
NSW Department of CommerceSydney, Australia.

  The Code:
   
  library(lattice)
library(graphics)
   
  x - matrix(1:75, ncol= 5)
dimnames(x)[[2]] - paste(Method, 1:5, sep=)
dimnames(x)[[1]] - paste(Row, 1:15, sep=)
   
  # library: graphics
   
  barplot(x,
beside=FALSE,
col= 1:nrow(x),
legend= rownames(x)
   )
   
  # library: lattice
   
  barchart(Freq ~ Var2,
 data = as.data.frame.table(x),
 groups = Var1, stack = TRUE,
 auto.key = TRUE)
   

   
-
Park yourself in front of a world of choices in alternative vehicles.

[[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] Ask for functions to obtain partial R-square (squared partial correlation coefficients)

2007-08-21 Thread Xingwang Ye
Many thanks to Frank. The anova.Design function is advanced and very 
powerful. Sometimes, I want to get the PCORR2 and SCORR2, any 
functions available now in R packages?


Frank E Harrell Jr wrote:
 Ye Xingwang wrote:
 The partial R-square (or coefficient of partial determination, or
 squared partial correlation coefficients) measures the marginal
 contribution of one explanatory variable when all others are already
 included in multiple linear regression model.

 The following link has very clear explanations on partial and
 semi-partial correlation:
 http://www.psy.jhu.edu/~ashelton/courses/stats315/week2.pdf

 In SAS, the options is PCORR2 and SCORR2.
 For example(from 
 http://www.ats.ucla.edu/stat/sas/examples/alsm/alsmsasch7.htm)

 data ch7tab01;
   input X1 X2 X3 Y;
   label x1 = 'Triceps'
 x2 = 'Thigh cir.'
 x3 = 'Midarm cir.'
  y = 'body fat';
   cards;
   19.5  43.1  29.1  11.9
   24.7  49.8  28.2  22.8
   30.7  51.9  37.0  18.7
   29.8  54.3  31.1  20.1
   19.1  42.2  30.9  12.9
   25.6  53.9  23.7  21.7
   31.4  58.5  27.6  27.1
   27.9  52.1  30.6  25.4
   22.1  49.9  23.2  21.3
   25.5  53.5  24.8  19.3
   31.1  56.6  30.0  25.4
   30.4  56.7  28.3  27.2
   18.7  46.5  23.0  11.7
   19.7  44.2  28.6  17.8
   14.6  42.7  21.3  12.8
   29.5  54.4  30.1  23.9
   27.7  55.3  25.7  22.6
   30.2  58.6  24.6  25.4
   22.7  48.2  27.1  14.8
   25.2  51.0  27.5  21.1
 ;
 run;

 proc reg data = ch7tab01;
   model y = x1 x2 / pcorr2 SCORR2;
   model y = x1-x3 / pcorr2 SCORR2;
 run;
 quit;

 There has been a post in
 http://tolstoy.newcastle.edu.au/R/help/05/03/0437.html

 It will be great appreciated if someone could write a general function
 to work with class lm or glm to obtain the
 pcorr2 (squared partial correlation coefficients using Type II sums 
 of squares)
 and scorr2 (squared semi-partial correlation coefficients using Type
 II sums of squares)
 for all independent variables (3 variables) simultaneously?

 Thank you.
 Xingwang Ye


 library(Design)  # requires Hmisc
 f - ols(y ~ x1 + x2)
 p - plot(anova(f), what='partial R2')
 p

 The anova.Design function called above handles pooling related degrees 
 of freedom and pools main effects with related interaction effects to 
 get the total partial effect.

 Frank



__
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] Stacked Bar

2007-08-21 Thread Jim Lemon
Deb Midya wrote:
 Hi R Users!
  
 Thanks in advance.
  
 I am using R-2.5.1 on Windows XP.
  
 I am trying to do a stacked bar plot, but could not get through the following 
 problem. The code is given below.

   1. How can I provide 15 different colors for each method with 15 Rows?

   2. How can I put the legend in a particular position (eg., in the top or 
 bottom or right or left)? How can I put legend using a number of rows (eg., 
 using two or three rows)? 
   
Hi Deb,
As you have probably noticed, the integer coded colors repeat too 
quickly for the number of colors you want. You can use the rainbow()
function to generate colors like this:

barplot(x,beside=FALSE,col=rainbow(nrow(x)))

or there are lots of other color generating functions in the grDevices 
or plotrix packages. Here's how to get your legend in an empty space for 
your plot. There is also an emptyspace() function in the plotrix package 
that tries to find the biggest empty space in a plot, although it 
probably wouldn't work in this case.

legend(0,1000,rownames(x),fill=rainbow(nrow(x)))

Jim

__
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] runing .r file from C#

2007-08-21 Thread Alex MD
 Hi,

 I know that the general subject calling R from C has been discused but I
have been reading the manuals and also scouting the lists and I can not seam
to find
a working solution for my problem.
  I want to call a R script ( let's call it test.r ) from within C# code.
  After reading about this topic I am trying to do this :

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = E:/R/R-2.5.1 /bin/Rterm.exe;
proc.StartInfo.Arguments =  'test.r' --no-save;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();


bun when Rterm starts it shows parameter test.r ignored

When I try to do the same from a command line shell it DOES work just fine :
 Rterm.exe test.r --no-save  runs the file without any problems.

 Do you have any idea how to make it not to ignore the input file? Or is
there other way to just execute a .r file from C# code?

 Thank you very much,
Alex

-- 
Alexandru Maruseac
BEST Bucharest
E-mail: [EMAIL PROTECTED]
Tel:+40 0722 329 083
www.BEST.eu.org
www.BESTBc.pub.ro

[[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] Stacked Bar

2007-08-21 Thread Deb Midya
Jim,
   
  Thanks for such a quick response. It works well. Is it possible to fill the 
bars with patterns and colours?
   
  Regards,
   
  Deb

Jim Lemon [EMAIL PROTECTED] wrote:
  Deb Midya wrote:
 Hi R Users!
 
 Thanks in advance.
 
 I am using R-2.5.1 on Windows XP.
 
 I am trying to do a stacked bar plot, but could not get through the following 
 problem. The code is given below.
 
 1. How can I provide 15 different colors for each method with 15 Rows?
 
 2. How can I put the legend in a particular position (eg., in the top or 
 bottom or right or left)? How can I put legend using a number of rows (eg., 
 using two or three rows)? 
 
Hi Deb,
As you have probably noticed, the integer coded colors repeat too 
quickly for the number of colors you want. You can use the rainbow()
function to generate colors like this:

barplot(x,beside=FALSE,col=rainbow(nrow(x)))

or there are lots of other color generating functions in the grDevices 
or plotrix packages. Here's how to get your legend in an empty space for 
your plot. There is also an emptyspace() function in the plotrix package 
that tries to find the biggest empty space in a plot, although it 
probably wouldn't work in this case.

legend(0,1000,rownames(x),fill=rainbow(nrow(x)))

Jim



   
-

[[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] library(fCalendar) timeDate(12.03.2005, format=%d.%m.%Y)

2007-08-21 Thread Ola Lindqvist
Thanks!
Seems to work fine now!

Regards,
Ola


Martin Becker wrote:
 Dear Ola,

 I think you spotted a small bug in *package* fCalendar.
 Explicit specification should prevent autodetection of the date 
 format, which is not the case for fCalendar v251.70, instead 
 autodetection is done at least once (twice, if actually appropriate).
 With the following patch, things should work ok:

 diff --recursive fCalendar.orig/R/3A-TimeDateClass.R 
 fCalendar/R/3A-TimeDateClass.R
 433c433
  charvec = format(strptime(charvec, .whichFormat(charvec)), 
 isoFormat)
 ---
  charvec = format(strptime(charvec, format), isoFormat)

 You did not provide the output of sessionInfo() (which you are asked 
 for in the posting guide). If you are using Windows and don't know how 
 to apply the patch, you can download a patched binary version here:
 http://www.saar-gate.net/download/fCalendar_251.70.zip

 Regards,

   Martin

 PS: Maybe r-sig-finance is more appropriate for questions concerning 
 Rmetrics.


 Ola Lindqvist wrote:
 Dear R users,
 I have problem with the library fCalendar.

 I am not using the US standard format notations. It seems like it is 
 not possible to have different format than the US standards.
 Anyone how knows a way to go around this problem?

 Here is the code I enter:
 myDate = 12.03.2005
 timeDate(myDate, format = %d.%m.%Y)

 And I get following error message:
 Error in if (sum(lt$sec + lt$min + lt$hour) == 0) isoFormat = 
 %Y-%m-%d :
 missing value where TRUE/FALSE needed

 Thanks,
 Ola

 __
 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] Stacked Bar

2007-08-21 Thread Stephen Tucker
I think you want to use the 'density' argument. For example:

barplot(1:5,col=1)
legend(topleft,fill=1,legend=text,cex=1.2)
par(new=TRUE)
barplot(1:5,density=5,col=2)
legend(topleft,fill=2,density=20,legend=text,bty=n,cex=1.2)

(if you wanted to overlay solid colors with hatching)

Here's the lattice alternative of the bar graph, though the help page says
'density' is currently unimplemented (Package lattice version 0.16-2). To get
the legend into columns, I followed the suggestion described here:
http://tolstoy.newcastle.edu.au/R/help/05/04/2529.html

Essentially I use mapply() and the line following to create a list with
alternating 'text' and 'rect' arguments (3 times to get 3 columns).
===
x - matrix(1:75, ncol= 5)
dimnames(x)[[2]] - paste(Method, 1:5, sep=)
dimnames(x)[[1]] - paste(Row, 1:15, sep=)

u - mapply(function(x,y) list(text=list(lab=x),rect=list(col=y)),
x = as.data.frame(matrix(levels(as.data.frame.table(x)$Var1),
  ncol=3)),
y = as.data.frame(matrix(rainbow(nrow(x)),
  ncol=3)),
SIMPLIFY=FALSE)
key - c(rep=FALSE,space=bottom,unlist(names-(u,NULL),rec=FALSE))

barchart(Freq ~ Var2,
 data = as.data.frame.table(x),
 groups = Var1, stack = TRUE,
 col=rainbow(nrow(x)),density=5,
 key = key )
===
(I often use tim.colors() in the 'fields' package, if you wanted other ideas
for color schemes).



--- Deb Midya [EMAIL PROTECTED] wrote:

 Jim,

   Thanks for such a quick response. It works well. Is it possible to fill
 the bars with patterns and colours?

   Regards,

   Deb
 
 Jim Lemon [EMAIL PROTECTED] wrote:
   Deb Midya wrote:
  Hi R Users!
  
  Thanks in advance.
  
  I am using R-2.5.1 on Windows XP.
  
  I am trying to do a stacked bar plot, but could not get through the
 following problem. The code is given below.
  
  1. How can I provide 15 different colors for each method with 15 Rows?
  
  2. How can I put the legend in a particular position (eg., in the top or
 bottom or right or left)? How can I put legend using a number of rows (eg.,
 using two or three rows)? 
  
 Hi Deb,
 As you have probably noticed, the integer coded colors repeat too 
 quickly for the number of colors you want. You can use the rainbow()
 function to generate colors like this:
 
 barplot(x,beside=FALSE,col=rainbow(nrow(x)))
 
 or there are lots of other color generating functions in the grDevices 
 or plotrix packages. Here's how to get your legend in an empty space for 
 your plot. There is also an emptyspace() function in the plotrix package 
 that tries to find the biggest empty space in a plot, although it 
 probably wouldn't work in this case.
 
 legend(0,1000,rownames(x),fill=rainbow(nrow(x)))
 
 Jim
 
 
 

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



   


Comedy with an Edge to see what's on, when.

__
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] runing .r file from C#

2007-08-21 Thread Prof Brian Ripley
On Tue, 21 Aug 2007, Alex MD wrote:

 Hi,

 I know that the general subject calling R from C has been discused but I
 have been reading the manuals and also scouting the lists and I can not seam
 to find
 a working solution for my problem.

It's a C# issue.

  I want to call a R script ( let's call it test.r ) from within C# code.
  After reading about this topic I am trying to do this :

 System.Diagnostics.Process proc = new System.Diagnostics.Process();
 proc.StartInfo.FileName = E:/R/R-2.5.1 /bin/Rterm.exe;
 proc.StartInfo.Arguments =  'test.r' --no-save;
 proc.StartInfo.UseShellExecute = false;
 proc.StartInfo.RedirectStandardOutput = false;
 proc.Start();


 bun when Rterm starts it shows parameter test.r ignored

 When I try to do the same from a command line shell it DOES work just fine :
  Rterm.exe test.r --no-save  runs the file without any problems.

 Do you have any idea how to make it not to ignore the input file? Or is
 there other way to just execute a .r file from C# code?

You need a shell for redirection (  |) to work, and 'system' commands in 
Windows do not usually use one (as in C, C++, R, Perl): you seem to have 
turned off using a shell in C#.  However, I think you should be using 
RScript.exe, where this is not an issue.

-- 
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] runing .r file from C#

2007-08-21 Thread Alex MD
  Thank you very much for your help. It did work.  So here is the code that
I've used case anybody else is seaching for an answer to this
problem :


System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = E:/R/bin/Rscript.exe;
proc.StartInfo.WorkingDirectory = E:/R/bin/;
proc.StartInfo.Arguments = E:/R/bin/test.r;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();


 Thanks again for your help, good luck.

   Alex





On 8/21/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 On Tue, 21 Aug 2007, Alex MD wrote:

  Hi,
 
  I know that the general subject calling R from C has been discused but
 I
  have been reading the manuals and also scouting the lists and I can not
 seam
  to find
  a working solution for my problem.

 It's a C# issue.

   I want to call a R script ( let's call it test.r ) from within C#
 code.
   After reading about this topic I am trying to do this :
 
  System.Diagnostics.Process proc = new System.Diagnostics.Process();
  proc.StartInfo.FileName = E:/R/R-2.5.1 /bin/Rterm.exe;
  proc.StartInfo.Arguments =  'test.r' --no-save;
  proc.StartInfo.UseShellExecute = false;
  proc.StartInfo.RedirectStandardOutput = false;
  proc.Start();
 
 
  bun when Rterm starts it shows parameter test.r ignored
 
  When I try to do the same from a command line shell it DOES work just
 fine :
   Rterm.exe test.r --no-save  runs the file without any problems.
 
  Do you have any idea how to make it not to ignore the input file? Or is
  there other way to just execute a .r file from C# code?

 You need a shell for redirection (  |) to work, and 'system' commands in
 Windows do not usually use one (as in C, C++, R, Perl): you seem to have
 turned off using a shell in C#.  However, I think you should be using
 RScript.exe, where this is not an issue.

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




-- 
Alexandru Maruseac
BEST Bucharest
E-mail: [EMAIL PROTECTED]
Tel:+40 0722 329 083
www.BEST.eu.org
www.BESTBc.pub.ro

[[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] standardized cronbach's alpha?

2007-08-21 Thread Steve Powell
Hi list members
Any easy way to get standardized cronbach's alpha for a scale, as in SPSS? 
Thanks 

Steve Powell

 
proMENTE social research 
research | evaluation | training  consulting 
Kranjčevićeva 35, 71000 Sarajevo 
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866


Checked by AVG Free Edition. 

17:44

__
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] library(fCalendar) timeDate(12.03.2005, format=%d.%m.%Y)

2007-08-21 Thread Martin Maechler
 OL == Ola Lindqvist [EMAIL PROTECTED]
 on Tue, 21 Aug 2007 14:32:19 +0200 writes:

OL Thanks!
OL Seems to work fine now!

Well, for your example.

But sorry to say, the patch breaks other cases.

I'm investigating further
(and will hopefully contribute to a new CRAN release of fCalendar
 once Diethelm Wuertz is back from wherever; I've already made
 more changes)

Martin Maechler,
ETH Zurich  [but different department than D.Wuertz]


OL Martin Becker wrote:
 Dear Ola,
 
 I think you spotted a small bug in *package* fCalendar.
 Explicit specification should prevent autodetection of the date 
 format, which is not the case for fCalendar v251.70, instead 
 autodetection is done at least once (twice, if actually appropriate).
 With the following patch, things should work ok:
 
 diff --recursive fCalendar.orig/R/3A-TimeDateClass.R 
 fCalendar/R/3A-TimeDateClass.R
 433c433
  charvec = format(strptime(charvec, .whichFormat(charvec)), 
 isoFormat)
 ---
  charvec = format(strptime(charvec, format), isoFormat)
 
 You did not provide the output of sessionInfo() (which you are asked 
 for in the posting guide). If you are using Windows and don't know how 
 to apply the patch, you can download a patched binary version here:
 http://www.saar-gate.net/download/fCalendar_251.70.zip
 
 Regards,
 
 Martin
 
 PS: Maybe r-sig-finance is more appropriate for questions concerning 
 Rmetrics.
 
 
 Ola Lindqvist wrote:
 Dear R users,
 I have problem with the library fCalendar.
 
 I am not using the US standard format notations. It seems like it is 
 not possible to have different format than the US standards.
 Anyone how knows a way to go around this problem?
 
 Here is the code I enter:
 myDate = 12.03.2005
 timeDate(myDate, format = %d.%m.%Y)
 
 And I get following error message:
 Error in if (sum(lt$sec + lt$min + lt$hour) == 0) isoFormat = 
 %Y-%m-%d :
 missing value where TRUE/FALSE needed
 
 Thanks,
 Ola
 
 __
 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.
 
 

OL __
OL R-help@stat.math.ethz.ch mailing list
OL https://stat.ethz.ch/mailman/listinfo/r-help
OL PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
OL 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] Variable c and function c

2007-08-21 Thread Vladimir Eremeev

I have found the error in my script which was semi-automatically translated
from the other person's MATLAB code.

The error is that c was assigned a value inside a function.
That is the function body contained the following instructions
  c-nw*czr
  d-nw*cz
  rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
  firstguess-c( 0,0,0,3,0.5,  0 , 0 ,  0.01)

I have already run this function and obtained the results, it was rather
long process, therefore I don't want to rerun it.

I was not given any warnings. 
How did the interpreter treat this? 
Will the result change, if I change the variable from c to, say, c. ?
This variable is not used anywhere else in the function.
-- 
View this message in context: 
http://www.nabble.com/Variable-c-and-function-c-tf4305781.html#a12256590
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] standardized cronbach's alpha?

2007-08-21 Thread Dimitris Rizopoulos
look at: help(cronbach.alpha, package = ltm)

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: Steve Powell [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, August 21, 2007 4:02 PM
Subject: [R] standardized cronbach's alpha?


Hi list members
Any easy way to get standardized cronbach's alpha for a scale, as in 
SPSS?
Thanks

Steve Powell


proMENTE social research
research | evaluation | training  consulting
Kranjčevićeva 35, 71000 Sarajevo
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 
866


Checked by AVG Free Edition.

17:44

__
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] Subsetting zoo object with a vector of time values.

2007-08-21 Thread Todd Remund
I have a zoo object for which I would like to subset using a vector of time 
values.  For example, I have the following time values represented in my zoo 
object.

-50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915 
-49.880

and would like to get observations corresponding to times

-50 -49.96 -49.92 -49.88.

What can I do without using the lapply or which functions?

Thank you.

Todd Remund

__
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] Odp: Variable c and function c

2007-08-21 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 21.08.2007 17:07:05:

 
 I have found the error in my script which was semi-automatically 
translated
 from the other person's MATLAB code.
 
 The error is that c was assigned a value inside a function.
 That is the function body contained the following instructions
   c-nw*czr
   d-nw*cz
   rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)

My guess is that rFren is computed with c defined above and

   firstguess-c( 0,0,0,3,0.5,  0 , 0 ,  0.01)

firstguess is assigned above numbers

See

fff-function(nw=10, czr=5, cz=3) {
c-nw*czr
d-nw*cz
rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
firstguess-c( 0,0,0,3,0.5,  0 , 0 ,  0.01)
list(rFren, firstguess)
}

 fff()
[[1]]
[1] 0.6483025

[[2]]
[1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06

 fff(1)
[[1]]
[1] 0.0625

[[2]]
[1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06

Regards
Petr

 
 I have already run this function and obtained the results, it was rather
 long process, therefore I don't want to rerun it.
 
 I was not given any warnings. 
 How did the interpreter treat this? 
 Will the result change, if I change the variable from c to, say, c. 
?
 This variable is not used anywhere else in the function.
 -- 
 View this message in context: 
http://www.nabble.com/Variable-c-and-function-c-
 tf4305781.html#a12256590
 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-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 zoo object with a vector of time values.

2007-08-21 Thread Achim Zeileis
On Tue, 21 Aug 2007, Todd Remund wrote:

 I have a zoo object for which I would like to subset using a vector of time
 values.  For example, I have the following time values represented in my zoo
 object.

 -50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915
 -49.880

 and would like to get observations corresponding to times

 -50 -49.96 -49.92 -49.88.

 What can I do without using the lapply or which functions?

Use the window() function:

z - zoo(1:10, c(-50.000, -49.996, -49.995, -49.960, -49.956, -49.955,
 -49.920, -49.916, -49.915, -49.880))
window(z, c(-50, -49.96, -49.92, -49.88))

hth,
Z

 Thank you.

 Todd Remund

 __
 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] Subsetting zoo object with a vector of time values.

2007-08-21 Thread Gabor Grothendieck
See ?window.zoo
e.g.

library(zoo)

# create test data
tt - c(-50, -49.996, -49.995, -49.96, -49.956, -49.955, -49.92, -49.916,
-49.915, -49.88)
z - zoo(seq_along(tt), tt)

window(z, c(-50, -49.96, -49.92, -49.88))

On 8/21/07, Todd Remund [EMAIL PROTECTED] wrote:
 I have a zoo object for which I would like to subset using a vector of time
 values.  For example, I have the following time values represented in my zoo
 object.

 -50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915
 -49.880

 and would like to get observations corresponding to times

 -50 -49.96 -49.92 -49.88.

 What can I do without using the lapply or which functions?

 Thank you.

 Todd Remund

 __
 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] Selective transformation

2007-08-21 Thread Allan Kamau
I am looking for a way to transform select observations based on a value based 
criteria.
Why - Am learning r and would like to perform regression analysis of given 
variables of the babies dataset (part of UsingR) for example babies$wt1, the 
data in the variables does contain values which should be interpreted as 
unknown, some variables have 999 for unknown and some have 99 for the same, 
since lm() expects not available data to be marked using NA.
I would like to use a solution that does not employ loops (I think it may not 
be the ideal way)

I am looking at using apply() and supply the name of my function responsible 
for transformation, but am unable to know now to reference the element of the 
vector/list being currently processed by apply() so I may do in place 
substitution (if value is 99 or 999) of the value with NA.






   

Pinpoint customers who are looking for what you sell.

__
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] extracting month from date in numeric form

2007-08-21 Thread Gonçalo Ferraz
Hi,
Anyone knows what would be a short way of extracting a month from a date in
numeric or integer format?

months(1979-12-20)
returns
December in character format.

How could I get 12 in numeric or integer format?

Thanks!

G.

[[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] Variable c and function c

2007-08-21 Thread Duncan Murdoch
On 8/21/2007 11:07 AM, Vladimir Eremeev wrote:
 I have found the error in my script which was semi-automatically translated
 from the other person's MATLAB code.
 
 The error is that c was assigned a value inside a function.
 That is the function body contained the following instructions
   c-nw*czr
   d-nw*cz
   rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
   firstguess-c( 0,0,0,3,0.5,  0 , 0 ,  0.01)
 
 I have already run this function and obtained the results, it was rather
 long process, therefore I don't want to rerun it.
 
 I was not given any warnings. 
 How did the interpreter treat this? 
 Will the result change, if I change the variable from c to, say, c. ?
 This variable is not used anywhere else in the function.

When looking for a function, R will ignore variables that are not 
functions.  So what you show above is not an error, though it can be 
confusing, so it's not a good idea.

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] extracting month from date in numeric form

2007-08-21 Thread Henrique Dallazuanna
Hi,

perhaps:
format.Date(as.Date(1979-12-20), %m)

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

On 21/08/07, Gonçalo Ferraz [EMAIL PROTECTED] wrote:

 Hi,
 Anyone knows what would be a short way of extracting a month from a date
 in
 numeric or integer format?

 months(1979-12-20)
 returns
 December in character format.

 How could I get 12 in numeric or integer format?

 Thanks!

 G.

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


[[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] extracting month from date in numeric form

2007-08-21 Thread Gabor Grothendieck
On 8/21/07, Gonçalo Ferraz [EMAIL PROTECTED] wrote:
 Hi,
 Anyone knows what would be a short way of extracting a month from a date in
 numeric or integer format?

 months(1979-12-20)
 returns
 December in character format.

 How could I get 12 in numeric or integer format?


Here are a few solutions:

format(as.Date(1979-12-20), %m)

as.POSIXlt(as.Date(1979-12-20))$mo + 1

as.numeric(substring(1979-12-20, 6, 7))

as.numeric(factor(months(as.Date(1979-12-20), abbrev = TRUE), levels
= month.abb))


See R News 4/1 Help Desk article for more on dates.

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

2007-08-21 Thread Alan Harrison
Hello Folks,

Very new to R so bear with me, running 5.2 on XP.  Trying to do a zero-inflated 
negative binomial regression on placental scar data as dependent.  Lactation, 
location, number of tick larvae present and mass of mouse are independents.  
Dataframe and attributes below:


 Location Lac Scars Lar Mass Lacfac
1   Tullychurry   0 0  15 13.87  0
2  Somerset   0 0   0 15.60  0
3 Tollymore   0 0   3 16.43  0
4 Tollymore   0 0   0 16.55  0
5   Caledon   0 0   0 17.47  0
6  Hillsborough   1 5   0 18.18  1
7   Caledon   0 0   1 19.06  0
8   Portglenone   0 4   0 19.10  0
9   Portglenone   0 5   0 19.13  0
10Tollymore   0 5   3 19.50  0
11 Hillsborough   1 5   0 19.58  1
12  Portglenone   0 4   0 19.76  0
13  Caledon   0 8   0 19.97  0
14 Hillsborough   1 4   0 20.02  1
15  Tullychurry   0 3   3 20.13  0
16 Hillsborough   1 5   0 20.18  1
17   LoughNavar   1 5   0 20.20  1
18Tollymore   0 0   1 20.24  0
19 Hillsborough   1 5   0 20.48  1
20  Caledon   0 4   1 20.56  0
21  Caledon   0 3   2 20.58  0
22Tollymore   0 4   3 20.58  0
23Tollymore   0 0   2 20.88  0
24 Hillsborough   1 0   0 21.01  1
25  Portglenone   0 5   0 21.08  0
26  Tullychurry   0 2   5 21.28  0
27 Ballysallagh   1 4   0 21.59  1
28  Caledon   0 0   1 21.68  0
29 Hillsborough   1 5   0 22.09  1
30  Tullychurry   0 5   5 22.28  0
31  Tullychurry   1 6  75 22.43  1
32 Ballysallagh   1 5   0 22.57  1
33 Ballysallagh   1 4   0 22.67  1
34   LoughNavar   1 5   3 22.71  1
35 Hillsborough   1 4   0 23.01  1
36  Caledon   0 0   3 23.08  0
37   LoughNavar   1 5   0 23.53  1
38 Ballysallagh   1 4   0 23.55  1
39  Portglenone   1 6   0 23.61  1
40   Mt.Stewart   0 3   0 23.70  0
41 Somerset   0 5   0 23.83  0
42 Ballysallagh   1 5   0 23.93  1
43 Ballysallagh   1 5   0 24.01  1
44  Caledon   0 0   3 24.14  0
45   LoughNavar   0 6   0 24.30  0
46   LoughNavar   1 5   0 24.34  1
47 Hillsborough   1 4   0 24.45  1
48  Caledon   0 3   2 24.55  0
49  Tullychurry   0 5  44 24.83  0
50 Hillsborough   1 5   0 24.86  1
51 Ballysallagh   1 5   0 25.02  1
52  Tullychurry   0 0   9 25.27  0
53   Mt.Stewart   0 5   0 25.31  0
54   LoughNavar   1 4   8 25.43  1
55 Somerset   1 0   0 25.58  1
56 Hillsborough   1 5   0 25.82  1
57  Portglenone   1 2   0 26.02  1
58 Ballysallagh   1 5   0 26.19  1
59   Mt.Stewart   1 0   0 26.66  1
60  Randalstown   1 0   1 26.70  1
61 Somerset   0 4   0 27.01  0
62   Mt.Stewart   0 4   0 27.05  0
63 Somerset   0 3   0 27.10  0
64 Somerset   0 6   0 27.34  0
65 Somerset   0 0   0 27.87  0
66   LoughNavar   1 5   1 28.01  1
67  Tullychurry   1 6  42 28.55  1
68 Hillsborough   1 5   0 28.84  1
69  Portglenone   1 4   0 29.00  1
70 Somerset   1 4   0 31.87  1
71 Ballysallagh   1 5   0 33.06  1
72   LoughNavar   1 4   0 33.24  1
73 Somerset   1 4   0 33.36  1

alan : 'data.frame':73 obs. of  6 variables:
 $ Location: Factor w/ 10 levels Ballysallagh,..: 10 8 9 9 2 3 2 6 6 9 ...
 $ Lac : int  0 0 0 0 0 1 0 0 0 0 ...
 $ Scars   : int  0 0 0 0 0 5 0 4 5 5 ...
 $ Lar : int  15 0 3 0 0 0 1 0 0 3 ...
 $ Mass: num  13.9 15.6 16.4 16.6 17.5 ...
 $ Lacfac  : Factor w/ 2 levels 0,1: 1 1 1 1 1 2 1 1 1 1 ...

The syntax I used to create the model is:

zinb.zc - zicounts(resp=Scars~.,x =~Location + Lar + Mass + Lar:Mass + 
Location:Mass,z =~Location + Lar + Mass + Lar:Mass + Location:Mass, data=alan)

The error given is:

Error in optim(par = parm, fn = neg.like, gr = neg.grad, hessian = TRUE,  : 
non-finite value supplied by optim
In addition: Warning message:
fitted probabilities numerically 0 or 1 occurred in: glm.fit(zz, 1 - pmin(y, 
1), family = binomial())

I understand this is a problem with the model I specified, could anyone help 
out??

Many thanks

Alan Harrison

Quercus
Queen's University Belfast
MBC, 97 Lisburn Road
Belfast

BT9 7BL

T: 02890 972219
M: 07798615682


[[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] Formatting Sweave in R-News

2007-08-21 Thread Arjun Ravi Narayan
Hi,

I am editing a document for submission to the R-news newsletter, and
in my article my Sweave code inserts a dynamically generated PDF
report that my R program generates.

However, when I insert the PDF using the following Sweave code:

\newpage
\includegraphics[scale=1.0]{\Sexpr{print(location)}}
\newpage

(in tex this looks like):
\newpage
\includegraphics[scale=1.0]{/home/arjun/sample.pdf}
\newpage


However, the r-news style package over-rides everything that I can set
(including using the minipage option) to make my included PDF small
sized. Part of the problem is that the R-news style specifies a
two-column formatting, and so the PDF is shrunk to fit in one column.
How can I, for just one page, over-ride the styles to include the PDF?
Even if I hard-hack the graphics to be scaled up in size, that does
not get rid of the vertical line that in between the two columns, and
thus breaking my image.

I realise that this is not an R problem, but more a latex problem, but
I am hoping that somebody has faced similar problems with the Rnews
styles and has an idea on how to do this.


Thank you,

Yours sincerely,
-- 
Arjun Ravi Narayan
[EMAIL PROTECTED]

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


Re: [R] Selective transformation

2007-08-21 Thread Chuck Cleland
Allan Kamau wrote:
 I am looking for a way to transform select observations based on a value 
 based criteria.
 Why - Am learning r and would like to perform regression analysis of given 
 variables of the babies dataset (part of UsingR) for example babies$wt1, the 
 data in the variables does contain values which should be interpreted as 
 unknown, some variables have 999 for unknown and some have 99 for the same, 
 since lm() expects not available data to be marked using NA.
 I would like to use a solution that does not employ loops (I think it may not 
 be the ideal way)
 
 I am looking at using apply() and supply the name of my function responsible 
 for transformation, but am unable to know now to reference the element of the 
 vector/list being currently processed by apply() so I may do in place 
 substitution (if value is 99 or 999) of the value with NA.

  Does this do what you want?

babies$wt1 - with(babies, replace(wt1, wt1 == 999, NA))

?replace

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

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

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


[R] divided scatter plots

2007-08-21 Thread Caroline Nganga
I have a data set which contains two columns. The first column is a
list of countries, and the second column contains their political risk
ratings. I would like to create  one large plot that contains 5
different sections, each with a scatter plot. To clarify, I have
divided the countries into 5 groups. For each group (continent), I
would like to have the name of the continent on the x-axis, and points
representing countries and  their risk rating on the y-axis. However,
I want all 5 scatter plots to be in one large plot. What function
should I use to do this? Also, is it possible to label each point?
thanks for any help!

__
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] Selective transformation

2007-08-21 Thread Allan Kamau


- Original Message 
From: Chuck Cleland [EMAIL PROTECTED]
To: Allan Kamau [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Tuesday, August 21, 2007 6:48:53 PM
Subject: Re: [R] Selective transformation

Allan Kamau wrote:
 I am looking for a way to transform select observations based on a value 
 based criteria.
 Why - Am learning r and would like to perform regression analysis of given 
 variables of the babies dataset (part of UsingR) for example babies$wt1, the 
 data in the variables does contain values which should be interpreted as 
 unknown, some variables have 999 for unknown and some have 99 for the same, 
 since lm() expects not available data to be marked using NA.
 I would like to use a solution that does not employ loops (I think it may not 
 be the ideal way)
 
 I am looking at using apply() and supply the name of my function responsible 
 for transformation, but am unable to know now to reference the element of the 
 vector/list being currently processed by apply() so I may do in place 
 substitution (if value is 99 or 999) of the value with NA.

  Does this do what you want?

babies$wt1 - with(babies, replace(wt1, wt1 == 999, NA))

?replace




Thanks Chuck, the replace command is just what I was looking for.

wt1-babies$wt1
wt1-replace(wt1,wt1==999,NA)

I get NA in wt1 vector in place of 999




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

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






  

Luggage? GPS? Comic books?

__
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] pvals.fnc unhappy about lmer objects

2007-08-21 Thread Horace Tso
Dear folks (or Dear Professor Bates),

I'm quite confused as to the current status of some of the available
functions applicable to lmer objects. Following the examples in Baayen,
Davidson, Bates (2006), my plan is to run mcmcsamp on a random effect
model created by lmer in package lme4, then use the (perhaps outdated)
pvals to estimate p-value. But then I couldn't find pvals anywhere. 

So question number one is : Has pvals been replaced? by pvals.fnc in
the package languageR perhaps?

From the help page, it's stated that pvals.fnc takes a model fitted
with lmer, in contrast with the pvals I've read about in Baayen et al,
which takes an mcmc object. So I then tried,

 hr.lmer = lmer(hr ~ tg + spl + (1+tg|M), data=dat)
 pvals.fnc(hr.lmer)

An error is reported,

Error in get(x, envir, mode, inherits) : variable Gen.2001 of mode
function was not found

First I suspected it must be my model, so I run through the example in
pvals.fnc help page, as follow,
 data(primingHeid) 
 primingHeid = primingHeid[primingHeid$RT  7.1,]
 primingHeid = primingHeid[primingHeid$RT  7.1,]
 primingHeid.lmer = lmer(RT ~ RTtoPrime * ResponseToPrime + 
+ Condition + (1|Subject) + (1|Word), data = primingHeid)
 primingHeid.pvals = pvals.fnc(primingHeid.lmer)

The same error is encountered,

Error in get(x, envir, mode, inherits) : variable Gen.2001 of mode
function was not found

Thanks in advance.

Horace W. Tso

*-
PS: I'm on Windows XP,  with R2.5.1 (2007-06-27)

 sessionInfo()
R version 2.5.1 (2007-06-27) 
i386-pc-mingw32 

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

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

other attached packages:
   languageRrpart MASS   Design survival   
Hmisce1071class  cluster 
   0.2 3.1-37 7.2-34  2.1-1   2.32 
3.4-2 1.5-16 7.2-34 1.11.7 
   zipfR coda xlsReadWrite lme4   Matrix 
lattice R.oo  zoo 
 0.6-0 0.12-1  1.3.2  0.99875-7 0.999375-1   
0.15-11  1.2.7  1.2-2 


__
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] small issue with densityplot

2007-08-21 Thread Horace Tso
Hi folks,

This is really minor but to someone not familiar with the various tentacles of 
the lmer package it could be really annoying. I was trying to plot the 
posterior density of the fixed effect parameters of a lmer model,

 hr.mcmc = mcmcsamp(hr.lmer, n=5)
 densityplot(hr.mcmc, plot.points=F)

There is this error,

Error in densityplot(hr.mcmc, plot.points = F) : 
no applicable method for densityplot 

It kind of smells like something I've come across before. So I checked the 
mcmcsamp help page, and alas, the example suggests that the package coda is 
needed.  

From the help page of densityplot alone, there is no way one could figure out 
this dependency. It says, together with histogram, it is part of lattice.

Could the function author *please* make clarification in future editions of 
lattice.

Thanks.

Horace W. Tso

__
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] small issue with densityplot

2007-08-21 Thread Deepayan Sarkar
On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
 Hi folks,

 This is really minor but to someone not familiar with the various tentacles 
 of the lmer package it could be really annoying. I was trying to plot the 
 posterior density of the fixed effect parameters of a lmer model,

  hr.mcmc = mcmcsamp(hr.lmer, n=5)
  densityplot(hr.mcmc, plot.points=F)

 There is this error,

 Error in densityplot(hr.mcmc, plot.points = F) :
 no applicable method for densityplot 

 It kind of smells like something I've come across before. So I checked the 
 mcmcsamp help page, and alas, the example suggests that the package coda is 
 needed.

 From the help page of densityplot alone, there is no way one could figure 
 out this dependency. It says, together with histogram, it is part of lattice.

 Could the function author *please* make clarification in future editions of 
 lattice.

There is nothing to clarify. densityplot() is a generic function, and
it is not possible for the author of the generic function to
anticipate and document all possible methods, especially those in
other packages. I would say that since you are using mcmcsamp(), it's
perfectly reasonable to expect you to look at its help page to figure
out what you can do with the results.

What gave you the idea that densityplot would work on the result of
mcmcsamp in the first place?

-Deepayan

__
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] Stacked Bar

2007-08-21 Thread Deepayan Sarkar
On 8/21/07, Stephen Tucker [EMAIL PROTECTED] wrote:
 I think you want to use the 'density' argument. For example:

 barplot(1:5,col=1)
 legend(topleft,fill=1,legend=text,cex=1.2)
 par(new=TRUE)
 barplot(1:5,density=5,col=2)
 legend(topleft,fill=2,density=20,legend=text,bty=n,cex=1.2)

 (if you wanted to overlay solid colors with hatching)

 Here's the lattice alternative of the bar graph, though the help page says
 'density' is currently unimplemented (Package lattice version 0.16-2).

Yes, and that's unlikely to change unless grid begins to support it.

 To get
 the legend into columns, I followed the suggestion described here:
 http://tolstoy.newcastle.edu.au/R/help/05/04/2529.html

 Essentially I use mapply() and the line following to create a list with
 alternating 'text' and 'rect' arguments (3 times to get 3 columns).
 ===
 x - matrix(1:75, ncol= 5)
 dimnames(x)[[2]] - paste(Method, 1:5, sep=)
 dimnames(x)[[1]] - paste(Row, 1:15, sep=)

 u - mapply(function(x,y) list(text=list(lab=x),rect=list(col=y)),
 x = as.data.frame(matrix(levels(as.data.frame.table(x)$Var1),
   ncol=3)),
 y = as.data.frame(matrix(rainbow(nrow(x)),
   ncol=3)),
 SIMPLIFY=FALSE)
 key - c(rep=FALSE,space=bottom,unlist(names-(u,NULL),rec=FALSE))

 barchart(Freq ~ Var2,
  data = as.data.frame.table(x),
  groups = Var1, stack = TRUE,
  col=rainbow(nrow(x)),density=5,
  key = key )
 ===

A more transparent solution (IMO) is something like

barchart(Freq ~ Var2,
data = as.data.frame.table(x),
groups = Var1, stack = TRUE,
par.settings = list(superpose.polygon = list(col=rainbow(nrow(x,
auto.key = list(space = right, columns = 2) )

-Deepayan

__
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] small issue with densityplot

2007-08-21 Thread Horace Tso
Deepayan, you're right. Now I realize anyone could write a densityplot function 
to apply on a different class of objects. I guess I should write to the author 
of lme4 which from what I could see does not describe a densityplot. By the 
way, it is used in Baayen, Davidson, and Bates (2006).

H.

 Deepayan Sarkar [EMAIL PROTECTED] 8/21/2007 11:17:39 AM 
On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
 Hi folks,

 This is really minor but to someone not familiar with the various tentacles 
 of the lmer package it could be really annoying. I was trying to plot the 
 posterior density of the fixed effect parameters of a lmer model,

  hr.mcmc = mcmcsamp(hr.lmer, n=5)
  densityplot(hr.mcmc, plot.points=F)

 There is this error,

 Error in densityplot(hr.mcmc, plot.points = F) :
 no applicable method for densityplot 

 It kind of smells like something I've come across before. So I checked the 
 mcmcsamp help page, and alas, the example suggests that the package coda is 
 needed.

 From the help page of densityplot alone, there is no way one could figure 
 out this dependency. It says, together with histogram, it is part of lattice.

 Could the function author *please* make clarification in future editions of 
 lattice.

There is nothing to clarify. densityplot() is a generic function, and
it is not possible for the author of the generic function to
anticipate and document all possible methods, especially those in
other packages. I would say that since you are using mcmcsamp(), it's
perfectly reasonable to expect you to look at its help page to figure
out what you can do with the results.

What gave you the idea that densityplot would work on the result of
mcmcsamp in the first place?

-Deepayan

__
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] clusterCall with replicate function

2007-08-21 Thread Michael Gormley
I am trying to run a monte carlo process using snow with a MPI cluster.  I 
have ~thirty processors to run the algorithm on and I want to run it 5000 
times and take the average of the output.  A very simple way to do this is 
to divide 5000 by the number of processors to get a number n and tell each 
processor to run the algorithm n times.  I realize there are more efficient 
ways to manage the parallelization.   To implement this I used the 
clusterCall command with the replicate function along the lines of
clusterCall(cl, replicate, n, function(args)).  Because my function is a 
monte carlo process it relies on drawing from random distributions to 
generate output.  When I do this, all of my processors generate the same 
random numbers.  I copied the following from the command space for a simple 
example:
cl-makeCluster(cl, replicate,1,runif(2))
 clusterCall(cl, replicate, 2, runif(2))
[[1]]
0.65339590.6533959
0.10710510.1071051
[[2]]
0.65339590.6533959
0.10710510.1071051

This is not alleviated by using clusterApply to set a random seed for each 
processor and seems to be related to the use of the replicate function 
within clusterCall.  I have rearranged the function so that replicate is 
used to call the clusterCall function (ie. replicate(2, clusterCall(cl, 
runif,2),simplify=F) ) and resolved the random number issue.  However, this 
also involves much more communication between master and slaves and results 
in slower computation time.   Will rsprng fix this problem?  Is there a 
better way to do this without using replicate?
I hope this is somewhat clear.

Thanks,
Mike

__
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 do i use the get function to obtain an element from a list...

2007-08-21 Thread Juan Manuel Barreneche
my problem can be explained with the following example:

x - 1:12
y - 13:24
a - data.frame(x = x, y = y)

## if i write
a$x
## it returns
[1]  1  2  3  4  5  6  7  8  9 10 11 12

## but the function get doesn't recognize a$x. Instead it produces the
following error:
get(a$x)
Error in get(x, envir, mode, inherits) : variable a$x was not found

i intend to do it inside a loop, using a new object (and hence, a new
name) for each iteration (i.e., instead of a$x, it would be a$1, a$2,
a$3, and so on, for a million times).

i would greatly appreciate it if someone could help me on this issue,

thanks in advance,

Juan Manuel Barreneche,
Zoología de Vertebrados,
Facultad de Ciencias,
UDELAR, Uruguay.

__
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 do i use the get function to obtain an element from alist...

2007-08-21 Thread Leeds, Mark \(IED\)
eval(parse(text=(a$x). You can only use get when it's an object. a$x isn't. 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Manuel 
Barreneche
Sent: Tuesday, August 21, 2007 3:35 PM
To: r-help@stat.math.ethz.ch
Subject: [R] how do i use the get function to obtain an element from alist...

my problem can be explained with the following example:

x - 1:12
y - 13:24
a - data.frame(x = x, y = y)

## if i write
a$x
## it returns
[1]  1  2  3  4  5  6  7  8  9 10 11 12

## but the function get doesn't recognize a$x. Instead it produces the 
following error:
get(a$x)
Error in get(x, envir, mode, inherits) : variable a$x was not found

i intend to do it inside a loop, using a new object (and hence, a new
name) for each iteration (i.e., instead of a$x, it would be a$1, a$2, a$3, and 
so on, for a million times).

i would greatly appreciate it if someone could help me on this issue,

thanks in advance,

Juan Manuel Barreneche,
Zoología de Vertebrados,
Facultad de Ciencias,
UDELAR, Uruguay.

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


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] how do i use the get function to obtain an element from a list...

2007-08-21 Thread Duncan Murdoch
On 8/21/2007 3:35 PM, Juan Manuel Barreneche wrote:
 my problem can be explained with the following example:
 
 x - 1:12
 y - 13:24
 a - data.frame(x = x, y = y)
 
 ## if i write
 a$x
 ## it returns
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 
 ## but the function get doesn't recognize a$x. Instead it produces the
 following error:
 get(a$x)
 Error in get(x, envir, mode, inherits) : variable a$x was not found

a$x is an expression, which you could evaluate, not a variable, which 
you could get.

 
 i intend to do it inside a loop, using a new object (and hence, a new
 name) for each iteration (i.e., instead of a$x, it would be a$1, a$2,
 a$3, and so on, for a million times).
 
 i would greatly appreciate it if someone could help me on this issue,

Why name things?  I'd use something like

for (i in 1:100) print(a[[i]])

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.


[R] Random Sampling from a Matrix

2007-08-21 Thread Anup Nandialath
Dear Friends,

I have a matrix of size 5000 X 20. The first two columns are indicator 
variables taking the value of either 0 or 1. Let us call the first two columns 
Y1 and Y2. 

I need to randomly sample 1000 rows with all the associated columns, in other 
words my new matrix should be of size 1000 X 20. I realize that using this 
command

 newmat - mainmat[sample(1000,replace=F),]

achieves this. However, I would like to make sure that both Y1 and Y2 have more 
or less an equal amount of 0's and 1's. At present when I sample, I get cases 
where sometimes all my Y2's are 0. Is there any way to accomodate this problem.

Thanks in advance.

Regards

Anup

   
-

[[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 do i use the get function to obtain an element from a list...

2007-08-21 Thread Henrique Dallazuanna
Hi, you can try this:

eval(parse(text=a$x))

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

On 21/08/07, Juan Manuel Barreneche [EMAIL PROTECTED] wrote:

 my problem can be explained with the following example:

 x - 1:12
 y - 13:24
 a - data.frame(x = x, y = y)

 ## if i write
 a$x
 ## it returns
 [1]  1  2  3  4  5  6  7  8  9 10 11 12

 ## but the function get doesn't recognize a$x. Instead it produces the
 following error:
 get(a$x)
 Error in get(x, envir, mode, inherits) : variable a$x was not found

 i intend to do it inside a loop, using a new object (and hence, a new
 name) for each iteration (i.e., instead of a$x, it would be a$1, a$2,
 a$3, and so on, for a million times).

 i would greatly appreciate it if someone could help me on this issue,

 thanks in advance,

 Juan Manuel Barreneche,
 Zoología de Vertebrados,
 Facultad de Ciencias,
 UDELAR, Uruguay.

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


[[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] Optimization problem

2007-08-21 Thread Gabor Grothendieck
Lac and Lacfac are the same.

On 8/21/07, Alan Harrison [EMAIL PROTECTED] wrote:
 Hello Folks,

 Very new to R so bear with me, running 5.2 on XP.  Trying to do a 
 zero-inflated negative binomial regression on placental scar data as 
 dependent.  Lactation, location, number of tick larvae present and mass of 
 mouse are independents.  Dataframe and attributes below:


  Location Lac Scars Lar Mass Lacfac
 1   Tullychurry   0 0  15 13.87  0
 2  Somerset   0 0   0 15.60  0
 3 Tollymore   0 0   3 16.43  0
 4 Tollymore   0 0   0 16.55  0
 5   Caledon   0 0   0 17.47  0
 6  Hillsborough   1 5   0 18.18  1
 7   Caledon   0 0   1 19.06  0
 8   Portglenone   0 4   0 19.10  0
 9   Portglenone   0 5   0 19.13  0
 10Tollymore   0 5   3 19.50  0
 11 Hillsborough   1 5   0 19.58  1
 12  Portglenone   0 4   0 19.76  0
 13  Caledon   0 8   0 19.97  0
 14 Hillsborough   1 4   0 20.02  1
 15  Tullychurry   0 3   3 20.13  0
 16 Hillsborough   1 5   0 20.18  1
 17   LoughNavar   1 5   0 20.20  1
 18Tollymore   0 0   1 20.24  0
 19 Hillsborough   1 5   0 20.48  1
 20  Caledon   0 4   1 20.56  0
 21  Caledon   0 3   2 20.58  0
 22Tollymore   0 4   3 20.58  0
 23Tollymore   0 0   2 20.88  0
 24 Hillsborough   1 0   0 21.01  1
 25  Portglenone   0 5   0 21.08  0
 26  Tullychurry   0 2   5 21.28  0
 27 Ballysallagh   1 4   0 21.59  1
 28  Caledon   0 0   1 21.68  0
 29 Hillsborough   1 5   0 22.09  1
 30  Tullychurry   0 5   5 22.28  0
 31  Tullychurry   1 6  75 22.43  1
 32 Ballysallagh   1 5   0 22.57  1
 33 Ballysallagh   1 4   0 22.67  1
 34   LoughNavar   1 5   3 22.71  1
 35 Hillsborough   1 4   0 23.01  1
 36  Caledon   0 0   3 23.08  0
 37   LoughNavar   1 5   0 23.53  1
 38 Ballysallagh   1 4   0 23.55  1
 39  Portglenone   1 6   0 23.61  1
 40   Mt.Stewart   0 3   0 23.70  0
 41 Somerset   0 5   0 23.83  0
 42 Ballysallagh   1 5   0 23.93  1
 43 Ballysallagh   1 5   0 24.01  1
 44  Caledon   0 0   3 24.14  0
 45   LoughNavar   0 6   0 24.30  0
 46   LoughNavar   1 5   0 24.34  1
 47 Hillsborough   1 4   0 24.45  1
 48  Caledon   0 3   2 24.55  0
 49  Tullychurry   0 5  44 24.83  0
 50 Hillsborough   1 5   0 24.86  1
 51 Ballysallagh   1 5   0 25.02  1
 52  Tullychurry   0 0   9 25.27  0
 53   Mt.Stewart   0 5   0 25.31  0
 54   LoughNavar   1 4   8 25.43  1
 55 Somerset   1 0   0 25.58  1
 56 Hillsborough   1 5   0 25.82  1
 57  Portglenone   1 2   0 26.02  1
 58 Ballysallagh   1 5   0 26.19  1
 59   Mt.Stewart   1 0   0 26.66  1
 60  Randalstown   1 0   1 26.70  1
 61 Somerset   0 4   0 27.01  0
 62   Mt.Stewart   0 4   0 27.05  0
 63 Somerset   0 3   0 27.10  0
 64 Somerset   0 6   0 27.34  0
 65 Somerset   0 0   0 27.87  0
 66   LoughNavar   1 5   1 28.01  1
 67  Tullychurry   1 6  42 28.55  1
 68 Hillsborough   1 5   0 28.84  1
 69  Portglenone   1 4   0 29.00  1
 70 Somerset   1 4   0 31.87  1
 71 Ballysallagh   1 5   0 33.06  1
 72   LoughNavar   1 4   0 33.24  1
 73 Somerset   1 4   0 33.36  1

 alan : 'data.frame':73 obs. of  6 variables:
  $ Location: Factor w/ 10 levels Ballysallagh,..: 10 8 9 9 2 3 2 6 6 9 ...
  $ Lac : int  0 0 0 0 0 1 0 0 0 0 ...
  $ Scars   : int  0 0 0 0 0 5 0 4 5 5 ...
  $ Lar : int  15 0 3 0 0 0 1 0 0 3 ...
  $ Mass: num  13.9 15.6 16.4 16.6 17.5 ...
  $ Lacfac  : Factor w/ 2 levels 0,1: 1 1 1 1 1 2 1 1 1 1 ...

 The syntax I used to create the model is:

 zinb.zc - zicounts(resp=Scars~.,x =~Location + Lar + Mass + Lar:Mass + 
 Location:Mass,z =~Location + Lar + Mass + Lar:Mass + Location:Mass, data=alan)

 The error given is:

 Error in optim(par = parm, fn = neg.like, gr = neg.grad, hessian = TRUE,  :
non-finite value supplied by optim
 In addition: Warning message:
 fitted probabilities numerically 0 or 1 occurred in: glm.fit(zz, 1 - pmin(y, 
 1), family = binomial())

 I understand this is a problem with the model I specified, could anyone help 
 out??

 Many thanks

 Alan Harrison

 Quercus
 Queen's University Belfast
 MBC, 97 Lisburn Road
 Belfast

 BT9 7BL

 T: 02890 972219
 M: 07798615682


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

Re: [R] standardized cronbach's alpha?

2007-08-21 Thread Doran, Harold
You can get this using alpha() or alpha.Summary() in the MiscPsycho package. 
Stratified alpha coefficients are coming for the next release, BTW.


-Original Message-
From: [EMAIL PROTECTED] on behalf of Steve Powell
Sent: Tue 8/21/2007 10:02 AM
To: r-help@stat.math.ethz.ch
Subject: [R] standardized cronbach's alpha?
 
Hi list members
Any easy way to get standardized cronbach's alpha for a scale, as in SPSS? 
Thanks 

Steve Powell

 
proMENTE social research 
research | evaluation | training  consulting 
Kranjceviceva 35, 71000 Sarajevo 
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866


Checked by AVG Free Edition. 

17:44

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


[[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] summing columns of data frame by group

2007-08-21 Thread Daniel O'Shea
I have a data frame and one separate vector that is a grouping variable for the 
data frame.  I would like to take all rows of the data frame belonging to each 
group and then sum the columns with out using a for statement.

Something like: take all rows of group 1 then apply(group1.data,1,sum), but do 
this without having to do it separately for each group.  Any ideas?  thank you.

Dan

__
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] clusterCall with replicate function

2007-08-21 Thread Luke Tierney
replicate uses non-standard evaluation of its expr argument so that
doesn't work well with clusterCall or clusterApply. The way you are
using it you will get the same answer on all nodes no patter what you
do about the generators because the computations are all being done
on the master.

You can use clusterEvalQ, as in

 clusterEvalQ(cl, replicate(2, runif(2)))

Or you can use something like

 clusterCall(cl, function(n) replicate(n, runif(2)), 2)

This will still probably give identical results most of the time if
you don't do something about the RNG.  clusterSetupRNG will help you
with that -- just install the rlecuyer package and call
clusterSetupRNG.

Best,

luke

On Tue, 21 Aug 2007, Michael Gormley wrote:

 I am trying to run a monte carlo process using snow with a MPI cluster.  I
 have ~thirty processors to run the algorithm on and I want to run it 5000
 times and take the average of the output.  A very simple way to do this is
 to divide 5000 by the number of processors to get a number n and tell each
 processor to run the algorithm n times.  I realize there are more efficient
 ways to manage the parallelization.   To implement this I used the
 clusterCall command with the replicate function along the lines of
 clusterCall(cl, replicate, n, function(args)).  Because my function is a
 monte carlo process it relies on drawing from random distributions to
 generate output.  When I do this, all of my processors generate the same
 random numbers.  I copied the following from the command space for a simple
 example:
 cl-makeCluster(cl, replicate,1,runif(2))
 clusterCall(cl, replicate, 2, runif(2))
 [[1]]
 0.65339590.6533959
 0.10710510.1071051
 [[2]]
 0.65339590.6533959
 0.10710510.1071051

 This is not alleviated by using clusterApply to set a random seed for each
 processor and seems to be related to the use of the replicate function
 within clusterCall.  I have rearranged the function so that replicate is
 used to call the clusterCall function (ie. replicate(2, clusterCall(cl,
 runif,2),simplify=F) ) and resolved the random number issue.  However, this
 also involves much more communication between master and slaves and results
 in slower computation time.   Will rsprng fix this problem?  Is there a
 better way to do this without using replicate?
 I hope this is somewhat clear.

 Thanks,
 Mike

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


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

__
R-help@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 installing updated version of vars package

2007-08-21 Thread sj
All,

I was looking onlin and noticed that the vars package (by Bernhard Pfaff)
was recently updated (update date listed Aug 6, 2007) The updated packages
has some features that I would find very useful. I have used the update
packages function and vars was one of the packages identified as needing an
update. I was able to updated and it appeared to work, however when  I load
the package it does not seem to be the most recent version? Has anyone else
had similar problems? Or does anyone have any suggestions?

System Info:

R 2.4.1
Windows XP
install mirror: USA 3 (UCLA I think)

thanks,

Spencer

[[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] small issue with densityplot

2007-08-21 Thread Douglas Bates
On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
 Deepayan, you're right. Now I realize anyone could write a densityplot 
 function to apply on a different class of objects. I guess I should write to 
 the author of lme4 which from what I could see does not describe a 
 densityplot. By the way, it is used in Baayen, Davidson, and Bates (2006).

You're right.  It's my bad for not documenting that the coda package
is required for plots of the results of mcmcsamp.  I was trying to
piggy-back on the work that the authors of the coda package had done
on diagnostics, etc.  It was actually Deepayan and I who added the
lattice-based plots to the coda package for exactly this purpose (did
you remember that, Deepayan?).

In some ways it might be better to remove the dependence on coda and
write the classes and methods in the lme4 package.  That way I can use
S4 classes and irritate all those people who rail against S4 classes
and methods (and you know who you are).

  Deepayan Sarkar [EMAIL PROTECTED] 8/21/2007 11:17:39 AM 
 On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
  Hi folks,
 
  This is really minor but to someone not familiar with the various tentacles 
  of the lmer package it could be really annoying. I was trying to plot the 
  posterior density of the fixed effect parameters of a lmer model,
 
   hr.mcmc = mcmcsamp(hr.lmer, n=5)
   densityplot(hr.mcmc, plot.points=F)
 
  There is this error,
 
  Error in densityplot(hr.mcmc, plot.points = F) :
  no applicable method for densityplot 
 
  It kind of smells like something I've come across before. So I checked the 
  mcmcsamp help page, and alas, the example suggests that the package coda is 
  needed.
 
  From the help page of densityplot alone, there is no way one could figure 
  out this dependency. It says, together with histogram, it is part of 
  lattice.
 
  Could the function author *please* make clarification in future editions of 
  lattice.

 There is nothing to clarify. densityplot() is a generic function, and
 it is not possible for the author of the generic function to
 anticipate and document all possible methods, especially those in
 other packages. I would say that since you are using mcmcsamp(), it's
 perfectly reasonable to expect you to look at its help page to figure
 out what you can do with the results.

 What gave you the idea that densityplot would work on the result of
 mcmcsamp in the first place?

 -Deepayan

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

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


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


Re: [R] how do i use the get function to obtain an element from a list...

2007-08-21 Thread Tony Plate
One simple way that I haven't seen mentioned yet is to do:

  get(a)$x

(which of course allows further variants such as get(a)$x[3:6] ...)


-- Tony Plate

Juan Manuel Barreneche wrote:
 my problem can be explained with the following example:
 
 x - 1:12
 y - 13:24
 a - data.frame(x = x, y = y)
 
 ## if i write
 a$x
 ## it returns
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 
 ## but the function get doesn't recognize a$x. Instead it produces the
 following error:
 get(a$x)
 Error in get(x, envir, mode, inherits) : variable a$x was not found
 
 i intend to do it inside a loop, using a new object (and hence, a new
 name) for each iteration (i.e., instead of a$x, it would be a$1, a$2,
 a$3, and so on, for a million times).
 
 i would greatly appreciate it if someone could help me on this issue,
 
 thanks in advance,
 
 Juan Manuel Barreneche,
 Zoología de Vertebrados,
 Facultad de Ciencias,
 UDELAR, Uruguay.
 
 __
 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] (Most efficient) way to make random sequences of random sequences

2007-08-21 Thread Emmanuel Levy
Hi,

I was wondering the what would be the (most efficient) way to generate
a sequence
of sequences, i mean:

if I have 1,2 and 3.

I'd like to generate a sequence of length N*3 (N ~ 1,000,000 or more)

Where random permutations of the sequence 1,2,3 follow each other.

i.e  1,2,3,1,3,2,3,2,1

/!\ The thing is that there should never be twice the same number of
in the same sub-sequence, meaning that this is different from
generating a vector with the numbers 1,2 and 3 randomly distributed.

Any suggestion very welcome! Thanks,

Emmanuel

__
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] summing columns of data frame by group

2007-08-21 Thread John Kane
?by perhaps
--- Daniel O'Shea [EMAIL PROTECTED] wrote:

 I have a data frame and one separate vector that is
 a grouping variable for the data frame.  I would
 like to take all rows of the data frame belonging to
 each group and then sum the columns with out using a
 for statement.
 
 Something like: take all rows of group 1 then
 apply(group1.data,1,sum), but do this without having
 to do it separately for each group.  Any ideas? 
 thank you.
 
 Dan
 
 __
 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] summing columns of data frame by group

2007-08-21 Thread bogdan romocea
Here's one way,
lapply(split(DF, your.vector), function(x) {apply(x, 2, sum)})


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Daniel O'Shea
 Sent: Tuesday, August 21, 2007 3:53 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] summing columns of data frame by group

 I have a data frame and one separate vector that is a
 grouping variable for the data frame.  I would like to take
 all rows of the data frame belonging to each group and then
 sum the columns with out using a for statement.

 Something like: take all rows of group 1 then
 apply(group1.data,1,sum), but do this without having to do it
 separately for each group.  Any ideas?  thank you.

 Dan

 __
 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] small issue with densityplot

2007-08-21 Thread Rolf Turner

On 22/08/2007, at 8:44 AM, Douglas Bates wrote:

 In some ways it might be better to remove the dependence on coda and
 write the classes and methods in the lme4 package.  That way I can use
 S4 classes and irritate all those people who rail against S4 classes
 and methods (and you know who you are).

That --- i.e. causing such irritation --- would indeed seem to be  
the only
purpose/justification for using the (utterly incomprehensible to the  
human
mind, which is what I'm equipped with) S4 classes and methods!

cheers,

Rolf

##
Attention:\ This e-mail message is privileged and confidenti...{{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] quantile() returns a value outside the data range

2007-08-21 Thread Jenny Bryan
Hello,

I am getting an unexpected result from quantile().  Specifically, the
return value falls outside the range of the data, which I wouldn't
have thought possible for a weighted average of 2 order statistics.
Is this an unintended accuracy issue or am I being too casual in my
comparison (is there some analogue of 'all.equal' for =)?

Small example:

  foo - h2[,17][h2$plate==222] # some data I have, details not  
interesting
  foo - sort(foo)[1:3]# can demo with the 3 smallest  
values
  yo - data.frame(matrix(foo,nrow=length(foo),ncol=10))
  fooQtile - rep(0,9)
  for(i in 1:9) {   # compute 0.01 quantile, for all  
'types'
+   fooQtile[i] - quantile(foo,probs=0.01,type=i)
+   yo[,i+1] - foo = fooQtile[i]
+ }
  names(yo) - c(myData,paste(qType,1:9,sep=))
  yo
 myData qType1 qType2 qType3 qType4 qType5 qType6 qType7 qType8  
qType9
1 6.402611   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  FALSE  FALSE
TRUE
2 6.402611   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  FALSE  FALSE
TRUE
3 6.420587  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE   
FALSE
  fooQtile
[1] 6.40261 6.40261 6.40261 6.40261 6.40261 6.40261 6.40261 6.40261  
6.40261
  table(fooQtile)
fooQtile
6.40261053520674 6.40261053520674
27

I expected the returned quantile to be either equal to or greater than
the minimum observed value and that is the case for types 1-6 and
9. But for types 7 (the default) and 8, the returned quantile is less
than the minimum observed value.  The difference between the type
(1-6,9) and type (7,8) return values and between the returned quantile
and the minimum is obviously very very small.

Is there any choice for 'type' that is guaranteed to return values
inside the observed range?

Thanks, Jenny

Dr. Jennifer Bryan
Assistant Professor
Department of Statistics and
  the Michael Smith Laboratories
University of British Columbia

333-6356 Agricultural Road
Vancouver, BC Canada
V6T 1Z2

__
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] (Most efficient) way to make random sequences of random sequences

2007-08-21 Thread roger koenker
One way:

N - 10
 s - c(apply(matrix(rep(1:3,N),3,N),2,sample))


url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820


On Aug 21, 2007, at 3:49 PM, Emmanuel Levy wrote:

 Hi,

 I was wondering the what would be the (most efficient) way to generate
 a sequence
 of sequences, i mean:

 if I have 1,2 and 3.

 I'd like to generate a sequence of length N*3 (N ~ 1,000,000 or more)

 Where random permutations of the sequence 1,2,3 follow each other.

 i.e  1,2,3,1,3,2,3,2,1

 /!\ The thing is that there should never be twice the same number of
 in the same sub-sequence, meaning that this is different from
 generating a vector with the numbers 1,2 and 3 randomly distributed.

 Any suggestion very welcome! Thanks,

 Emmanuel

 __
 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] (Most efficient) way to make random sequences of random sequences

2007-08-21 Thread Rolf Turner

On 22/08/2007, at 8:49 AM, Emmanuel Levy wrote:

 Hi,

 I was wondering the what would be the (most efficient) way to generate
 a sequence
 of sequences, i mean:

 if I have 1,2 and 3.

 I'd like to generate a sequence of length N*3 (N ~ 1,000,000 or more)

 Where random permutations of the sequence 1,2,3 follow each other.

 i.e  1,2,3,1,3,2,3,2,1

 /!\ The thing is that there should never be twice the same number of
 in the same sub-sequence, meaning that this is different from
 generating a vector with the numbers 1,2 and 3 randomly distributed.

require(gtools)
m - permutations(3,3)
M - m[sample(1:6,100,TRUE),]
x   - as.vector(t(M))

##
Attention:\ This e-mail message is privileged and confidenti...{{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] small issue with densityplot

2007-08-21 Thread Horace Tso
Thank you Prof. Bates and Deepayan. As the title of this thread suggests, it is 
a minor issue once the user is familar with where to look for hints. But better 
documentation certainly won't hurt.

H.

 Douglas Bates [EMAIL PROTECTED] 8/21/2007 1:44:11 PM 
On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
 Deepayan, you're right. Now I realize anyone could write a densityplot 
 function to apply on a different class of objects. I guess I should write to 
 the author of lme4 which from what I could see does not describe a 
 densityplot. By the way, it is used in Baayen, Davidson, and Bates (2006).

You're right.  It's my bad for not documenting that the coda package
is required for plots of the results of mcmcsamp.  I was trying to
piggy-back on the work that the authors of the coda package had done
on diagnostics, etc.  It was actually Deepayan and I who added the
lattice-based plots to the coda package for exactly this purpose (did
you remember that, Deepayan?).

In some ways it might be better to remove the dependence on coda and
write the classes and methods in the lme4 package.  That way I can use
S4 classes and irritate all those people who rail against S4 classes
and methods (and you know who you are).

  Deepayan Sarkar [EMAIL PROTECTED] 8/21/2007 11:17:39 AM 
 On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
  Hi folks,
 
  This is really minor but to someone not familiar with the various tentacles 
  of the lmer package it could be really annoying. I was trying to plot the 
  posterior density of the fixed effect parameters of a lmer model,
 
   hr.mcmc = mcmcsamp(hr.lmer, n=5)
   densityplot(hr.mcmc, plot.points=F)
 
  There is this error,
 
  Error in densityplot(hr.mcmc, plot.points = F) :
  no applicable method for densityplot 
 
  It kind of smells like something I've come across before. So I checked the 
  mcmcsamp help page, and alas, the example suggests that the package coda is 
  needed.
 
  From the help page of densityplot alone, there is no way one could figure 
  out this dependency. It says, together with histogram, it is part of 
  lattice.
 
  Could the function author *please* make clarification in future editions of 
  lattice.

 There is nothing to clarify. densityplot() is a generic function, and
 it is not possible for the author of the generic function to
 anticipate and document all possible methods, especially those in
 other packages. I would say that since you are using mcmcsamp(), it's
 perfectly reasonable to expect you to look at its help page to figure
 out what you can do with the results.

 What gave you the idea that densityplot would work on the result of
 mcmcsamp in the first place?

 -Deepayan

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

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


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

__
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] (Most efficient) way to make random sequences of random sequences

2007-08-21 Thread Liaw, Andy
Similarly:

s - c(replicate(N, sample(3)))

Andy 

From: roger koenker
 One way:
 
   N - 10
s - c(apply(matrix(rep(1:3,N),3,N),2,sample))
 
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820
 
 
 On Aug 21, 2007, at 3:49 PM, Emmanuel Levy wrote:
 
  Hi,
 
  I was wondering the what would be the (most efficient) way 
 to generate
  a sequence
  of sequences, i mean:
 
  if I have 1,2 and 3.
 
  I'd like to generate a sequence of length N*3 (N ~ 
 1,000,000 or more)
 
  Where random permutations of the sequence 1,2,3 follow each other.
 
  i.e  1,2,3,1,3,2,3,2,1
 
  /!\ The thing is that there should never be twice the same number of
  in the same sub-sequence, meaning that this is different from
  generating a vector with the numbers 1,2 and 3 randomly distributed.
 
  Any suggestion very welcome! Thanks,
 
  Emmanuel
 
  __
  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.
 
 
 


--
Notice:  This e-mail message, together with any attachments,...{{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] (Most efficient) way to make random sequences of random sequences

2007-08-21 Thread Emmanuel Levy
Thanks for all your suggestions!

I guess I'll have to make tests to see which one is faster :)

Will come back to you when it's done.

On 8/21/07, Liaw, Andy [EMAIL PROTECTED] wrote:
 Similarly:

 s - c(replicate(N, sample(3)))

 Andy

 From: roger koenker
  One way:
 
N - 10
 s - c(apply(matrix(rep(1:3,N),3,N),2,sample))
 
 
  url:www.econ.uiuc.edu/~rogerRoger Koenker
  email[EMAIL PROTECTED]Department of Economics
  vox: 217-333-4558University of Illinois
  fax:   217-244-6678Champaign, IL 61820
 
 
  On Aug 21, 2007, at 3:49 PM, Emmanuel Levy wrote:
 
   Hi,
  
   I was wondering the what would be the (most efficient) way
  to generate
   a sequence
   of sequences, i mean:
  
   if I have 1,2 and 3.
  
   I'd like to generate a sequence of length N*3 (N ~
  1,000,000 or more)
  
   Where random permutations of the sequence 1,2,3 follow each other.
  
   i.e  1,2,3,1,3,2,3,2,1
  
   /!\ The thing is that there should never be twice the same number of
   in the same sub-sequence, meaning that this is different from
   generating a vector with the numbers 1,2 and 3 randomly distributed.
  
   Any suggestion very welcome! Thanks,
  
   Emmanuel
  
   __
   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.
 
 
 


 --
 Notice:  This e-mail message, together with any attachment...{{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] small issue with densityplot

2007-08-21 Thread Deepayan Sarkar
On 8/21/07, Douglas Bates [EMAIL PROTECTED] wrote:
 On 8/21/07, Horace Tso [EMAIL PROTECTED] wrote:
  Deepayan, you're right. Now I realize anyone could write a densityplot 
  function to apply on a different class of objects. I guess I should write 
  to the author of lme4 which from what I could see does not describe a 
  densityplot. By the way, it is used in Baayen, Davidson, and Bates (2006).

 You're right.  It's my bad for not documenting that the coda package
 is required for plots of the results of mcmcsamp.  I was trying to
 piggy-back on the work that the authors of the coda package had done
 on diagnostics, etc.  It was actually Deepayan and I who added the
 lattice-based plots to the coda package for exactly this purpose (did
 you remember that, Deepayan?).

I do remember that, but my point remains:

(1) densityplot is a generic in lattice and documented as such.

(2) mcmcsamp produces an object of class mcmc defined in coda, and
this is documented in help(mcmcsamp), which even uses densityplot for
its examples after attaching coda.

(3) densityplot.mcmc is documented in coda.

which all seems to be as it should be (except maybe ?densityplot.mcmc
should additionally have an alias for densityplot). The only confusing
aspect I see is that lme4 does not require or import coda, even though
mcmcsamp produces objects of a class that is supposedly from coda. I
realize that ownership of S3 classes is not well defined, but wouldn't
that be the logical thing to do? The original problem wouldn't have
come up if this were true.

-Deepayan

__
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] Simulation of logistic equation

2007-08-21 Thread Nguyen Dinh Nguyen
Dear all,

 

I would like to simulate a study in which the prevalence of an event is 1%
(p = 0.01), and the risk of the event is associated with two risk factors:
x1 and x2.  The odds ratio per standard deviation increase in x1 is 1.8 (95%
CI: 1.1 to 2.8), and the odds ratio for x2 being present is 2.1 (1.8 - 3.1).
x1 is a continuous variable with normal distribution (mean = 1.0, SD=0.10).
x2 is a categorical variable (with two values 0 and 1), and the prevalence
of x2=1 is around 10%.  

 

I have looked at the codes given in Design package, but I am not sure how to
simulate the prevalence.  Any help is highly appreciated.

Regard,

 

Nguyen

 

 
Nguyen Dinh Nguyen

Bone and Mineral Research Program 
Garvan Institute of Medical Research 
St Vincent's Hospital 
384 Victoria Street, Darlinghurst 
Sydney, NSW 2010 
Australia 
Tel; 61-2-9295 8274 
Fax: 61-2-9295 8241 
E-mail: [EMAIL PROTECTED]  

 

 

 


[[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] Output from while and for loop

2007-08-21 Thread Ryan Briscoe Runquist

Hello,

I am new and am having a hard time getting the proper syntax for output
from loops.  I am working on a simulation to generate a null expectation of
bee behavior.  Pieces of it work.  The part that I am having specific
difficulty is in output of a vector from within the while loop that I am
using.  Basically the simulation works as such:  I have a starting point
and a neighbor matrix and a certain threshold distance for travel.  In the
while loop the bee moves to a randomly chosen neighbor location.  I want
to be able to record the elevations of these points (including the starting
point) so that I can look at variance in elevation and mean elevation.  The
loop itself works as does the calculation of the final elevation list,
change in elevation list, and true total distance traveled.  I have looked
in all of the email archives but have not come across a correct way of
doing it.  Code below:

start.elev.list-list()
final.mean.elev.list-list()
final.elev.list-list()
final.distance.list-list()
final.delta.elev.list-list()
final.var.elev-list()


b-length(Bees.Day.1$bee)
for (bee in 1:b){ 
#this is for number of bees that are trackable in the day with starting
points and threshold distances
   elev.current.vector-vector(mode=numeric, length=0)
   count-1
   ElevSS-0
   d.traveled-0
   thresh-Bees.Day.1$cum.dist[bee]
   n-Bees.Day.1$grid.pt[bee]
   #I'm making this up for the threshold, want to be bee specific
   #current.point-round(runif(1,1,n)) #random starting point
   current.point-Day.1.neighbor.matrix[1,n]
   #I want to specify the first point in the matrix
   Elev.Sum-Day.1.elev.vector[current.point]


   while(d.traveledthresh){
#which of the four options will be selection
transition-round(runif(1,1,4))

#so, what's the new point?
new.point- Day.1.neighbor.matrix[transition,n]

#what is the variance in elevation changed
Elev.current-Day.1.elev.vector[current.point]
elev.current.vector[i]-Elev.current
Elev.new-Day.1.elev.vector[new.point]
Elev.Sum-(Elev.Sum+Elev.new)

#how far will bee travelled
current.travel- Day.1.distance.matrix[current.point, new.point]
d.traveled- current.travel + d.traveled
current.point- new.point

#Number of iterations until we reach the threshold
count-count+1

   }
   
   print(count)
   print(elev.current.vector)
   mean.elev-Elev.Sum/count
   print(paste(Final mean elev for bee, bee, is, mean.elev, sep= ))
   final.mean.elev.list[bee]-list(mean.elev)

   #What was the start elevation?
   start.elev-Day.1.elev.vector[n]
   print(paste(Start elev for bee,bee,is,start.elev, sep= ))
   start.elev.list[bee]-list(start.elev)
   
   #what is the final elevation?
   final.elev-Day.1.elev.vector[current.point]
   print(paste(Final elev for bee,bee,is, final.elev,sep= ))
   final.elev.list[bee]-list(final.elev)
   
   print(paste(Final travel distance for bee, bee,is, d.traveled, sep= ))
   final.distance.list[bee]-list(d.traveled)
  
   net.delta.elev-(final.elev-Day.1.elev.vector[n])
   print(paste(Final net change in elevation for bee,bee,is,
net.delta.elev,sep= ))
   final.delta.elev.list[bee]-list(net.delta.elev)
   
}
~~
Ryan D. Briscoe Runquist
Population Biology Graduate Group
University of California, Davis
[EMAIL PROTECTED]

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


Re: [R] Partial comparison in string vector

2007-08-21 Thread Moshe Olshansky
Use grep(^e,x) if you are looking for the entries
where e is the first character.

--- Vladimir Eremeev [EMAIL PROTECTED] wrote:

 
 Hi!
 
 seq(along=x) %in% grep(e,x)
 
 
 
 Steve Powell-4 wrote:
  
  I have a vector of strings
  x=c(w,ex,ee)
  And I want to get a logical vector showing the
 positions where my search
  string e matches the elements partially, i.e. is
 at least the left-hand
  part of the target strings, i.e. I want to get a
 vector FALSE TRUE TRUE.
  
 
 -- 
 View this message in context:

http://www.nabble.com/Partial-comparison-in-string-vector-tf4304145.html#a12251593
 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-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] rectify a program of seasonal dummies matrix

2007-08-21 Thread hassen62
Hi friends, 
I would like to construct a matrix of seasonal dummies with number of rows 
(observations)=100. such matrix is written as follows:[1 0 0 0;0 1 0 0;0 0 1 
0;0 0 0 1;1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1;etc...] . I wrote the following 
program:
T=100
br=matrix(0,T,4)
{
for (i in 1:T)
for (j in 1:4)
if i==j
br[i,j]=1 
if else (abs(i-j)%%4==0
br[i,j]=1
else 
br[i,j]=0
}
z-br
z 

but unfortunately I obtained from the console the following message:
 {
+ for (i in 1:T)
+  for (j in 1:4)
+ (if i==j)
Erreur : syntax error, unexpected SYMBOL, expecting '(' dans :


 br[i,j]=1
Erreur dans br[i, j] = 1 : objet i non trouvé
 
 (if else (abs(i-j)%%4==0)
Erreur : syntax error, unexpected ELSE, expecting '(' dans (if else
 br[i,j]=1
Erreur dans br[i, j] = 1 : objet i non trouvé
 else 
Erreur : syntax error, unexpected ELSE dans else
 br[i,j]=0
Erreur dans br[i, j] = 0 : objet i non trouvé
   }
Erreur : syntax error, unexpected '}' dans   }
  
Can you please rectify my smal program, I tried to rectify it but I can't. Many 
thanks in advance. 
[[alternative HTML version deleted]]

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


[R] tackle memory insufficiency for large dataset using save() load()??

2007-08-21 Thread Jessica Z
Hello List, i have been agonizing over this for days, any reply would be 
greatly appreciated!
   
  Situation:___ 
My original dataset is a .csv dataset (w/ 2M records) with 4 variables: 
job_id (Primary key, won't be used for analysis, just used for join tables),
sector_id (categorical variable, for 19 industry sectors), 
sqft (con't variable for square footage),   
building_type (categorical, for 2 building types)
  some values of sqft were inputed wrong, so i'd like to set sqft1 to NA and 
then use aregImpute() to impute those NAs. 
   
  Problem: the origianl dataset(.csv format) is too large. though i could read 
that dataset into R, i could not get aregImpute() run even i set the memory 
limit to 3G ! (yes, i did the switch in windows to reach 3G rather than 2G)
   
  Goal: try to find a way to slim down my dataset so as to get aregImpute() 
running. 
   
  What i did:
  i searched in the archive, and found someone said, as R tends to inflate 
memory, it is a good idea to first read the original dataset into R-- then 
save it as a more compact binary file using save() -- and then reload the 
compact binary file back into R using load(). this way would reduce the memory 
allocation. 
   
  HOWEVER, after i saved my original dataset into a compact binary file using 
save(), and used load(filename.Rdata) to reload the new compact data format 
into R, I could not figure out how to retrive all my variables!!! R shows the 
new dataset is not a list, nor a matrix, or a dataframe, but just a character 
with length 1 !!! and there is no way i could do attach(). 
   
  i generated a 1K-row subset out of my original dataset to illustrate my 
problem (does anyone know how to get my four variables back from this compact 
binary new dataset? what did i do wrong?):
  
 data - read.table (file.choose(),header=T,sep=,)
 summary(data)
 job_id sector_id   sqftbuilding_type  
 Min.   :   1.0   Min.   : 6.000   Min.   :  0.00   Min.   :1.000  
 1st Qu.: 250.8   1st Qu.: 6.000   1st Qu.:  3.00   1st Qu.:2.000  
 Median : 500.5   Median :11.000   Median :  4.00   Median :2.000  
 Mean   : 500.5   Mean   : 9.455   Mean   : 12.49   Mean   :1.996  
 3rd Qu.: 750.3   3rd Qu.:11.000   3rd Qu.:  4.00   3rd Qu.:2.000  
 Max.   :1000.0   Max.   :12.000   Max.   :192.00   Max.   :2.000  
  
 attach(data)
 sqft[sqft1] - NA
 sector.f - as.factor(sector_id)
 building_type.f - as.factor (building_type)
 d - data.frame(job_id,sector.f,sqft, building_type.f)
 summary (d)
 job_id   sector.f  sqftbuilding_type.f
 Min.   :   1.0   6 :340   Min.   :  3.00   1:  4  
 1st Qu.: 250.8   11:505   1st Qu.:  4.00   2:996  
 Median : 500.5   12:155   Median :  4.00  
 Mean   : 500.5Mean   : 14.16  
 3rd Qu.: 750.33rd Qu.: 17.00  
 Max.   :1000.0Max.   :192.00  
   NA's   :118.00  
 save (d, file=compact_d.Rdata, ascii=FALSE)
 
 newdata - load (compact_d.Rdata)
 
 summary(newdata)
   Length Class  Mode 
1 character character 
 attach(newdata)
Error in attach(newdata) : file 'd' not found
 is.data.frame (newdata)
[1] FALSE
 is.list (newdata)
[1] FALSE
 is.matrix (newdata)
[1] FALSE
 
  _
btw, i also tried to just save (into compact binary) and reload (the new 
compact binary data format) (as i could do the NA stuff in sql anyhow). 
however, i still got stucked at the same spot:
 data - read.table (file.choose(),header=T,sep=,)
 summary(data)
 job_id sector_id   sqftbuilding_type  
 Min.   :   1.0   Min.   : 6.000   Min.   :  0.00   Min.   :1.000  
 1st Qu.: 250.8   1st Qu.: 6.000   1st Qu.:  3.00   1st Qu.:2.000  
 Median : 500.5   Median :11.000   Median :  4.00   Median :2.000  
 Mean   : 500.5   Mean   : 9.455   Mean   : 12.49   Mean   :1.996  
 3rd Qu.: 750.3   3rd Qu.:11.000   3rd Qu.:  4.00   3rd Qu.:2.000  
 Max.   :1000.0   Max.   :12.000   Max.   :192.00   Max.   :2.000  
 save (data, file=compact_data.Rdata, ascii=FALSE)
 newdata - load (compact_data.Rdata)
 summary(newdata)
   Length Class  Mode 
1 character character 
 attach(newdata)
Error: restore file may be empty -- no data loaded
In addition: Warning message:
file 'data' has magic number ''
   Use of save versions prior to 2 is deprecated 
 is.data.frame (newdata)
[1] FALSE
 is.list (newdata)
[1] FALSE
 is.matrix (newdata)
[1] FALSE
 
   
   

   
-
Building a website is a piece of cake. 

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

Re: [R] tackle memory insufficiency for large dataset using save() load()?

2007-08-21 Thread Gabor Grothendieck
See ?save .  The ... arguments are the ***names*** of the objects, not
the objects
so you want save(d, ...whatever...) not save(d, ...whatever...) .
Also don't use attach and detach and read this about factors which applies
if your factor has many levels but can be ignored if not:
http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg92970.html

On 8/21/07, Jessica Z [EMAIL PROTECTED] wrote:
 Hello List, i have been agonizing over this for days, any reply would be 
 greatly appreciated!

  Situation:___
 My original dataset is a .csv dataset (w/ 2M records) with 4 variables:
 job_id (Primary key, won't be used for analysis, just used for join tables),
 sector_id (categorical variable, for 19 industry sectors),
 sqft (con't variable for square footage),
 building_type (categorical, for 2 building types)
  some values of sqft were inputed wrong, so i'd like to set sqft1 to NA 
 and then use aregImpute() to impute those NAs.

  Problem: the origianl dataset(.csv format) is too large. though i could read 
 that dataset into R, i could not get aregImpute() run even i set the memory 
 limit to 3G ! (yes, i did the switch in windows to reach 3G rather than 2G)

  Goal: try to find a way to slim down my dataset so as to get aregImpute() 
 running.

  What i did:
  i searched in the archive, and found someone said, as R tends to inflate 
 memory, it is a good idea to first read the original dataset into R-- then 
 save it as a more compact binary file using save() -- and then reload the 
 compact binary file back into R using load(). this way would reduce the 
 memory allocation.

  HOWEVER, after i saved my original dataset into a compact binary file using 
 save(), and used load(filename.Rdata) to reload the new compact data 
 format into R, I could not figure out how to retrive all my variables!!! R 
 shows the new dataset is not a list, nor a matrix, or a dataframe, but just a 
 character with length 1 !!! and there is no way i could do attach().

  i generated a 1K-row subset out of my original dataset to illustrate my 
 problem (does anyone know how to get my four variables back from this 
 compact binary new dataset? what did i do wrong?):

  data - read.table (file.choose(),header=T,sep=,)
  summary(data)
 job_id sector_id   sqftbuilding_type
  Min.   :   1.0   Min.   : 6.000   Min.   :  0.00   Min.   :1.000
  1st Qu.: 250.8   1st Qu.: 6.000   1st Qu.:  3.00   1st Qu.:2.000
  Median : 500.5   Median :11.000   Median :  4.00   Median :2.000
  Mean   : 500.5   Mean   : 9.455   Mean   : 12.49   Mean   :1.996
  3rd Qu.: 750.3   3rd Qu.:11.000   3rd Qu.:  4.00   3rd Qu.:2.000
  Max.   :1000.0   Max.   :12.000   Max.   :192.00   Max.   :2.000
 
  attach(data)
  sqft[sqft1] - NA
  sector.f - as.factor(sector_id)
  building_type.f - as.factor (building_type)
  d - data.frame(job_id,sector.f,sqft, building_type.f)
  summary (d)
 job_id   sector.f  sqftbuilding_type.f
  Min.   :   1.0   6 :340   Min.   :  3.00   1:  4
  1st Qu.: 250.8   11:505   1st Qu.:  4.00   2:996
  Median : 500.5   12:155   Median :  4.00
  Mean   : 500.5Mean   : 14.16
  3rd Qu.: 750.33rd Qu.: 17.00
  Max.   :1000.0Max.   :192.00
   NA's   :118.00
  save (d, file=compact_d.Rdata, ascii=FALSE)
 
  newdata - load (compact_d.Rdata)
 
  summary(newdata)
   Length Class  Mode
1 character character
  attach(newdata)
 Error in attach(newdata) : file 'd' not found
  is.data.frame (newdata)
 [1] FALSE
  is.list (newdata)
 [1] FALSE
  is.matrix (newdata)
 [1] FALSE
 
  _
 btw, i also tried to just save (into compact binary) and reload (the new 
 compact binary data format) (as i could do the NA stuff in sql anyhow). 
 however, i still got stucked at the same spot:
  data - read.table (file.choose(),header=T,sep=,)
  summary(data)
 job_id sector_id   sqftbuilding_type
  Min.   :   1.0   Min.   : 6.000   Min.   :  0.00   Min.   :1.000
  1st Qu.: 250.8   1st Qu.: 6.000   1st Qu.:  3.00   1st Qu.:2.000
  Median : 500.5   Median :11.000   Median :  4.00   Median :2.000
  Mean   : 500.5   Mean   : 9.455   Mean   : 12.49   Mean   :1.996
  3rd Qu.: 750.3   3rd Qu.:11.000   3rd Qu.:  4.00   3rd Qu.:2.000
  Max.   :1000.0   Max.   :12.000   Max.   :192.00   Max.   :2.000
  save (data, file=compact_data.Rdata, ascii=FALSE)
  newdata - load (compact_data.Rdata)
  summary(newdata)
   Length Class  Mode
1 character character
  attach(newdata)
 Error: restore file may be empty -- no data loaded
 In addition: Warning message:
 file 'data' has magic number ''
   Use of save versions prior to 2 is deprecated
  is.data.frame (newdata)
 [1] FALSE
  is.list (newdata)
 [1] FALSE
  is.matrix (newdata)
 [1] FALSE
 




 -
 Building a website is a piece of cake.

[[alternative 

Re: [R] R on a flash drive

2007-08-21 Thread Williams Scott
I often run R via a Ceedo virtualisation on a USB drive
(http://www.ceedo.com/) with XP. It costs a few dollars to it this way,
but is a very low stress installation and has worked flawlessly, albeit
a little slower (barely noticeable). Very handy if you are often working
on various machines without administrator rights (as I do in clinic) -
just plug in your USB and go directly back to your project. It then
removes any trace of you (so they say) when you log out. And you can use
it for other software (within limits though) you might want to carry
around.

Hope that helps.

Scott


Scott Williams MD
Peter MacCallum Cancer Centre
Melbourne
Australia

-Original Message-
From: John Kane [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 21 August 2007 12:28 AM
To: John Kane; Erin Hodgess; r-help@stat.math.ethz.ch
Subject: Re: [R] R on a flash drive

Oops meant to send this to the list.
--- John Kane [EMAIL PROTECTED] wrote:

 
 --- Erin Hodgess [EMAIL PROTECTED] wrote:
 
  Dear R People:
  
  Has anyone run R from a flash drive, please?
  
  If so, how did it work, please?
 
 Yes I run R, occasionally, on a USB with no problem
 on
 WindowsXP. It works well, albeit a bit more slowly
 than from the hard drive which is as you would
 expect.
 
 The last time I upgraded the USB (to 2.5.0 ?) I
 simply
 downloaded R and installed it on the USB drive
 rather
 than the C: drive and then installed all my usual
 optional packages using the normal Rgui interface. 
 
 I usually have R, Tinn-R and portable versions of
 OpenOoffice.org, and Firefox installed on the USB.  
 
 
   Get news delivered with the All new Yahoo!
 Mail.  Enjoy RSS feeds right on your Mail page.
 Start today at
 http://mrd.mail.yahoo.com/try_beta?.intl=ca


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

2007-08-21 Thread Ben Bolker

  (Hope this gets threaded properly.  Sorry if it doesn't.)

   Gabor: Lac and Lacfac being the same is irrelevant, wouldn't
produce NAs (but would produce something like a singular Hessian
and maybe other problems) -- but they're not even specified in this
model.

  The bottom line is that you have a location with a single
observation, so the GLM that zicounts runs to get the initial
parameter values has an unestimable location:mass interaction
for one location, so it gives an NA, so optim complains.

  In gruesome detail:

## set up  data
scardat = read.table(scars.dat,header=TRUE)
library(zicounts)
## try to run model
zinb.zc - zicounts(resp=Scars~.,
x =~Location + Lar + Mass + Lar:Mass + Location:Mass,
z =~Location + Lar + Mass + Lar:Mass + Location:Mass,
data=scardat)
## tried to debug this by dumping zicounts.R to a file, modifying
## it to put a trace argument in that would print out the parameters
## and log-likelihood for every call to the log-likelihood function.
dump(zicounts,file=zicounts.R)
source(zicounts.R)
zinb.zc - zicounts(resp=Scars~.,
x =~Location + Lar + Mass + Lar:Mass + Location:Mass,
z =~Location + Lar + Mass + Lar:Mass + Location:Mass,
data=scardat,trace=TRUE)
## this actually didn't do any good because the negative log-likelihood
## function never gets called -- as it turns out optim() barfs when it
## gets its initial values, before it ever gets to evaluating the 
log-likelihood

## check the glm -- this is the equivalent of what zicounts does to
## get the initial values of the x parameters
p1 - glm(Scars~Location + Lar + Mass + Lar:Mass + Location:Mass,
  data=scardat,family=poisson)
which(is.na(coef(p1)))

## find out what the deal is
table(scardat$Location)

scar2 = subset(scardat,Location!=Randalstown)
## first step to removing the bad point from the data set -- but ...
table(scar2$Location)
## it leaves the Location factor with the same levels, so
##  now we have ZERO counts for one location:
## redefine the factor to drop unused levels
scar2$Location - factor(scar2$Location)
## OK, looks fine now
table(scar2$Location)

zinb.zc - zicounts(resp=Scars~.,
x =~Location + Lar + Mass + Lar:Mass + Location:Mass,
z =~Location + Lar + Mass + Lar:Mass + Location:Mass,
data=scar2)
## now we get another error (system is computationally singular when
## trying to compute Hessian -- overparameterized?)   Not in any
## trivial way that I can see.  It would be nice to get into the guts
## of zicounts and stop it from trying to invert the Hessian, which is
## I think where this happens.

  In the meanwhile, I have some other  ideas about this analysis (sorry,
but you started it ...)

  Looking at the data in a few different ways:

library(lattice)
xyplot(Scars~Mass,groups=Location,data=scar2,jitter=TRUE,
   auto.key=list(columns=3))
xyplot(Scars~Mass|Location,data=scar2,jitter=TRUE)

xyplot(Scars~Lar,groups=Location,data=scar2,
   auto.key=list(columns=3))
xyplot(Scars~Mass|Lar,data=scar2)
xyplot(Scars~Lar|Location,data=scar2)

   Some thoughts: (1) I'm not at all sure that
zero-inflation is necessary (see Warton 2005, Environmentrics).
This is a fairly small, noisy data set without huge numbers
of zeros -- a plain old negative binomial might be fine.
 
   I don't actually see a lot of signal here, period (although there may 
be some) ...
there's not a huge range in Lar (whatever it is -- the rest of the 
covariates I
think I can interpret).  It would be tempting to try to fit location as 
a random
effect, because fitting all those extra degrees of freedom is going to 
kill you.
On the other hand, GLMMs are a bit hairy.

   cheers
   Ben

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


[R] C code generators

2007-08-21 Thread adrian
Dear R-helpers

Are there any established R packages that include a C code generator -- 
that generates new C language files and compiles them?

To be precise what I'm looking for is a process that takes text input in
some format (it might be pseudocode, fragments of C code, etc) and creates
a valid C language source file that can be compiled by R CMD COMPILE.
Ideally the procedure should also cause the C code to be compiled and
dynamically loaded.

To give a trivial example, suppose I want to be able to perform image
filtering operations on matrices. All filters have the same structure:
each position [i,j] in the matrix is visited in a double loop; a
calculation (depending on the filter) is performed using the value at
[i,j] and also the values at neighbouring positions [i+1,j] , [i+1,j+1]
etc; the result is written to the output matrix at the position [i,j]. The
C code for the loop is always the same; only a few lines of code that
perform the filter calculation will change. I would like a procedure that
accepts a text file containing just a few lines of C code or pseudocode,
and inserts these lines into the appropriate place in the loop, producing
a valid C language routine which can then be compiled by R CMD COMPILE and
dynamically loaded.

(Of course, it can get more complicated than just inserting a single text
fragment!)

I once implemented such a feature in an image processing package, so I
know it's not hard. Before dusting off this ancient code I would like to
learn whether there's an R package or other open source program that
already does it.

Any pointers would be welcome

thanks
Adrian Baddeley

__
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] polar.plot orientation and scale in plotrix

2007-08-21 Thread tsip002
Thanks for that Stephen.  It works nicely.  It seems that my expectations for
the plot defaults were non-standard.  From your remarks and those of a
colleague with an engineering background, I guess the defaults are standard. As
a biologist, it seemed sensible to me to expect it to work like a compass
though.  Future updates to the plotrix package apparently might include options
to easily customize these features (thanks to the package maintainer).

Best regards,

Quoting Stephen Tucker [EMAIL PROTECTED]:

 I think that's the standard presentation for polar plots (theta measured from
 positive x-axis) - that I've seen, anyway. But for customization you can
 shift your origin for theta and define your own labels. For example, here is
 a modification to the example in the help page for polar.plot():

 testlen-c(rnorm(36)*2+5)
 testpos-seq(0,350,by=10)
 polar.plot(testlen,360-(testpos+90),
main=Test Polar Plot,lwd=3,line.col=4,
labels=seq(0,359,by=45)[c(3:1,8:4)],
label.pos=seq(0,359,by=45))





 --- Tim Sippel [EMAIL PROTECTED] wrote:

  Hello all-
 
 
 
  I would like to orient my polar.plot (from package plotrix) so that the
  circular scale runs clockwise and the origin (ie. 0 degrees) starts at the
  top of the plot.  The defaults of running the scale counter-clockwise and
  beginning with 90 degrees at the top of the graph seems counter-intuitive
  to
  me.
 
 
 
  I'm using R 2.5.0, and plotrix version 2.2-4.
 
 
 
  Many thanks,
 
 
 
  Tim
 
 
 
 
  [[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.
 






 Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail,
 news, photos  more.
 http://mobile.yahoo.com/go?refer=1GNXIC


__
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] rectify a program of seasonal dummies matrix

2007-08-21 Thread jim holtman
Your syntax is wrong; e.g.,
if i==j

should be

if (i == j)

same with your use of 'if else'.  You need to use the correct syntax.
Your example is hard to follow without the correct indentation since
you are using the incorrect syntax.

On 8/21/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi friends,
 I would like to construct a matrix of seasonal dummies with number of rows 
 (observations)=100. such matrix is written as follows:[1 0 0 0;0 1 0 0;0 0 1 
 0;0 0 0 1;1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1;etc...] . I wrote the following 
 program:
 T=100
 br=matrix(0,T,4)
 {
 for (i in 1:T)
 for (j in 1:4)
 if i==j
 br[i,j]=1
 if else (abs(i-j)%%4==0
 br[i,j]=1
 else
 br[i,j]=0
 }
 z-br
 z

 but unfortunately I obtained from the console the following message:
  {
 + for (i in 1:T)
 +  for (j in 1:4)
 + (if i==j)
 Erreur : syntax error, unexpected SYMBOL, expecting '(' dans :
 
 
  br[i,j]=1
 Erreur dans br[i, j] = 1 : objet i non trouvé
 
  (if else (abs(i-j)%%4==0)
 Erreur : syntax error, unexpected ELSE, expecting '(' dans (if else
  br[i,j]=1
 Erreur dans br[i, j] = 1 : objet i non trouvé
  else
 Erreur : syntax error, unexpected ELSE dans else
  br[i,j]=0
 Erreur dans br[i, j] = 0 : objet i non trouvé
}
 Erreur : syntax error, unexpected '}' dans   }
 
 Can you please rectify my smal program, I tried to rectify it but I can't. 
 Many thanks in advance.
[[alternative HTML version deleted]]


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




-- 
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] tackle memory insufficiency for large dataset using save() load()?

2007-08-21 Thread Rolf Turner

On 22/08/2007, at 1:48 PM, Gabor Grothendieck wrote:

 See ?save .  The ... arguments are the ***names*** of the objects, not
 the objects
 so you want save(d, ...whatever...) not save(d, ...whatever...) .

I think this is wrong.  You want the objects not their names.

If you want to make use of object names, use the list argument.

I.e.

save(melvin,clyde,file=irving)

and

save(list=c(melvin,clyde),file=irving)

accomplish the same thing.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confidenti...{{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] tackle memory insufficiency for large dataset using save() load()?

2007-08-21 Thread Gabor Grothendieck
?save says its the names (not the objects) although I just
tried it and both save(iris, file = /iris.Rdata) and
save(iris, file = /iris.Rdata) seemed to work so you are
right that it seems to work with the objects, not just the names,\
although its not documented to do so.

Usage
save(..., list = character(0),
 file = stop('file' must be specified),
 ascii = FALSE, version = NULL, envir = parent.frame(),
 compress = !ascii, eval.promises = TRUE)

save.image(file = .RData, version = NULL, ascii = FALSE,
   compress = !ascii, safe = TRUE)

Arguments
... the names of the objects to be saved.
list A character vector containing the names of objects to be saved.

On 8/21/07, Rolf Turner [EMAIL PROTECTED] wrote:

 On 22/08/2007, at 1:48 PM, Gabor Grothendieck wrote:

  See ?save .  The ... arguments are the ***names*** of the objects, not
  the objects
  so you want save(d, ...whatever...) not save(d, ...whatever...) .

I think this is wrong.  You want the objects not their names.

If you want to make use of object names, use the list argument.

I.e.

save(melvin,clyde,file=irving)

and

save(list=c(melvin,clyde),file=irving)

accomplish the same thing.

cheers,

Rolf Turner

 ##
 Attention:
 This e-mail message is privileged and confidential. If you are not the
 intended recipient please delete the message and notify the sender.
 Any views or opinions presented are solely those of the author.

 This e-mail has been scanned and cleared by MailMarshal
 www.marshalsoftware.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] tackle memory insufficiency for large dataset using save() load()?

2007-08-21 Thread Rolf Turner

On 22/08/2007, at 2:52 PM, Gabor Grothendieck wrote:

 ?save says its the names (not the objects) although I just
 tried it and both save(iris, file = /iris.Rdata) and
 save(iris, file = /iris.Rdata) seemed to work so you are
 right that it seems to work with the objects, not just the names,\
 although its not documented to do so.

Yeah, you're right --- it works both ways.  I just looked at the
code and it converts the ... argument to a list of names using
as.character(substitute(list(...)))[-1].

These R Core people are sneaky-clever!

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confidenti...{{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] rectify a program of seasonal dummies matrix

2007-08-21 Thread Friedrich Schuster
Hello, 
 
the main problem seems to be the if else, should be else if. 

Your code is hard to read, maybe you should consider using more () {}: 

T - 100;
br - matrix(0,T,4);

for (i in 1:T) {
   for (j in 1:4) {
  if (i==j) {
 br[i,j] - 1;
   }
   else if ((abs(i-j)%%4)==0) {
  br[i,j] - 1;
}
else {
  br[i,j] - 0;
}
}
 }

A simpler approach is creating a diagonal matrix and multply it : 

# create small diagonal matrix
mat = diag(x=1, nrow=4, ncol=4);
mat
# multiply diagonal matrix and re-dimension it   to 4 cols
br - rep(mat, 25);
dim(br) - c(100, 4);
br;

Hope this helps, 
FS

-- 

Friedrich Schuster
mail at friedrich-schuster.de

__
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 installing updated version of vars package

2007-08-21 Thread Prof Brian Ripley
On Tue, 21 Aug 2007, sj wrote:

 All,

 I was looking onlin and noticed that the vars package (by Bernhard Pfaff)
 was recently updated (update date listed Aug 6, 2007) The updated packages
 has some features that I would find very useful. I have used the update
 packages function and vars was one of the packages identified as needing an
 update. I was able to updated and it appeared to work, however when  I load
 the package it does not seem to be the most recent version? Has anyone else
 had similar problems? Or does anyone have any suggestions?

 System Info:

 R 2.4.1

You need to update your R (as the posting guide asked you to before 
posting) or install the package from sources.

The binary builds are not updated for obsolete versions of R: the builds 
for 2.4.x stopped on 28 June.

 Windows XP
 install mirror: USA 3 (UCLA I think)

 thanks,

 Spencer

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

PLEASE do!


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


[R] open/execute/call/run an external file

2007-08-21 Thread STEPHEN M POWERS
I'm trying to figure out how to trigger a process from within R. I have an 
exectuable file that runs a Fortran model, but ideally, would like to run it 
from R. Note that I'm not talking about importing the function at all, passing 
variables, or anything complicated like that. I basically just want a script 
that double-clicks on a particular file and opens/runs it for me.

The idea here is that the executable Fortran file, when double clicked, simply 
draws all necessary inputs from text files within the same directory and I have 
no need to change this. So I've used R to summarize some raw data and format 
these required text input files in the way the Fortran executable requires, and 
also have scripts to interpret the Fortran text file outputs and summarize/plot 
them in R. The problem is I must run the first part of the R script to send 
data from R to the model, then double click the Fortran executable, then run 
the second part of the R script to get the model outputs into R, in three 
separate steps. Given that I may be doing this hundereds of times, I'd prefer 
to do it all in one step.

Any thoughts?---steve

__
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 on a flash drive

2007-08-21 Thread Prof Brian Ripley
On Wed, 22 Aug 2007, Williams Scott wrote:

 I often run R via a Ceedo virtualisation on a USB drive
 (http://www.ceedo.com/) with XP. It costs a few dollars to it this way,
 but is a very low stress installation and has worked flawlessly, albeit

It is not necessary though, as R does not need 'virtualisation'.  For 
Windows this is covered in the rw-FAQ Q2.6.

 a little slower (barely noticeable).

Perhaps the overhead of Credo?  Once R starts up (which does take longer 
on a slow drive) I found no time-able difference in 2.1.x (all the files 
frequently used from disc are cached on startup).

It would be nice to give the R developers the credit for writing R in such 
a way that it works well from slow media, instead of it being credited to 
an unnecessary commercial product.

 Very handy if you are often working
 on various machines without administrator rights (as I do in clinic) -
 just plug in your USB and go directly back to your project. It then
 removes any trace of you (so they say) when you log out. And you can use
 it for other software (within limits though) you might want to carry
 around.

Many sites would not allow programs to be run from a USB drive or make it 
a breach of usage conditions to do so.


 Hope that helps.

 Scott

 
 Scott Williams MD
 Peter MacCallum Cancer Centre
 Melbourne
 Australia

 -Original Message-
 From: John Kane [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, 21 August 2007 12:28 AM
 To: John Kane; Erin Hodgess; r-help@stat.math.ethz.ch
 Subject: Re: [R] R on a flash drive

 Oops meant to send this to the list.
 --- John Kane [EMAIL PROTECTED] wrote:


 --- Erin Hodgess [EMAIL PROTECTED] wrote:

 Dear R People:

 Has anyone run R from a flash drive, please?

 If so, how did it work, please?

 Yes I run R, occasionally, on a USB with no problem
 on
 WindowsXP. It works well, albeit a bit more slowly
 than from the hard drive which is as you would
 expect.

 The last time I upgraded the USB (to 2.5.0 ?) I
 simply
 downloaded R and installed it on the USB drive
 rather
 than the C: drive and then installed all my usual
 optional packages using the normal Rgui interface.

 I usually have R, Tinn-R and portable versions of
 OpenOoffice.org, and Firefox installed on the USB.


   Get news delivered with the All new Yahoo!
 Mail.  Enjoy RSS feeds right on your Mail page.
 Start today at
 http://mrd.mail.yahoo.com/try_beta?.intl=ca


 __
 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] open/execute/call/run an external file

2007-08-21 Thread Prof Brian Ripley
On Tue, 21 Aug 2007, STEPHEN M POWERS wrote:

 I'm trying to figure out how to trigger a process from within R. I have 
 an exectuable file that runs a Fortran model, but ideally, would like to 
 run it from R. Note that I'm not talking about importing the function at 
 all, passing variables, or anything complicated like that. I basically 
 just want a script that double-clicks on a particular file and 
 opens/runs it for me.

 The idea here is that the executable Fortran file, when double clicked, 
 simply draws all necessary inputs from text files within the same 
 directory and I have no need to change this. So I've used R to summarize 
 some raw data and format these required text input files in the way the 
 Fortran executable requires, and also have scripts to interpret the 
 Fortran text file outputs and summarize/plot them in R. The problem is I 
 must run the first part of the R script to send data from R to the 
 model, then double click the Fortran executable, then run the second 
 part of the R script to get the model outputs into R, in three separate 
 steps. Given that I may be doing this hundereds of times, I'd prefer to 
 do it all in one step.

 Any thoughts?---steve

It is described in the relevant manual: Writing R Extensions.
?system, and if this is Windows also ?shell and ?shell.exec.

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

When you do, you will see that we asked for your OS which is relevant 
here.

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