Re: [R] Date conversion problem using as.Date

2005-03-18 Thread Gabor Grothendieck
Vegard Andersen vegard.andersen at ism.uit.no writes: : : Hello! : : My problem is that the Julian date behind my dates seems to be wrong. I : will examplify my problem. : : t1 - 1998-11-20 : t2 - as.Date(t1) : # Here t2 is correctly 1998-11-20, but : date.mdy(t2) : $month : [1] 11 : $day :

Re: [R] Is a .R script file name available inside the script?

2005-03-18 Thread Gabor Grothendieck
Darren Weber darrenleeweber at gmail.com writes: : : Hi, : : if we have a file called Rscript.R that contains the following, for example: : : x - 1:100 : outfile = Rscript.Rout : sink(outfile) : print(x) : : and then we run : : source(Rscript.R) : : we get an output file called

Re: [R] newbie question about beta distribution

2005-03-20 Thread Gabor Grothendieck
faisal99 at inf.its-sby.edu writes: : : hi everyone, : I'm still a newbie in statistics, : : I have a question about beta distribution, that is, : : On the ref/tutorials I've found on the net, why beta distribution always : have value p(x) more than 1? Consider the uniform distribution on

Re: [R] Violin plot for discrete variables.

2005-03-21 Thread Gabor Grothendieck
Witold Eryk Wolski W.E.Wolski at ncl.ac.uk writes: : : Dear Rgurus, : : To my knowledge the best way to visualize the distribution of a discrete : variable X is : plot(table(X)) : : The problem which I have is the following. I have to discrete variables : X and Y which distribution I would

Re: [R] Read a dataset with different lengths

2005-03-21 Thread Gabor Grothendieck
Xiyan Lon xiyanlon at gmail.com writes: : : Dear useR again, : How can I read a dataset if lines in dataset did not have same : elements (have different lengths), For example: : : 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 : 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1,

Re: [R] Convex hull line coordinates..

2005-03-21 Thread Gabor Grothendieck
achilleas.psomas at wsl.ch writes: : : Hello R-Helpers.. : : I am still new in R and I have the following question.. : I am applying the function chull on a 2D dataset and have the convex hull : nicely : calculated and plotted. : Do you know if there is a way to extract the coordinates of the

Re: [R] flatten a matrix and unflatten it

2005-03-21 Thread Gabor Grothendieck
Bill Simpson William.Simpson at drdc-rddc.gc.ca writes: : : I want to flatten a matrix and unflatten it again. Please tell me how to : do it. : : 1. given a matrix: : x1 y1 z1 : x2 y2 z2 : ... : xk yk zk : convert it to a vector: : x1, y1, z1, x2, y2, z2, ..., xk, yk, zk : : 2. given a

Re: [R] problem in textConnection function

