Re: [R] List to Array

2006-04-05 Thread Gabor Grothendieck
/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Werner Wernersen [EMAIL PROTECTED] To: Gabor Grothendieck [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Wednesday, April 05, 2006 3:55 PM Subject: Re: [R] List to Array Oh yes, I

Re: [R] determine dimension on which by() applies

2006-04-05 Thread Gabor Grothendieck
By works on the rows or first dimension. See ?by, ?apply, ?aperm ?tapply On 4/5/06, Werner Wernersen [EMAIL PROTECTED] wrote: Hi, having solved one problem with your kindest help I directly ran into the next one: I now have a 4-dimensional array and I want to aggregate subsets (sum up

Re: [R] Evaluating a function with another function

2006-04-06 Thread Gabor Grothendieck
I assume you want a list containing length(x) data frames, one per list component. If that's it try this: test - function(x = 1:4, s = 1:2, rangit = 0:11) lapply(x, function(x) data.frame(rangit, y = x+s[1]+rangit, p=x+s[2]+rangit)) test() # test run On 4/6/06, Guenther, Cameron [EMAIL

Re: [R] Indexing With List Of Vectors (Replacement)

2006-04-06 Thread Gabor Grothendieck
Try this: do.call([-, c(list(b), idx, list(a))) On 4/6/06, Paul Roebuck [EMAIL PROTECTED] wrote: I have the following: a - matrix(1:10, nrow = 2, byrow = TRUE) b - array(as.integer(0), c(7, 5)) idx - list() length(idx) - 2 dim(idx) - c(1, 2) idx[[1]] - as.integer(1:2) idx[[2]] -

Re: [R] reshape question

2006-04-06 Thread Gabor Grothendieck
Just follow this example from example(reshape): reshape(wide, idvar=Subject, varying=list(names(wide)[2:12]), v.names=conc, direction=long) like this: long - reshape(dd, direction = long, varying = list(names(dd)[5:7]), idvar = v, v.names = x, times = paste(value, 1:3,

Re: [R] Referencing variables in a dataframe.

2006-04-06 Thread Gabor Grothendieck
Here are two ways: with(iris, Sepal.Length + Sepal.Width) attach(iris) Species On 4/6/06, Brian Quinif [EMAIL PROTECTED] wrote: I have a question about how to reference variables in a dataframe. Normally, after I have read in some Stata data using the following command all -

Re: [R] Financial functions

2006-04-06 Thread Gabor Grothendieck
See the first two hits for: RSiteSearch(IRR) On 4/6/06, Liaw, Andy [EMAIL PROTECTED] wrote: Those functions in Excel are for computing things like interest payment for fixed interest rate loan, etc. RSiteSearch() doesn't turn up anything useful, so I'd guess no one has written them. Good

Re: [R] creating files using for loop

2006-04-06 Thread Gabor Grothendieck
See ?paste and try: paste(sub.dataset[i], tex, sep = .) On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: I would like to use a for loop to run estimations on 12 different subsets of a dataset. I have the basics of my script figured out, but I am having problems getting the loop to name some

Re: [R] creating files using for loop

2006-04-07 Thread Gabor Grothendieck
in it: x - paste(101, tex, sep = .) x [1] 101.tex cat(x) 101.tex nchar(x) [1] 7 Note that there are 7 characters in x. Thanks, BQ 2006/4/7, Gabor Grothendieck [EMAIL PROTECTED]: See ?paste and try: paste(sub.dataset[i], tex, sep = .) On 4/7/06, Brian Quinif [EMAIL PROTECTED

Re: [R] saving estimates from a for loop for later use

2006-04-07 Thread Gabor Grothendieck
Another possibility is to create a data.frame. I've just put one statistic, sum, in it but you could put in as many as you like: g - expand.grid(i = 1:2, j = 1:2, k = 1:3) f - function(x) with(x, c(i = i, j = j, k = k, sum = i+j+k)) do.call(rbind, lapply(split(g, rownames(g)), f)) i j k

Re: [R] How to implement an iterative unit root test

2006-04-08 Thread Gabor Grothendieck
Try this: library(fMultivar) set.seed(1) x - rnorm(25) rollFun(x, 15, FUN = function(x) adf.test(x)$p.value) [1] 0.1207730 0.3995849 0.3261577 0.4733004 0.5776586 0.6400228 0.6758550 [8] 0.6897812 0.3792858 0.6587171 0.5675147 rollFun(x, 15, FUN = function(x) adf.test(x)$statistic) [1]

Re: [R] The mysterious e1071

2006-04-08 Thread Gabor Grothendieck
Did you try installing it first? From R, install.packages(e1071, dep = TRUE) On 4/8/06, Chelsea Ellis [EMAIL PROTECTED] wrote: Hi, I'm trying to use the svm function in R, but I can't find the e1071 package. When I type library(e1071), I get the error message that the package doesn't

Re: [R] How to implement an iterative unit root test

2006-04-08 Thread Gabor Grothendieck
P VALUE: 0.5612 Description: Sat Apr 08 19:11:40 2006 I checked with the help pages of the adfTest and fMultivar, but can simply not figure out why I am receiving these error messages above. How could I fix this? Many thanks! Sincerely, Bernd Dittmann Gabor Grothendieck

Re: [R] finding common elements in a list

2006-04-08 Thread Gabor Grothendieck
I guess I am coming a bit late to this but here is a one-line zoo solution. The lapply creates a zoo object from each foo component with the constant value 1 and the contents as the times of that object.Merging the objects together using cbind gives columns of 1s and NAs and removing the NAs

Re: [R] dot diagram

2006-04-09 Thread Gabor Grothendieck
Don't know about a function but it can be done in one plot statement like this: plot(seq(x) - match(x, x) ~ x, list(x = sort(mydata)), xlim=c(25,45), ylab =, yaxt=n, pch=19, frame.plot=FALSE) On 4/9/06, Jinsong Zhao [EMAIL PROTECTED] wrote: Hi, I am wondering whether there is a

Re: [R] adding a row to a matrix

2006-04-09 Thread Gabor Grothendieck
Try this: t(t(a)+b) On 4/9/06, Tim Smith [EMAIL PROTECTED] wrote: Hi All, This is probably a very simple question. I was trying to add a row to the rows in a matrix. For example: a - matrix(1:6,2,3) b - a[1,] print(a) [,1] [,2] [,3] [1,]135 [2,]246

Re: [R] help on using 'sum' in writng a function

2006-04-09 Thread Gabor Grothendieck
If c is c(c1, c2, c3) and x is c(x1, x2, x3) then c+x is (c1+x1, c2+x2, c3+x3) so sum(c+x) is c1+x1+c2+x2+c3+x3 = sum(c) + sum(x) What you were expecting is given by: rowSums(outer(1:4, c(-1,0,1), +)) # gives c(3, 6, 9, 12) Review the Introduction to R manual and also look at ?outer and

Re: [R] help on using 'sum' in writng a function

2006-04-09 Thread Gabor Grothendieck
Or, of course, if you are willing to reduce it then its just sum(c) + length(c) * x On 4/9/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: If c is c(c1, c2, c3) and x is c(x1, x2, x3) then c+x is (c1+x1, c2+x2, c3+x3) so sum(c+x) is c1+x1+c2+x2+c3+x3 = sum(c) + sum(x) What you were

Re: [R] [Help] a Correlation Problem

2006-04-09 Thread Gabor Grothendieck
Try this where g is f summed over j and k for given scalars theta and rho and gv is g vectorized over theta. I have not checked this carefully so be sure you do: f - function(theta = 0, rho = 0, j = 0, k = 0) dnorm(theta+2*pi*j,0,1)*pnorm(2*pi*(k+1)-rho*(theta+2*pi*j)) g - function(theta

Re: [R] help on using sum in writng a function again

2006-04-09 Thread Gabor Grothendieck
Sorry, I replied to the wrong email. Here it is again: Try this where g is f summed over j and k for given scalars theta and rho and gv is g vectorized over theta. I have not checked this carefully so be sure you do: f - function(theta = 0, rho = 0, j = 0, k = 0)

Re: [R] how to figure out skewness

2006-04-10 Thread Gabor Grothendieck
RSiteSearch(skewness) On 4/10/06, Jian Zhang [EMAIL PROTECTED] wrote: I think it is simply, but I cannot find the method to figure out skewness. Thanks! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list

Re: [R] Upadating windows shortcuts after upgrade

2006-04-10 Thread Gabor Grothendieck
If you are using XP then create a shortcut to Rgui.bat, which can be found in: http://cran.r-project.org/contrib/extra/batchfiles/ 0.2-7 is the most recent. When you install R it saves in the registry the R version and Rgui.bat looks that up and runs that version thereby giving you the last

Re: [R] seq

2006-04-10 Thread Gabor Grothendieck
Its undoubtedly a timezone or daylight savings time issue. Use this instead: seq(from=as.Date('2005-12-4'), to=as.Date('2006-4-9'), by='weeks') [1] 2005-12-04 2005-12-11 2005-12-18 2005-12-25 2006-01-01 [6] 2006-01-08 2006-01-15 2006-01-22 2006-01-29 2006-02-05 [11] 2006-02-12 2006-02-19

Re: [R] timeAlign

2006-04-10 Thread Gabor Grothendieck
Try this. dd - Sys.time() # test data lt - as.POSIXlt(dd) ISOdate(1900+lt$year, 1, 1, 0, tz = ) ISOdate(1901+lt$year, 1, 1, 0, tz = ) seq(now, length = 2, by = paste(-, lt$wday, day, sep =))[2] seq(now, length = 2, by = paste(7-lt$wday, day))[2] with(lt, ISOdate(1901+year, mon, mday, 0, tz

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

2006-04-10 Thread Gabor Grothendieck
On 4/10/06, Farrel Buchinsky [EMAIL PROTECTED] wrote: 1) I know how to post to the list. You simply send an e-mail to [EMAIL PROTECTED] But how do you read the items and respond to them? I usually read the items at http://tolstoy.newcastle.edu.au/R/help/06/04/index.html#end and then have to

Re: [R] timeAlign

2006-04-10 Thread Gabor Grothendieck
On 4/10/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try this. dd - Sys.time() # test data lt - as.POSIXlt(dd) ISOdate(1900+lt$year, 1, 1, 0, tz = ) ISOdate(1901+lt$year, 1, 1, 0, tz = ) seq(now, length = 2, by = paste(-, lt$wday, day, sep =))[2] seq(now, length = 2, by = paste(7

Re: [R] problems with rounding in output

2006-04-10 Thread Gabor Grothendieck
Try: sprintf((%.2f), pi) [1] (3.14) On 4/11/06, Brian Quinif [EMAIL PROTECTED] wrote: Perhaps someone will have a solution to my more general problem, but here is the specific one: I used the round() function to round some estimates to 3 decimal places. I then sent put the rounded

Re: [R] error in which(): recursive default argument reference

2006-04-11 Thread Gabor Grothendieck
Or use letters. = letters and similarly for the other arguments of the form x = x. On 4/11/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: 'letters' is an argument to your function, with default 'letters', that it itself. (Default arguments are evaluated in the evaluation frame of the

Re: [R] variable-substitution / command-substitution

2006-04-11 Thread Gabor Grothendieck
Here are some different approaches: x - 1 y - 2 paste(p, x, y, .dat, sep = ) # p12.dat sprintf(p%s%s.dat, x, y) file.path(a, b.dat) # a/b.dat library(gsubfn) gsubfn(,,p$x$y.dat) # p12.dat On 4/11/06, Damaris Zurell [EMAIL PROTECTED] wrote: Hello, I have about 2000 data files which I

Re: [R] Text Problem

2006-04-11 Thread Gabor Grothendieck
Try: junk - capture.output(print(abc)) On 4/11/06, Sumanta Basak [EMAIL PROTECTED] wrote: Hi All, I'm running garch models for different combinations, like (1,1),(1,2) etc. in a for loop. But, when i'm running it, R is showing a text * ESTIMATION WITH ANALYTICAL GRADIENT * . How can

Re: [R] About list to list

2006-04-11 Thread Gabor Grothendieck
Are you trying to turn each of the components of foo into a matrix? If that's it then: lapply(foo, function(x) matrix(unlist(x), nrow = length(x))) On 4/11/06, Muhammad Subianto [EMAIL PROTECTED] wrote: Dear all, I have a result my experiment like this below (here my toy example): foo1 -

Re: [R] About list to list

2006-04-11 Thread Gabor Grothendieck
I forgot the byrow = TRUE. Try this instead: lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE)) On 4/11/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Are you trying to turn each of the components of foo into a matrix? If that's it then: lapply(foo, function(x

Re: [R] About list to list - thanks

2006-04-11 Thread Gabor Grothendieck
One other thought. If they are all of the same dimension you could alternately consider putting them into a 3d array: library(abind) abind(lapply(foo, function(x) do.call(rbind, x)), along = 3) which may or may not have some advantage to you. On 4/11/06, Muhammad Subianto [EMAIL PROTECTED]

Re: [R] Variable Scope

2006-04-12 Thread Gabor Grothendieck
Use local or codetools package as in: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69694.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69695.html On 4/12/06, James Kirkby [EMAIL PROTECTED] wrote: Hi, I was wondering if there is a way to stop R looking outside the scope of a

Re: [R] Time Series information in formulae

2006-04-12 Thread Gabor Grothendieck
You might want to look at the dyn package. It allows time series in model formulae, e.g. this aligns UKgas and diff(UKgas) properly: dyn$lm(UKgas ~ diff(UKgas)) dyn$ transforms the above to dyn(lm(dyn(UKgas ~ diff(UKgas and the inner dyn adds class dyn to the formula's class vector

Re: [R] S4 method dispatch matrixOrArray

2006-04-12 Thread Gabor Grothendieck
I think its good enough to just define an array method, i.e. you don't need the matrix method or the matrixOrArray class, and the vector method can call foo(matrix(A,1), ...) so: setGeneric(foo, function(A, ...) { cat(generic, match.call()[[1]], \n)

Re: [R] Pipe delimiter ( | ) in read.delim

2006-04-12 Thread Gabor Grothendieck
For the lines you posted this read them in successfully: read.table(clipboard, sep = |) To extract the RD lines you will need two passes: L - readLines(clipboard) L - grep(^RD, L, value = TRUE) read.table(textConnection(L), sep = |) or you can use read.table(pipe(...), sep = |) where ... is a

Re: [R] S4 method dispatch matrixOrArray

2006-04-12 Thread Gabor Grothendieck
This is surprising. I would have thought that the parent/child relationships determine the order that dispatched methods are invoked, not the order that the setMethod commands are issued in. On 4/12/06, Paul Roebuck [EMAIL PROTECTED] wrote: On Wed, 12 Apr 2006, Gabor Grothendieck wrote: On 4

Re: [R] question about source package

2006-04-12 Thread Gabor Grothendieck
The minimum you need is to have a single file, DESCRIPTION, plus R and man directories/folders which contain your .R and .Rd files respectively. A package need not use C and I suspect most don't. On 4/12/06, James Anderson [EMAIL PROTECTED] wrote: Hi, Just a silly question about R source

Re: [R] S4 method dispatch matrixOrArray

2006-04-13 Thread Gabor Grothendieck
Maechler [EMAIL PROTECTED] wrote: Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Wed, 12 Apr 2006 18:24:46 -0400 writes: Gabor This is surprising. I would have thought that the Gabor parent/child relationships determine the order that Gabor dispatched methods are invoked

Re: [R] What does rbind(iris[,,1], iris[,,2], iris[,,3]) do?

2006-04-13 Thread Gabor Grothendieck
What you are referring to iris is called iris3 in R so just replace iris with iris3. iris3 is a 3d array in R whereas iris is a data frame. On 4/13/06, Sasha Pustota [EMAIL PROTECTED] wrote: It's in the Venables Ripley MASS (ed 3) book in the section on principal components. The context is

Re: [R] Creating an environment for a function.

2006-04-13 Thread Gabor Grothendieck
If you think of n and the function as components of an object then you could use the proto package to define an object, p, that contains those two components. If we assume no children of p are required (from your description I assume that that is the case) then its just: library(proto) p -

Re: [R] Questions on formula in princomp

2006-04-13 Thread Gabor Grothendieck
On 4/13/06, Sasha Pustota [EMAIL PROTECTED] wrote: I hope this time I'm using the iris dataset correctly: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) I'm trying to understand the meaning of expressions like ~ a+b+c+d, used with princomp,

Re: [R] Subset rows over multiple columns

2006-04-13 Thread Gabor Grothendieck
Try this: tt2 - tt tt2[,1] - as.character(tt2[,1]) tt2[,2] - as.character(tt2[,2]) f - function(x) with(tt2, mean(righta_a[x == itd_1 | x == itd_45])) sapply(unique(unlist(tt2[,1:2])), f) On 4/13/06, Doran, Harold [EMAIL PROTECTED] wrote: I have a data frame where I need to subset certain

Re: [R] loop: results for all inputs

2006-04-13 Thread Gabor Grothendieck
See: https://www.stat.math.ethz.ch/pipermail/r-help/2006-March/089888.html and succeeding messages in thread. On 4/13/06, gynmeerut [EMAIL PROTECTED] wrote: Dear R users, I am using a loop that does matrix multiplication in a manner (A%*%B)%*%(A) Here A is a row of data frame D of

Re: [R] Finding the format of an object redux

2006-04-13 Thread Gabor Grothendieck
Look at: str(obj) class(obj) dput(obj) On 4/13/06, Thomas L Jones [EMAIL PROTECTED] wrote: Okay, I am dealing with an object. Without going into too much detail, a gam (Generalized Additive Model) is involved. Assume that the name of the object is obj without the quotes. I tell it: print

Re: [R] vector-factor operation

2006-04-14 Thread Gabor Grothendieck
Look at ?ave ave(vec, Fac) ave(vec, Fac, FUN = mean) # same ave(vec, Fac, FUN = sd) On 4/14/06, Murray Jorgensen [EMAIL PROTECTED] wrote: I found myself wanting to average a vector [vec] within each level of a factor [Fac], returning a vector of the same length as vec. After a while I

Re: [R] The object argument of NextMethod.

2006-04-14 Thread Gabor Grothendieck
In section 5.5 of the language manual it says: It is important to realize that the choice of the next method depends on the current values of .Generic and .Class and not on the object. So changing the object in a call to NextMethod affects the arguments received by the next method but does not

Re: [R] The object argument of NextMethod.

2006-04-14 Thread Gabor Grothendieck
On 4/14/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Fri, 14 Apr 2006, ronggui wrote: My question is when the object argument of NexthMethod be used? Looking at the C code, I don't think it is. But look at do_nextmethod in src/main/objects.c yourself. Note that in your examples it

Re: [R] Questions on formula in princomp

2006-04-14 Thread Gabor Grothendieck
2 1.589235 1.098612 0.3364722 -1.6094379 3 1.547563 1.163151 0.2623643 -1.6094379 4 1.526056 1.131402 0.4054651 -1.6094379 5 1.609438 1.280934 0.3364722 -1.6094379 6 1.686399 1.360977 0.5306283 -0.9162907 On 4/14/06, Sasha Pustota [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED

Re: [R] matching identical row names

2006-04-15 Thread Gabor Grothendieck
aggregate(DF[,-1], DF[, 1, drop = FALSE], mean) On 4/15/06, Srinivas Iyyer [EMAIL PROTECTED] wrote: dear group, i have a sample matrix name v1 v2 v3 v4 cat 1011 12 15 dog 3 12 10 14 cat 9 12 12 15 cat 5 12 10 11 dog 12113 123 31

Re: [R] as.Date / size of par

2006-04-17 Thread Gabor Grothendieck
Try this: # test data y - 0:1000 # values dd - Sys.Date() + y # Dates # create zoo object, aggregate it by year using last value and plot it z - zoo(y, dd) yr - function(x) as.POSIXlt(x)$year + 1900 # or, yr - function(x) as.numeric(format(x, %Y)) z.yr - aggregate(z, yr, tail, 1) plot(z.yr,

Re: [R] Problem using plot and converted dates

2006-04-17 Thread Gabor Grothendieck
Try: y - 1:length(sam4) # test data dd - as.Date(sam4, %m/%d/%y) plot(dd, y) # also try this library(zoo) z - zoo(y, dd) plot(z) Also read, from earlier today: https://www.stat.math.ethz.ch/pipermail/r-help/2006-April/092471.html On 4/17/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear

Re: [R] Problem using plot and converted dates

2006-04-17 Thread Gabor Grothendieck
Try: axis.Date(1, sam5, sam5, format = %b-%y) On 4/17/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R-help, My apologies, my previous script ran successfully before I posted as I had already created mkf as an object in my active workspace. I have had some success, however I am unable

Re: [R] Tick mark alignment for POSIXct data

2006-04-17 Thread Gabor Grothendieck
Read the R News 4/1 help desk article which specifically discusses this. On 4/17/06, jim holtman [EMAIL PROTECTED] wrote: I am using POSIXct objects to store my date/time information. If I am plotting less that 2 days worth of data, I get the correct tick marks on the x-axis which is showing

Re: [R] R and ViM

2006-04-18 Thread Gabor Grothendieck
This was just posted this week: https://www.stat.math.ethz.ch/pipermail/r-help/2006-April/092457.html and I think there are some relevant macros on the vim web page I use vim but do not use anything special with it. It gives syntax highlighting out of the box. On 4/18/06, Michael Graber [EMAIL

Re: [R] about intersection set and union set

2006-04-18 Thread Gabor Grothendieck
This was just discussed recently. See the following thread: http://tolstoy.newcastle.edu.au/R/help/06/04/24923.html On 4/18/06, XinMeng [EMAIL PROTECTED] wrote: Hello sir: group1:1,2,3,4 group2:1,3,4,5 group3:2,4,8,9 .. ... group1000:9,3,8,2 I wanna get the intersection set and union

Re: [R] creating empty cells with table()

2006-04-19 Thread Gabor Grothendieck
One can use the fact that converting a zoo object to a ts object fills in the holes with NAs. First create some test data, x, and create the table, tab. Then create a zoo object and convert that to a ts object. Now barplot the ts values using the times as names. set.seed(1) x - rpois(20, 4) #

Re: [R] Breakdown a number

2006-04-19 Thread Gabor Grothendieck
Maybe you could discuss in words what you want but perhaps you are looking for diff: bp - c(0, 250, 800, 1200) diff(bp) [1] 250 550 400 On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote: Isn't there a builtin method for doing this and, if so, what is it called? breakdown -

Re: [R] 3D pie

2006-04-19 Thread Gabor Grothendieck
Since everyone else wimped out with a tedious you-do-not-want-to-do-that, here is a solution that uses R to control Excel and create a 3d chart. You will need the RDCOMclient package that you can find via google. library(RDCOMClient) xl - COMCreate(Excel.Application) # starts up Excel

Re: [R] 3D pie

2006-04-19 Thread Gabor Grothendieck
On 4/19/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote: Rolf Turner wrote: Gabor Grothendieck wrote: Since everyone else wimped out with a tedious you-do-not-want-to-do-that, here is a solution that uses R to control Excel and create a 3d chart. . . . People really

Re: [R] there is no xls reader in R?

2006-04-19 Thread Gabor Grothendieck
See: http://finzi.psych.upenn.edu/R/doc/manual/R-data.html#Reading-Excel-spreadsheets Also the RDCOMClient package (find it via google) and rcom (on CRAN) can control Excel from R and can be used. On 4/19/06, Michael [EMAIL PROTECTED] wrote: Currently I have to convert all my xls into csv

Re: [R] read dataset with blank space as missing value

2006-04-19 Thread Gabor Grothendieck
There are a number of approaches: 1. This will identify the line numbers of the short lines and then you can fix them up by hand. k - count.fields(myfile) which(k max(k)) 2. If you can assume that 4 spaces, say, represents a missing value then: L - readLines(myfile) L - gsub(, . , L)

Re: [R] Breakdown a number

2006-04-19 Thread Gabor Grothendieck
On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote: On Wed, 19 Apr 2006, Gabor Grothendieck wrote: On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote: Isn't there a builtin method for doing this and, if so, what is it called? breakdown - function(whole) { breaks

Re: [R] Randomly selecting one row for each factor level

2006-04-19 Thread Gabor Grothendieck
Try this: set.seed(1) f - function(x) { dd - dfr[dfr$x == x,]; dd[sample(nrow(dd),1),] } do.call(rbind, lapply(levels(dfr$x), f )) On 4/20/06, Kelly Hildner [EMAIL PROTECTED] wrote: I don't use R much, and I have been unable to figure out how to get the subset of my data frame that I would

Re: [R] Breakdown a number

2006-04-20 Thread Gabor Grothendieck
Try using breaks[breaks = x] in place of breaks. Your solution always returns three components if breaks has two whereas this one does not but you could extend the output it if that is an essential part. On 4/20/06, Paul Roebuck [EMAIL PROTECTED] wrote: On Thu, 20 Apr 2006, Gabor Grothendieck

Re: [R] R-Help

2006-04-20 Thread Gabor Grothendieck
Read them in as zoo objects (you can replace textConnection(Lines1) with the filename) and then merge them using all = FALSE to retain only common time points. Note that in my English locale I had to modify your Apl to Apr. Lines1 - Date x y Jan-1,2005120 230

Re: [R] (sem assunto)

2006-04-20 Thread Gabor Grothendieck
Try paste: paste(Axis, f) On 4/20/06, Eric Ferreira [EMAIL PROTECTED] wrote: Dear R-colleagues, Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot? For instance: f-2 plot(..., ylab='Axis f', ...) where f means the VALUE of f. Thany you in advance, Eric.

Re: [R] S4 objects with list of objects as slots: how to subset?

2006-04-20 Thread Gabor Grothendieck
Try: c(sapply(1:2, function(i) [EMAIL PROTECTED]@my.slot)) On 4/20/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I don't manage to see if you have already focussed on this point in some previous messages so I post my question: I have a little problem with the S4 style of

Re: [R] there is no xls reader in R?

2006-04-20 Thread Gabor Grothendieck
a single file and in the situation that there is junk on the first few lines of the spreadsheet you could use the skip= argument to read.csv to skip over that. I don't think the RODBC approach can handle that. On 4/20/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: See: http://finzi.psych.upenn.edu

Re: [R] Conditional Row Sum

2006-04-20 Thread Gabor Grothendieck
Using the built in data.frame iris sum each of the first 4 columns for each value of the 5th column. rowsum(iris[,-5], iris[,5]) On 4/20/06, Sachin J [EMAIL PROTECTED] wrote: Hi, How can I accomplish this in R. Example: R1 R2 3 101 4 102 3 102 18102 11101

Re: [R] How to know the row number of raw matrix after resampling?

2004-05-12 Thread Gabor Grothendieck
For your first question the simplest way to handle it is to sample the indices rather than the data. For example, x - seq(10,200,10) # data ix - sample(length(x),10,rep=T) # 10 samples from 1:length(x) s - x[ix] # samples Now ix has the indices of s. Taemyong Choi tmchoi at

Re: [R] Design matrix not identity

2004-05-12 Thread Gabor Grothendieck
f-as.factor(c(1,1,2,2,3,3,3)) model.matrix(~f-1) Patrik Waldmann Patrik.Waldmann at genfys.slu.se writes: : : Hello again, : : I was too quick before. What I was looking for was a function that : constructs the design (or incidence) matrix (X in a linear model) from a : factor. Uwe Ligges

Re: [R] summary table newbie question

2004-05-12 Thread Gabor Grothendieck
Check out aggregate.table in package gregmisc . Jeff D. Hamann jeff.hamann at forestinformatics.com writes: : : I've got a newbie question and I got a little lost in the table helps. : I've got a data.frame I would like to summarize as a (and pardon for the : lack of correct vernacular) data

Re: [R] lm without a formula?

2004-05-12 Thread Gabor Grothendieck
lm(y~.,data=x) ivo welch iaw4 at welch.som.yale.edu writes: : : hi: I have a y vector and an x data frame. is it possible to use the : standard linear regression (lm, summary.lm) without having to construct : a formula, i.e., all x variables should be used. : : x - data.frame(

Re: [R] help with generalized list function in R

2004-05-12 Thread Gabor Grothendieck
You can do that with ls and the pattern= argument. For example, ls(pattern = my) finds all objects with my anywhere in the name. See ?ls Andrew White andrew_white at hmsa.com writes: : : In S-plus I have depended upon a simple extended ls() function developed by John wallace called lsx()

Re: [R] Fitting data from a spectrophotometer.

2004-05-12 Thread Gabor Grothendieck
Perhaps you really prefer something with a continuous first derivative? In that case, all the continuous cumulative distribution functions have a sigmoidal shape and might be suitable. You could fit pnorm, plogis or tanh with suitable scaling and location parameters using nls. An example of

Re: [R] xtable without rownames

2004-05-12 Thread Gabor Grothendieck
Don't know about xtable but here is an alternative: require(Hmisc) data(iris) iris4 - iris[1:4,] # first 4 rows of iris as test latex(iris4,file=) # with row names attr(iris4,row.names) - NULL latex(iris4,file=) # without row names Jeff D. Hamann jeff.hamann at forestinformatics.com writes: :

Re: [R] xtable with a table ?

2004-05-11 Thread Gabor Grothendieck
t. - table(a,b) xtable(format(t.)) From: Ian Wilson [EMAIL PROTECTED] : : Any more elegant solutions to this? : : a - sample(c(a,d,c),100,replace=T) : b - sample(c(d,e,f,100,replace=T) : t - table(a,b) : xtable(t) : Error in xtable(t) : no applicable method for xtable : : The problem

Re: [R] Lists and outer() like functionality?

2004-05-10 Thread Gabor Grothendieck
David Orme d.orme at imperial.ac.uk writes: : : : outer() generally works by expanding out the lists like : : Y - rep(y,length(x)) : X - rep(x,each=length(y)) # or maybe it's vice versa, never mind... : FUN(X,Y,extras) : : and then adds dims and dimnames. If FUN vectorizes, this is the :

Re: [R] #!/usr/bin/R

2004-05-10 Thread Gabor Grothendieck
Webb Sprague wwsprague at ucdavis.edu writes: : Is there any documentation on running R like one would run a shell or : Perl script, with out/input directed appropriately, environment variable : access, and command switch processing? : : I looked some, and even remembered to check the FAQ, but

Re: [R] tapply hist

2004-05-13 Thread Gabor Grothendieck
As another respondent already mentioned, Lattice is probably the way to go on this one but if you do want to use tapply try this: names(Pot) - SGruppo dummy - tapply(Pot,SGruppo,function(x)hist(x,main=names(x)[1],xlab=NULL)) Vittorio v.demartino2 at virgilio.it writes: : : I'm learning how

[R] Creating and editing networks

2004-05-09 Thread Gabor Grothendieck
I want to draw and edit networks. Currently I will do something like this -- my actual networks are larger and more complex: 1. Plot network # use polygon with nodes as example network N - 20 t. - 2*pi*seq(N+1)/N plot(cos(t.), sin(t.), type=b, pch=19, cex=5, col=blue, axes=F, ann=F) 2. copy

Re: [R] Using known errors and error bars

2004-05-09 Thread Gabor Grothendieck
See plotCI in package gregmisc. Sebastian Schubert Sebastian-Schubert at gmx.de writes: : : Hi, : : I'm now to R and hope (actually, I'm quite sure) you can help me. I made : an experiment and measured two values. As I know the errors of these : values I want to use them with the linear

Re: [R] strange behavior of names-

2004-05-09 Thread Gabor Grothendieck
Execute these two commands: ans - fun(x,f) attributes(ans) and you get this: $dim [1] 20 $dimnames $dimnames[[1]] [1] a a b c a d a b d d a b d c c c b c b [20] d so ans does not have names, it has dimnames. If you try dimnames(ans) - NULL then its dimnames do get nulled

Re: [R] R-help

2004-05-14 Thread Gabor Grothendieck
If you want pairwise correlations for the cols of matrix x and N is some parameter to your routine that does not vary throughout the calculation then: apply(x,2,function(a)apply(x,2,function(b)Transmer.cor(a,b,N))) Replace both occurrences of 2 with 1 if you want rows. Ruedi Epple ruedi.epple

Re: [R] type checking --- just a thought

2004-05-14 Thread Gabor Grothendieck
If its just arg 1 then you can use S3 generics for this. Here it is but we have extended it to data frames too which isn't so easy if you can only specify one type: sum.across - function(x) UseMethod(sum.across) sum.across.matrix - function(x) { stopifnot(is.numeric(x)); c(rowMeans(x)) }

Re: [R] Tagging identical rows of a matrix

2004-05-14 Thread Gabor Grothendieck
The shortest expression I can think of is: as.numeric(interaction(mat[,1],mat[,2],drop=T)) Completing the thought of those who suggested dist or unique: N - nrow(mat) dd - as.matrix(dist(rbind(mat,unique(mat[-seq(N),seq(N)] apply(dd,2,function(x)match(0,x)) Scott Waichler scott.waichler

Re: [R] Surprise when indexing with a factor.

2004-05-08 Thread Gabor Grothendieck
Note that if f is a factor with Date labels, e.g. f - factor(c(2000-02-02,2000-02-03)) then as.Date has a factor method whose effect is such that (as of R 1.9.1): as.Date(f) *is* the same as as.Date(as.character(f)) . (Presumably this makes it easier to use as.Date with read.table.)

Re: [R] metafile copy and R 1.9.0

2004-05-08 Thread Gabor Grothendieck
I don't know if this workaround suffers the same problem or not since I have not tried it but you could try using the xfig device for your graphics and then using xfig2dev to convert that file to .cgm format (which is also vector based) and then in Word use: Insert | Picture or if a

Re: [R] Getting the groupmean for each person

2004-05-08 Thread Gabor Grothendieck
predict(lm(AV~as.factor(GROUP))) Felix Eschenburg Atropin75 at t-online.de writes: : : Hello list ! : : I have a huge data.frame with several variables observed on about 3000 : persons. For every person (row) there is variable called GROUP which indices : the group the person belongs to.

Re: [R] Indexing column of a matrix with infix $

2004-05-08 Thread Gabor Grothendieck
as.data.frame(matrixname)$validname chris1 chris1 at psyctc.org writes: : : I'm using 1.9.0 on Windoze 2k and I created a numeric matrix and used : colnames() to give it some column names, but if I try to select a : column using matrixname$validname I get a null return but if I use :

Re: [R] Tagging identical rows of a matrix

2004-05-14 Thread Gabor Grothendieck
Waichler, Scott R Scott.Waichler at pnl.gov writes: Thanks to all of you who responded to my help request. Here is the very efficient upshot of your advice: mat2 - apply(mat, 1, paste, collapse=:) vec - match(mat2, unique(mat2)) vec [1] 1 2 1 1 2 3 P.S. I found that Andy Liaw's

Re: [R] dataset.date, date of an object

2004-05-05 Thread Gabor Grothendieck
Jason Watts jcwatts999 at yahoo.com writes: I'm looking for a function that returns the time at which a permanently stored version of a dataset (object) was last modified, just like dataset.date in S-Plus. Any suggestions? I think others have already answered this (i.e. R does not store

Re: [R] skip lines on a connection

2004-05-01 Thread Gabor Grothendieck
?seek Vadim Ogranovich vograno at evafunds.com writes: : : Hi, : : I am looking for an efficient way of skipping big chunks of lines on a : connection (not necessarily at the beginning of the file). One way is to : use read lines, e.g. readLines(1e6), but a) this incurs the overhead of :

Re: [R] xtable without rownames

2004-05-14 Thread Gabor Grothendieck
Data frames are supposed to have unique rownames but it seems xtable does not know that so just set them all to anyways on a copy of ata that you throw away later: ata2 - ata rownames(ata2) - rep(,nrow(ata2)) xtable(ata2) rm(ata2) Jeff D. Hamann jeff.hamann at forestinformatics.com writes: :

Re: [R] Tagging identical rows of a matrix

2004-05-14 Thread Gabor Grothendieck
(interaction(as.data.frame(mat), drop=T))] : : With 10 columns in the matrix, f0 and f1 ran fine in under 10 seconds, but : f2g started thrashing, and ran out of memory after a while. If you look at : how interaction() is written you'll quickly see why... : : Andy : : From: Gabor Grothendieck

Re: [R] How to restore and edit saved graphics?

2004-05-15 Thread Gabor Grothendieck
Saving of the low level graphics that R displays can be 1. turned on with dev.control(displaylist=enable) and 2. turned off with dev.control(displaylist=inhibit). recordPlot() can be used to save the display list in a variable. For example: # turn on display list, perform plot, turn off

Re: [R] Moving window regressions - how can I improve this code?

2004-05-16 Thread Gabor Grothendieck
Others have already addressed the bug. Your other question seems to be how to get some simplification. Note that Greg Warnes responded in: http://article.gmane.org/gmane.comp.lang.r.general/18033 regarding the use of running in gregmisc. Another thing you could do if you want to retain the

Re: [R] How to restore and edit saved graphics?

2004-05-16 Thread Gabor Grothendieck
. : : Daehyok Shin (Peter) : : -Original Message- : From: r-help-bounces at stat.math.ethz.ch : [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Gabor Grothendieck : Sent: Saturday, May 15, 2004 PM 11:59 : To: r-help at stat.math.ethz.ch : Subject: Re: [R] How to restore and edit

<    11   12   13   14   15   16   17   18   19   20   >