2005-03-21 Thread Gabor Grothendieck
Michael S michael_shen at hotmail.com writes: : : Dear all-helpers: : : I create one package ,code like this: : output - : function(x,y) : { : zz -textConnection(foo,w) : sink(zz) : a -5 : b -6 : z -a*b : z : e -spss : h -c(1,2,3) : ls() :

Re: [R] I modify my question in textconnection output

2005-03-21 Thread Gabor Grothendieck
Michael S michael_shen at hotmail.com writes: : : dear ALL-R-helper: : I modify my question in textconnection output: : I wrote one function in Rgui: : output - function(y){ : x - textConnection(foo,w) : sink(x) : a -5 : b -6 : z -a*b : z : e -spss :

Re: [R] Newbie: Matrix indexing

2005-03-22 Thread Gabor Grothendieck
Pascal BLEUYARD p.bleuyard at opgc.univ-bpclermont.fr writes: : : Hi all, : : I need to compute some occurence matrix: given a zero matrix and a set : of paired indexes, I want to store the number of occurences of each paired : index in a matrix. The paired indexes are stores as an index

Re: [R] r under linux: creating high quality bmp's for win users

2005-03-22 Thread Gabor Grothendieck
Can you provide a link. I did a google search and found something on a Japanese site but it turned out that the writer had made a mistake and it linked to wmf2eps, not eps2wmf. Christophe Pallier pallier at lscp.ehess.fr writes: : : Hello Christoph! : : In the past, I used an utility called

Re: [R] extracting numerical data from text field

2005-03-23 Thread Gabor Grothendieck
Luis Tercero luis.tercero at ebi-wasser.uni-karlsruhe.de writes: : : I have imported a data frame that looks like this: : :Measurement.Date.and.Time Z.Average..nm. PDI : 572 Dienstag, 22. Mrz 2005 11:05:59 366,4 0,468 : 573 Dienstag, 22. Mrz 2005 11:09:30 353,4

Re: [R] extracting numerical data from text field

2005-03-23 Thread Gabor Grothendieck
Gabor Grothendieck ggrothendieck at myway.com writes: Luis Tercero luis.tercero at ebi-wasser.uni-karlsruhe.de writes: : : I have imported a data frame that looks like this: : :Measurement.Date.and.Time Z.Average..nm. PDI : 572 Dienstag, 22. Mrz 2005 11:05:59

Re: [R] Fold in R?

2005-03-27 Thread Gabor Grothendieck
Seung Jun jun at cc.gatech.edu writes: : : Fold in Mathematica (or reduce in Python) works as follows: : : Fold[f, x, {a, b, c}] := f[f[f[x,a],b],c] : : That is, f is a binary operator, x is the initial value, and the results : are cascaded along the list. I've found it useful for reducing

Re: [R] Generating list of vector coordinates

2005-03-28 Thread Gabor Grothendieck
If the odometer order in your post is essential then you could try this: expand.grid(1:5, 1:4, 1:3)[,3:1] If R's reverse odometer order is ok then you could simplify it to this: expand.grid(1:3, 1:4, 1:5) On Mon, 28 Mar 2005 15:20:46 -0800, Ronnen Levinson [EMAIL PROTECTED] wrote:

Re: [R] Annotation metadata kills help.search

2005-03-28 Thread Gabor Grothendieck
This happened to me in R 2.1.0 (I forget which specific version since I now have March 27th) on Windows XP which I traced to package dataRep. Once I removed that package help.search worked again. On Mon, 28 Mar 2005 22:08:58 -0500, Gerard Tromp [EMAIL PROTECTED] wrote: Greetings! OS:

Re: [R] Recall() and sapply()

2005-03-30 Thread Gabor Grothendieck
I believe that the function that Recall executes is the function in which Recall, itself, is evaluated -- not the function in which Recall appears. In normal cases these are the same but if you pass Recall to another function then they are not the same. Here Recall is being passed to sapply

Re: [R] Survey of moving window statistical functions - still looking f or fast mad function

2005-04-01 Thread Gabor Grothendieck
Jaroslaw's article was great. In fact, it was used as the basis for rapply and some optimized special cases that will be included in the R 2.1.0 version of zoo (which have been coded but not yet released). Regarding numerically stable summation, check out the idea behind the following which I

Re: [R] factor to numeric in data.frame

2005-04-02 Thread Gabor Grothendieck
Try this: data.matrix(df.f12) On Apr 2, 2005 6:01 AM, Heinz Tuechler [EMAIL PROTECTED] wrote: Dear All, Assume I have a data.frame that contains also factors and I would like to get another data.frame containing the factors as numeric vectors, to apply functions like sapply(..., median) on

Re: [R] extract date

2005-04-05 Thread Gabor Grothendieck
I just started using gmail and one thing that I thought would be annoying but sometimes is actually interesting are the ads at the right hand side. They are keyed off the content of the email and in the case of your post produced: http://www.visibone.com/regular-expressions/?via=google120

Re: [R] lists: removing elements, iterating over elements,

2005-04-05 Thread Gabor Grothendieck
On Apr 5, 2005 1:36 PM, Paul Johnson [EMAIL PROTECTED] wrote: I'm writing R code to calculate Hierarchical Social Entropy, a diversity index that Tucker Balch proposed. One article on this was published in Autonomous Robots in 2000. You can find that and others through his web page at Georgia

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Gabor Grothendieck
Some other advantages of making your own package are: - you can use help.search to search for your own functions even if you don't load the package - if you can't even remember where your functions are (and I often can't) then you may not remember what they do either and packaging them

Re: [R] Is a .R script file name available inside the script?

2005-04-06 Thread Gabor Grothendieck
? Is the input script file anargument to R and therefore available in something like argv? On Mar 18, 2005 8:00 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: Darren Weber darrenleeweber at gmail.com writes: : : Hi, : : if we have a file called Rscript.R that contains the following, for example: : : x - 1

Re: [R] How to do aggregate operations with non-scalar functions

2005-04-07 Thread Gabor Grothendieck
On Apr 7, 2005 1:18 AM, Itay Furman [EMAIL PROTECTED] wrote: On Tue, 5 Apr 2005, Gabor Grothendieck wrote: On Apr 5, 2005 6:59 PM, Itay Furman [EMAIL PROTECTED] wrote: Hi, I have a data set, the structure of which is something like this: a - rep(c(a, b), c(6,6)) x - rep(c(x, y

Re: [R] package

2005-04-07 Thread Gabor Grothendieck
On Apr 7, 2005 8:43 AM, Gregory BENMENZER [EMAIL PROTECTED] wrote: hello, I created a package with my functions, and i wand to hide the code of some functions. Could you help me ? Grégory There was some discussion on the list that there is work being done on an R compiler. I don't

Re: [R] NA in table with integer types

2005-04-08 Thread Gabor Grothendieck
On Apr 8, 2005 9:05 AM, Paul Rathouz [EMAIL PROTECTED] wrote: OK. Thanks. So, if you use table() on a factor that contains NA's, but for which NA is not a level, is there any way to get table to generate an entry for the NAs? For example, in below, even exclude=NULL will not give me an

Re: [R] the difference between UseMethod and NextMehod?

2005-04-10 Thread Gabor Grothendieck
ronggui 0034058 at fudan.edu.cn writes: : hi,usRs,i am studing the R programming,but i can not get the point abut the difference between UseMethod : and NextMehod.i have read the manual and try to find the solutin from internet,but i still not master it : well.so anyone can give me a guide?it

Re: [R] How to change letters after space into capital letters

2005-04-11 Thread Gabor Grothendieck
On Apr 11, 2005 6:22 AM, Wolfram Fischer [EMAIL PROTECTED] wrote: What is the easiest way to change within vector of strings each letter after a space into a capital letter? E.g.: c( this is an element of the vector of strings, second element ) becomes: c( This Is An Element Of The

Re: [R] Sweave and abbreviating output from R

2005-04-11 Thread Gabor Grothendieck
On Apr 11, 2005 7:22 AM, Gavin Simpson [EMAIL PROTECTED] wrote: Dear List, I'm using Sweave to produce a series of class handouts for a course I am running. The students in previous years have commented about wanting output within the handouts so they can see what to expect the output to

Re: [R] the difference between x1 and x1

2006-04-20 Thread Gabor Grothendieck
Try this: # test data set.seed(1) DF - data.frame(x1 = rnorm(5), x2 = rnorm(5), x3 = rnorm(5)) DF model.list - c(x2, x3) # transform for(v in model.list) DF[v] - floor(DF[v]) On 4/20/06, Chad Reyhan Bhatti [EMAIL PROTECTED] wrote: Hello, I am not sure what to write in the subject line, but I

Re: [R] Considering port of SAS application to R

2006-04-21 Thread Gabor Grothendieck
R supports a number of databases and if you only need to work with a small amount of data at once it should be readily do-able; however, R keeps objects in memory and if you need large amounts at once then you could run into problems. Note that S-Plus keeps objects on disk and has other features

Re: [R] Creat new column based on condition

2006-04-21 Thread Gabor Grothendieck
Try: V1 - matrix(c(10, 20, 30, 10, 10, 20), nc = 1) V2 - 4 * (V1 == 10) + 6 * (V1 == 20) + 10 * (V1 == 30) or V2 - matrix(c(4, 6, 10)[V1/10], nc = 1) On 4/21/06, Sachin J [EMAIL PROTECTED] wrote: Hi, How can I accomplish this task in R? V1 10 20 30 10 10 20

Re: [R] Creat new column based on condition

2006-04-21 Thread Gabor Grothendieck
Gabor Grothendieck [EMAIL PROTECTED] wrote: Try: V1 - matrix(c(10, 20, 30, 10, 10, 20), nc = 1) V2 - 4 * (V1 == 10) + 6 * (V1 == 20) + 10 * (V1 == 30) or V2 - matrix(c(4, 6, 10)[V1/10], nc = 1) On 4/21/06, Sachin J wrote: Hi, How can I accomplish this task in R? V1 10 20

Re: [R] Creat new column based on condition

2006-04-21 Thread Gabor Grothendieck
Here is a compact solution using approx: DF$V2 - approx(c(10, 20, 30), c(4,6,10), DF$V1)$y On 4/21/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: DF - data.frame(V1 = c(10, 20, 30, 10, 10, 20)) DF$V2 - with(DF, 4 * (V1 == 10) + 6 * (V1 == 20) + 10 * (V1 == 30)) DF$V3 - c(4, 6, 10)[DF$V1

Re: [R] Minor documentation issue

2006-04-21 Thread Gabor Grothendieck
It is matched by the first argument which is called from even though, as the documentation indicates under the explanation of the last form, it refers to the ending value. Note, for example, that seq(from = 3) gives 1:3 and not 3:1. Also the help file does say: The interpretation of the

Re: [R] Reorganizing rows and columns

2006-04-23 Thread Gabor Grothendieck
Use merge: # test data both - list(structure(list(Doc = c(5, 9, 7, 5, 7, 9), Query = c(1, 1, 1, 2, 2, 2), Rank = c(1, 2, 3, 1, 2, 3)), .Names = c(Doc, Query, Rank), class = data.frame, row.names = c(1, 2, 3, 4, 5, 6)), structure(list(Doc = c(4, 5, 9, 8, 5, 7), Query = c(1, 1, 1, 2, 2, 2), Rank =

Re: [R] arrange data for simple regression analysis

2006-04-24 Thread Gabor Grothendieck
Here are a couple of possibilities using the builtin iris data set. Note that although the coefficients come out the same, the degrees of freedom, etc., would differ: n - rep(1:3, 50) lm(Petal.Length ~ Petal.Width, iris, weight = n) Call: lm(formula = Petal.Length ~ Petal.Width, data = iris,

Re: [R] Sending an ESC command to the console from wihtin a script

2006-04-24 Thread Gabor Grothendieck
RSiteSearch(clear screen) will locate Windows code to send a ctrl-L to the screen that you can modify. On 4/24/06, Tolga Uzuner [EMAIL PROTECTED] wrote: Hi, Is there a way to send an ESC command to the console from within a script window, without using the mouse ? Thanks, Tolga

Re: [R] Handling large dataset dataframe

2006-04-24 Thread Gabor Grothendieck
You just need the much smaller cross product matrix X'X and vector X'Y so you can build those up as you read the data in in chunks. On 4/24/06, Sachin J [EMAIL PROTECTED] wrote: Hi, I have a dataset consisting of 350,000 rows and 266 columns. Out of 266 columns 250 are dummy variable

Re: [R] Change the language of the labels in a graph

2006-04-24 Thread Gabor Grothendieck
This works for me on my Windows XP system: Sys.putenv(LANGUAGE=FR); Sys.setlocale(LC_ALL,FR) On 4/24/06, Lapointe, Pierre [EMAIL PROTECTED] wrote: Hello, How do you change the language of the labels in a graph. In this example, I want to get French labels by changing Sys.putenv. I should

Re: [R] Handling large dataset dataframe [Broadcast]

2006-04-24 Thread Gabor Grothendieck
, and accumulate (i.e., add) them. There are examples in S Programming, taken from independent replies by the two authors to a post on S-news, if I remember correctly. Andy From: Sachin J Gabor: Can you elaborate more. Thanx Sachin Gabor Grothendieck wrote: You just need the much

Re: [R] Add qoutation marks and combine values in a vector

2006-04-25 Thread Gabor Grothendieck
Use dQuote. Assuming you have a data frame with the column as factors: DF - data.frame(x = letters) # test data levels(DF$x) - dQuote(levels(DF$x)) On 4/25/06, Jerry Pressnell [EMAIL PROTECTED] wrote: I wish to place quotation marks around each element of the following list;

Re: [R] R help

2006-04-25 Thread Gabor Grothendieck
A similar question was just asked. See: http://tolstoy.newcastle.edu.au/R/help/06/04/25898.html On 4/25/06, Erez [EMAIL PROTECTED] wrote: Hello, I'm working with large matrix data and i would like to know if there is any way to reduce the size of it because even that I'm increasing the

Re: [R] by() and CrossTable()

2006-04-25 Thread Gabor Grothendieck
At least for this case I think you could get the effect without modifyiing CrossTable like this: as.CrossTable - function(x) structure(x, class = c(CrossTable, class(x))) print.CrossTable - function(x) for(L in x) cat(L, \n) by(warpbreaks, warpbreaks$tension, function(x)

Re: [R] Questions to RDCOMClient

2006-04-25 Thread Gabor Grothendieck
On 4/25/06, Dr. Michael Wolf [EMAIL PROTECTED] wrote: 3. RDCOMCLient and Excel Manual === Do you know a good overview of using Excel VBA code via RDCOMClient (e. g. sh$Select())? Are there people interesting in working out such a paper? I could contribute some

Re: [R] www.r-project.org

2006-04-25 Thread Gabor Grothendieck
On 4/25/06, hadley wickham [EMAIL PROTECTED] wrote: The R Web site is working fine. Even if it is not relifted from a long time, it is functional. So, this is the point... and it should remain, at least, as functional as it is. As an experienced user of the R website, this probably is true

Re: [R] www.r-project.org

2006-04-25 Thread Gabor Grothendieck
Its not hard if you know what to do but if you don't then its a nuisance to figure it out every time. On 4/25/06, Gavin Simpson [EMAIL PROTECTED] wrote: On Tue, 2006-04-25 at 14:09 -0400, Gabor Grothendieck wrote: On 4/25/06, hadley wickham [EMAIL PROTECTED] wrote: The R Web site

Re: [R] www.r-project.org

2006-04-25 Thread Gabor Grothendieck
On Windows, right click the web page, choose Properties and copy the url there. On 4/25/06, Spencer Graves [EMAIL PROTECTED] wrote: see inline hadley wickham wrote: The R Web site is working fine. snip As an experienced user of the R website, this probably is true for you. However,

Re: [R] new.frame()

2006-04-26 Thread Gabor Grothendieck
Also, the proto and R.oo packages provide object oriented ways of working with environments. On 4/26/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: ?new.env ?local should help you. R works with environments, basically a frame plus an enclosure. On Wed, 26 Apr 2006, Anna Whitfield wrote:

Re: [R] environment

2006-04-26 Thread Gabor Grothendieck
A third possibility is to using the proto package and define a proto object (an environment with special meaning for $) containing the two components .x and g like this: library(proto) p - proto(.x = 2, g = function(.) { print(.$.x); .$.x - 3 }) p$.x # 2 print(p$g()) # 2, 3 p$.x # 3 or you can

Re: [R] environment

2006-04-26 Thread Gabor Grothendieck
Also, if you don;t need to create child objects which override .x, and I don't think you do here, p could be further simplified to this (only the print statement has been changed): p - proto(.x = 2, g = function(.) { print(.x); .$.x - 3 }) On 4/26/06, Gabor Grothendieck [EMAIL PROTECTED] wrote

Re: [R] About regression and plot

2006-04-26 Thread Gabor Grothendieck
On 4/26/06, Daniel Yang [EMAIL PROTECTED] wrote: --- I changed to format to text instead of html --- Dear R-help, This is my first R day. I want to ask some more beginner's questions. Read the posting guide at the bottom of each post to r-help. Q1. How can I obtain the covariance matrix

Re: [R] Were to find appropriate functions for a given task in R

2006-04-26 Thread Gabor Grothendieck
There is a reference sheet here: http://www.rpad.org/Rpad/R-refcard.pdf a function finder here: http://biostat.mc.vanderbilt.edu/s/finder/find.html and task views here: http://cran.r-project.org/src/contrib/Views/ Also use of RSiteSearch and help.search from within R can be helpful. On

Re: [R] www.r-project.org

2006-04-26 Thread Gabor Grothendieck
Maybe a separate web site that shows R off or maybe just a pointer to the R Graph Gallery. On 4/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote: Romain Francois wrote: Dear R users and developpers, My question is adressed to both of you, so I choose R-help to post it. Are there any plans

Re: [R] help using tapply

2006-04-26 Thread Gabor Grothendieck
On 4/26/06, Dimitri Szerman [EMAIL PROTECTED] wrote: Dear R-mates, # Here's what I am trying to do. I have a dataset like this: id = c(rep(1,8), rep(2,8)) dur1 - c( 17,18,19,18,24,19,24,24 ) est1 - c( rep(1,5), rep(2,3) ) dur2 - c(1,1,3,4,8,12,13,14) est2 - rep(1,8) mydata =

Re: [R] copying previously installed libraries to R 2.3.0

2006-04-26 Thread Gabor Grothendieck
@stat.math.ethz.ch Subject: [R] copying previously installed libraries to R 2.3.0 hi all, is there a new mechanism in R 2.3.0 for copying libraries from, say, R 2.2.1 to R 2.3.0? i ask because gabor grothendieck comments in his copydir.bat (from gabor's batchfiles at: http://cran.r-project.org

Re: [R] problem with get command

2006-04-26 Thread Gabor Grothendieck
ov$vn1 is not a variable. It is the result of applying the $ function to the ov and vn1 arguments. For example, using BOD which is a data frame that comes with R, rather than get(BOD$Time) use get(BOD)[[Time]] On 4/26/06, Thomas Davidoff [EMAIL PROTECTED] wrote: I don't understand what my

Re: [R] stl function

2006-04-26 Thread Gabor Grothendieck
stl does this internally: x - na.action(as.ts(x)) so stl(x, s.window, na.action = f) is the same as stl(f(as.ts(x)), s.window) e.g. nottem[25] - NA # nottem is a built in data set in R stl(nottem, per) # error stl(nottem, per, na.action = na.contiguous) library(zoo) stl(nottem, per,

Re: [R] gmane?

2006-04-27 Thread Gabor Grothendieck
They can be found here: http://dir.gmane.org/gmane.comp.lang.r.announce Announcements about the development of the R Project for Statistical Computing and the availability of new code. (read-only) http://dir.gmane.org/gmane.comp.lang.r.deal Learning Bayesian networks in R - the 'deal' package

Re: [R] gmane?

2006-04-27 Thread Gabor Grothendieck
Assuming you are aware that the dir pages at gmane provide the key links for each group, googling for: dir gmane r-help gets it as the first hit. On 4/27/06, Jose Quesada [EMAIL PROTECTED] wrote: Thanks all, It was very surprising that I couldn't find it. I searched news.gmane.orgfor

Re: [R] State space AR models in R: some examples

2006-04-27 Thread Gabor Grothendieck
Check out the sspir package and http://www.jstatsoft.org/index.php?vol=16 On 4/27/06, Pablo Almaraz [EMAIL PROTECTED] wrote: Hi all, Does anyone have an example of an autoregressive (AR) time-series model specified as a state space model in R? That is, I want to go beyond the locally linear

Re: [R] scope of variable/object ?

2006-04-27 Thread Gabor Grothendieck
You probably need to contact the developer of pamr but short of investigating it, a workaround might be to put a copy of myd2 into the global environment since it likely will at least look there, e.g. add this line to: assign(myd2, myd2, .GlobalEnv) domat. On 4/27/06, Tim Smith [EMAIL

Re: [R] Break into Parts

2006-04-28 Thread Gabor Grothendieck
Try this: tapply(x, cut(x, 12), sd) On 4/28/06, sumanta basak [EMAIL PROTECTED] wrote: Hi R-Experts, I have a vector of length 72. I want to break it into 12 parts and want to take standerd deviation of each group. Please help me in this regard. Thanks, Sumanta.

Re: [R] Break into Parts

2006-04-28 Thread Gabor Grothendieck
Good point. Following Andy's comment sd(matrix(sort(x), nc=12)) could also be used if you want them broken up by 6 smallest, next 6 smallest, etc. although there might be differences in the case of ties. Using tapply here are a number of ways of breaking it up (the first three give the same

Re: [R] plot acf of several timeseries

2006-04-28 Thread Gabor Grothendieck
Try this: lapply(names(tslist), function(nm) acf(tslist[[nm]], main = nm)) On 4/28/06, Ulf Mehlig [EMAIL PROTECTED] wrote: Hello r-help, I have a couple of time-series of different length and I would like to produce a simple overview plot showing the autocorrelation functions of the

Re: [R] copying previously installed libraries to R 2.3.0

2006-04-28 Thread Gabor Grothendieck
, R.matlab, R.oo. It will truncate new directories as clim, haplo, hier, pls, R. On 4/26/06, Thomas Harte [EMAIL PROTECTED] wrote: hi all, is there a new mechanism in R 2.3.0 for copying libraries from, say, R 2.2.1 to R 2.3.0? i ask because gabor grothendieck comments in his copydir.bat

Re: [R] aggregating columns in a data frame in different ways

2006-04-28 Thread Gabor Grothendieck
Here are three possibilities: 1. aggregate on the columns that you want to sum and aggregate on the columns that you want to average and then merge them: By - A[, 2, drop = FALSE] merge(aggregate(A[, 3, drop = FALSE], By, sum), aggregate(A[, 4, drop = FALSE], By, mean)) 2. use by: f -

Re: [R] How to rep a matrix by row?

2006-04-29 Thread Gabor Grothendieck
Try this where DF is your data frame: DF[rep(seq(nrow(DF)), each = 3), ] On 4/29/06, Jiantao Shi [EMAIL PROTECTED] wrote: Hi, i have a dataframe like this, SourceTreatDrugReplicate control0A1 control10A2 control30A3 10A1

Re: [R] Reshaping genetic data from long to wide

2006-04-29 Thread Gabor Grothendieck
You might want to check the double check the list archives https://www.stat.math.ethz.ch/pipermail/r-help/ to see if your posts got through or not just in case its just some problem in displaying your own posts. On 4/29/06, Farrel Buchinsky [EMAIL PROTECTED] wrote: Gabor Grothendieck

Re: [R] Package docs for CRAN

2006-04-30 Thread Gabor Grothendieck
If your package is called mypkg you could create a mypkg-package.Rd file. e.g. library(dyn) library(help = dyn) # note that mypkg-package is listed package?dyn ?dyn-package # same and you could add one or more vignettes, e.g. library(zoo) library(help = zoo) # note that the 2 vignettes are

Re: [R] Duration labels on plot axes

2006-04-30 Thread Gabor Grothendieck
The times class in chron will give hours and minutes. e.g. library(times) plot(times(0:23/23), 0:23) and you could modify chron:::axis.times for the others. On 4/30/06, Duncan Murdoch [EMAIL PROTECTED] wrote: I have a variable containing a measurement of a duration in seconds which I would

Re: [R] general help on R and factor in R and a few simple comment from a newbie

2006-04-30 Thread Gabor Grothendieck
On 4/30/06, Guojun Zhu [EMAIL PROTECTED] wrote: Hi. I am starting to learn R for a course project. I am relative OK c++ programer. I found the R is very different. I have read the an introduction to R. I have to say it is not very newbie friendly. It does not explain many things

Re: [R] Duration labels on plot axes

2006-04-30 Thread Gabor Grothendieck
That should have been: library(chron) plot(times(0:23/24), 0:23) On 4/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: The times class in chron will give hours and minutes. e.g. library(times) plot(times(0:23/23), 0:23) and you could modify chron:::axis.times for the others. On 4/30/06

Re: [R] Yet another help needed

2006-04-30 Thread Gabor Grothendieck
Look at ?filter ?embed rollmean in the zoo package running in the gtools package runmean in the caTools package The last one is probably the fastest. On 4/30/06, Guojun Zhu [EMAIL PROTECTED] wrote: I have a big data.frame with abou 20 column and 60,000 rows for analyze. Let us say I had a

Re: [R] table of means/medians across bins used for a histogram

2006-04-30 Thread Gabor Grothendieck
My understanding is that you want to replace each rate with its average over the associated bin and then plot age against that. In that case try this: DF # test data age rate bin 1 0.002 10.0 A 2 0.045 0.1 B 3 0.130 15.0 A 4 0.150 34.0 D with(DF, plot(ave(rate, bin), age))

Re: [R] table of means/medians across bins used for a histogram

2006-04-30 Thread Gabor Grothendieck
Or perhaps a bit simpler: plot(age ~ ave(clock, bin), DF) On 4/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: My understanding is that you want to replace each rate with its average over the associated bin and then plot age against that. In that case try this: DF # test data age

Re: [R] pulling items out of a lm() call

2006-05-01 Thread Gabor Grothendieck
Try this: # test data fo - y ~ female + I(age^2) + female:black + (age + education) * female # create a list of form list(y = as.name(z.y), ...) for use with substitute L - sapply(all.vars(fo), function(nm) as.name(paste(z, nm, sep = .))) do.call(substitute, list(fo, L)) On 5/1/06, Andrew

Re: [R] How to strip one term from a data.frame? + How to write long line in script?

2006-05-01 Thread Gabor Grothendieck
Using the built in data frame iris, which has 5 columns, regress Sepal.Length against all other variables except the last one: lm(Sepal.Length ~., iris[1:4]) On 5/1/06, Guojun Zhu [EMAIL PROTECTED] wrote: I need to run a regression with 14 normal variables and 20 dummy variables. All the data

Re: [R] efficiency in merging two data frames

2006-05-01 Thread Gabor Grothendieck
Some functions that may be of help: ?aggregate.ts ?cbind ?merge and in the zoo package ?as.yearmon ?as.yearqtr ?aggregate.zoo ?merge.zoo On 5/1/06, Guojun Zhu [EMAIL PROTECTED] wrote: I have two data sets about lots of companies' stock and fiscal data. One is monthly data with about

Re: [R] How to specify function arguments that are used in different places

2006-05-01 Thread Gabor Grothendieck
You could have a list of args for each one like this: # test data x - list(data = c(1,3,5), points = c(2,4)) myfunc - function(x, plot.args = NULL, points.args = NULL) { do.call(plot, c(list(x$data), plot.args)) do.call(points, c(list(x$points), points.args)) } myfunc(x,

Re: [R] table of means/medians across bins used for a histogram

2006-05-01 Thread Gabor Grothendieck
Grothendieck [EMAIL PROTECTED] wrote: Or perhaps a bit simpler: plot(age ~ ave(clock, bin), DF) On 4/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: My understanding is that you want to replace each rate with its average over the associated bin and then plot age against

Re: [R] Adding elements in an array where I have missing data.

2006-05-01 Thread Gabor Grothendieck
Here are a few alternatives: replace(a, is.na(a), 0) + b ifelse(is.na(a), 0, a) + b mapply(sum, a, b, MoreArgs = list(na.rm = TRUE)) On 5/1/06, John Kane [EMAIL PROTECTED] wrote: This is a simple question but I cannot seem to find the answer. I have two vectors but with missing data and I

Re: [R] Pasting data into scan()

2006-05-01 Thread Gabor Grothendieck
On 5/1/06, Murray Jorgensen [EMAIL PROTECTED] wrote: The file TENSILE.DAT from the Hand et al Handbook of Small Data Sets looks like this: 0.023 0.032 0.054 0.069 0.081 0.094 0.105 0.127 0.148 0.169 0.188 0.216 0.255 0.277 0.311 0.361 0.376 0.395 0.432 0.463

Re: [R] Still help needed on embeded regression

2006-05-02 Thread Gabor Grothendieck
Using runmean from caTools the first one below does it in under 1 second but will not handle NAs. The second one takes under 15 seconds and handles them by replacing them with linear approximations. Note that k must be odd. # 1 library(caTools) set.seed(1) system.time({ y -

Re: [R] Still help needed on embeded regression

2006-05-02 Thread Gabor Grothendieck
, Guojun Zhu [EMAIL PROTECTED] wrote: Sorry to bother you guys again. This is great. But this is for 61 number and the second case will change 60 to 61. run* only accept odd number window. How to get around it with 60? Any suggestion? Thanks. --- Gabor Grothendieck [EMAIL PROTECTED] wrote

Re: [R] evaluation of expressions

2006-05-02 Thread Gabor Grothendieck
Try this: e - expression(glm(y ~ age)) eval(e) or this: chr - glm(y ~ age) eval(parse(text = chr)) On 5/2/06, Andrew Gelman [EMAIL PROTECTED] wrote: Hi, all. I'm trying to automate some regression operations in R but am confused about how to evaluate expressoins that are expressed as

Re: [R] Adding elements in an array where I have missing data.

2006-05-02 Thread Gabor Grothendieck
On 5/2/06, Berton Gunter [EMAIL PROTECTED] wrote: Here are a few alternatives: replace(a, is.na(a), 0) + b ifelse(is.na(a), 0, a) + b mapply(sum, a, b, MoreArgs = list(na.rm = TRUE)) Well, Gabor, if you want to get fancy... evalq({a[is.na(a)]-0;a})+b Note that the evalq can

Re: [R] Adding elements in an array where I have missing data.

2006-05-02 Thread Gabor Grothendieck
and mapply solutions do not change a. On 5/2/06, Berton Gunter [EMAIL PROTECTED] wrote: Below. -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 10:42 AM To: Berton Gunter Cc: John Kane; R R-help Subject: Re: [R] Adding elements

Re: [R] Use predict.lm

2006-05-02 Thread Gabor Grothendieck
Try this: # regression of Sepal.Length on cols 2 and 4 using first 100 rows iris.lm - lm(Sepal.Length ~ ., iris[,c(1,2,4)], subset = 1:100) # now do it with next 50 rows predict(update(iris.lm, subset = 101:150)) # double check - this gives same result as last line predict(lm(Sepal.Length ~ .,

Re: [R] Time series plot

2006-05-02 Thread Gabor Grothendieck
Try this (where you can replace textConnection(L) with name of file containing data): L - 01/02/1990 0.531 0.479 01/03/1990 0.510 0.522 01/06/1990 0.602 0.604 library(zoo) z - read.zoo(textConnection(L), format = %m/%d/%Y) plot(z, plot.type = single) This will give more info on zoo:

Re: [R] Use predict.lm

2006-05-02 Thread Gabor Grothendieck
, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try this: # regression of Sepal.Length on cols 2 and 4 using first 100 rows iris.lm - lm(Sepal.Length ~ ., iris[,c(1,2,4)], subset = 1:100) # now do it with next 50 rows predict(update(iris.lm, subset = 101:150)) # double check - this gives same

Re: [R] Still help needed on embeded regression

2006-05-02 Thread Gabor Grothendieck
: It does not work though. How is the lag work? How does the lag work? I read the help and do not quite understand. Here is a test y [1] 1 2 3 4 5 6 7 8 9 10 coredata(lag(y,-1)) [1] 1 2 3 4 5 6 7 8 9 10 attr(,tsp) [1] 2 11 1 --- Gabor Grothendieck [EMAIL PROTECTED

Re: [R] Listing Variables

2006-05-03 Thread Gabor Grothendieck
Column names in iris that contain the string Sepal: grep(Sepal, names(iris), value = TRUE) On 5/3/06, Farrel Buchinsky [EMAIL PROTECTED] wrote: How does one create a vector whose contents is the list of variables in a dataframe pertaining to a particular pattern? This is so simple but I

Re: [R] Math expressions in pie chart labels?

2006-05-03 Thread Gabor Grothendieck
On 5/3/06, Uwe Ligges [EMAIL PROTECTED] wrote: Johannes Graumann wrote: On Tuesday 02 May 2006 23:33, Uwe Ligges wrote: Then please read ?plotmath and use it: labels = expression( = 0.66, == 0.33, = -0.33, = -0.66) Error in lab != : comparison is not allowed for expressions

Re: [R] sprintf question

2006-05-03 Thread Gabor Grothendieck
Try this: do.call(sprintf, c(%9.2f\t%d\t%d\t%8.3f, as.list(v[iv]))) On 5/3/06, Paul Roebuck [EMAIL PROTECTED] wrote: How would one go about getting sprintf to use the values of a vector without having to specify each argument individually? v - c(1, 2, -1.197114, 0.1596687) iv - c(3, 1,

Re: [R] factor to real - best way to convert

2006-05-03 Thread Gabor Grothendieck
You can use as.is = TRUE arg to read.xls to get character data rather than factors. On 5/3/06, Knut Krueger [EMAIL PROTECTED] wrote: I have got factor from read.xls: is(factor_value) [1] factor oldClass [288] -0.32 0.180.180.18-0.32 0.180.68 [295] 0.680.18

Re: [R] Math expressions in pie chart labels?

2006-05-03 Thread Gabor Grothendieck
As a workaround you could use pie3D in the plotrix package with height=0 and theta=pi, e.g. library(plotrix) pie3D(1:3, height = 0, theta = pi, labels = expression( = 1, == 2, = 3)) On 5/3/06, Johannes Graumann [EMAIL PROTECTED] wrote: On Wednesday 03 May 2006 09:05, Uwe Ligges wrote:

Re: [R] Aggregate?

2006-05-03 Thread Gabor Grothendieck
Suppose we want to sum C over levels of A and that B is constant within levels of A. Then: DF - data.frame(A = gl(2,2), B = gl(2,2), C = 1:4) # test data do.call(rbind, by(DF, DF$A, function(x) replace(x[1,], C, sum(x$C On 5/3/06, Guenther, Cameron [EMAIL PROTECTED] wrote: Hello, I

Re: [R] do.call in 2.3.0 vers 2.3.x

2006-05-04 Thread Gabor Grothendieck
See: https://www.stat.math.ethz.ch/pipermail/r-devel/2006-May/037542.html On 5/4/06, Dieter Menne [EMAIL PROTECTED] wrote: Dear R-Core, after switching to 2.3.0, all my trusted do.call constructs that worked in 2.2 and earlier fail. I noted that changes were introduced to do.call, but I

Re: [R] combined multiple observations

2006-05-04 Thread Gabor Grothendieck
Assuming DF is your data frame, try this: aggregate(DF[,0-1:2], DF[,1:2], sum) On 5/4/06, YIHSU CHEN [EMAIL PROTECTED] wrote: Dear R users: I have a data frame as follows, where e1-e3 are indicator variables with value equal 0 or 1. St County e1 e2 e3 1 2 1 0 0 1

<    5   6   7   8   9   10   11   12   13   14   >