Re: [R] function for cumulative occurrence of elements

2005-06-28 Thread Tony Plate
red_maple 2 2 1 1 1 white_oak white_spruce 1 2 > table(doc) doc 1 2 3 9 5 3 > hope this helps, Tony Plate Steven K Friedman wrote: > Hello, > > I have a data set with 9700 recor

Re: [R] Generating correlated data from uniform distribution

2005-07-01 Thread Tony Plate
t2[2,]) > > quantile(dat2[1,]) 0% 25% 50% 75%100% 0.000655829 0.246216035 0.507075912 0.745158441 0.16418 > quantile(dat2[2,]) 0% 25% 50% 75% 100% 0.0393046 0.4980066 0.7150426 0.9208855 1.3864704 > -- Tony Plate Ji

Re: [R] Seeking help with a loop

2005-08-03 Thread Tony Plate
1 3 NA 2 NA 6 > # if you really want to create new variables rather > # than have them in a data frame: > # (use paste() or sub() to modify the names if you > # want something like "newfielda") > for (i in names(y)) assign(i, y[[i]]) > a [1] 3 NA > b

Re: [R] Why only a "" string for heading for row.names with write.csv with a matrix?

2005-08-10 Thread Tony Plate
d lots of features. I think the situation is that the original author of any particular function gets to decide what features the function will have, and after that there is considerable reluctance (justifiably) to add new features, especially in cases where there desired functionality can b

Re: [R] queer data set

2005-08-15 Thread Tony Plate
X24" [8,] "A2" "B2" "C2" "X25" [9,] "A3" "B3" "C3" "NA" [10,] "A4" "B4" "C4" "X41" [11,] "A4" "B4" "C4" "X42" [12,] "A4" &

Re: [R] References verifying accuracy of R for basic statistical calculations and tests

2006-07-13 Thread Tony Plate
king relevant [leaving "the" and "of" in the query results in the search engine timing out - odd?] -- Tony Plate Corey Powell wrote: > Do you know of any references that verify the accuracy of R for basic > statistical calculations and tests. The results of these studie

Re: [R] transformation matrice of vector into array

2006-07-27 Thread Tony Plate
places -- it's not too difficult to make mistakes when pulling apart and reassembling arrays like this. (For simpler cases involving lists of vectors or matrices, the abind() function can help.) -- Tony Plate Jessica Gervais wrote: > Hi, > > I need some help > > I ha

Re: [R] Functions ,Optim, & Dataframe

2006-07-31 Thread Tony Plate
ple, if your function has an argument 'he=', you will not be able to pass it, because if you say optim(x0, fr, he=3), the 'he' will match the 'hessian=' argument of optim(), and it will not be interpreted as being a '...' argument. -- Tony Plate Michael Pape

Re: [R] Functions ,Optim, & Dataframe

2006-07-31 Thread Tony Plate
I added an example of passing additional arguments through optim() to the objective and gradient functions to the Discussion section of the Wiki-fied R documentation. See it at http://wiki.r-project.org/rwiki/doku.php?id=rdoc:stats:optim -- Tony Plate PS. I had to add "&purge=tru

Re: [R] deleting a directory

2006-08-01 Thread Tony Plate
?unlink says that unlink() can remove directories (and has a 'recursive' argument). 'unlink' is in the "SEE ALSO" section in ?file.remove. -- Tony Plate Sundar Dorai-Raj wrote: > Hi, all, > > I'm looking a utility for removing a directory from

Re: [R] meta characters in file path

2006-08-03 Thread Tony Plate
What is the problem you are having? Seems to work fine for me running under Windows2000: > write.table(data.frame(a=1:3,b=4:6), file="@# x.csv", sep=",") > read.csv(file="@# x.csv") a b 1 1 4 2 2 5 3 3 6 > sessionInfo() Version 2.3.1 (2006-06-01) i386-pc-mingw32 attached base packages: [1

Re: [R] regex scares me

2006-08-28 Thread Tony Plate
I think this does the trick. Note that it is case sensitive. > x <- c("lad.tab", "xxladyy.tab", "xxyy.tab", "lad.tabx", "LAD.tab", "lad.TAB") > grep("lad.*\\.tab$", x, value=T) [1] "lad.tab" "xxladyy.tab" > Jon Minton wrote: > Hi, apologies if this is too simple but I've been stuck on th

Re: [R] Cannot get simple data.frame binding.

2006-08-28 Thread Tony Plate
t; str(other) ? Maybe the labelled data frame is causing the problem? Did you try as.data.frame(md1[,1:11])? (I'm guessing that will strip off extra attributes). -- Tony Plate John Kane wrote: > I am stuck on a simple problem where an example works > fine but the real one does not. >

Re: [R] problem with putting objects in list

2006-09-06 Thread Tony Plate
I suspect you are not thinking about the list and the subsetting/extraction operators in the right way. A list contains a number of components. To get a subset of the list, use the '[' operator. The subset can contain zero or more components of the list, and it is a list itself. So, if x is a

Re: [R] rename cols

2006-09-11 Thread Tony Plate
5 3 3 6 > For a data frame, 'names(x) <- c("Apple", "Orange")' also works, because a dataframe is stored internally as a list of columns. -- Tony Plate Ethan Johnsons wrote: > A quick question please! > > How do you rename column names

Re: [R] Regular expressions & sub

2005-08-18 Thread Tony Plate
> x <- scan("clipboard", what="") Read 7 items > x [1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8" > gsub("[0-9]*\\.", "", x) [1] "11" "11" "11" "31" "2" "3" "8" > Bernd Weiss wrote: > Dear all, > > I am struggling with the use of regular expression. I got > > >>as.char

Re: [R] books about MCMC to use MCMC R packages?

2005-09-23 Thread Tony Plate
I've found "Bayesian Data Analysis" by Gelman, Carlin, Stern & Rubin (2nd ed) to be quite useful for understanding how MCMC can be used for Bayesian models. It has a little bit of R code in it too. -- Tony Plate Molins, Jordi wrote: > Dear list users, > > I need

Re: [R] Assign references

2005-10-07 Thread Tony Plate
t of thing in R is to modify a local copy of the dataframe and return that, or if you have to return several dataframes, then return a list of dataframes. -- Tony Plate [EMAIL PROTECTED] wrote: > Folks, > > I've run into trouble while writing functions that I hope will create > a

Re: [R] R on a supercomputer

2005-10-10 Thread Tony Plate
nt of the computation done in your R program involves basic linear algebra (matrix multiplication, etc.), then you might see a good speedup. -- Tony Plate Kimpel, Mark William wrote: > I am using R with Bioconductor to perform analyses on large datasets > using bootstrap methods. In an attem

Re: [R] outer-question

2005-10-27 Thread Tony Plate
+ return(a*b+(sum(d))) + } > additional <- runif(100) > outer(X=a, Y=b, FUN=f, d=additional) In f: 12 12 [,1] [,2] [,3] [,4] [1,] 53.61985 54.61985 55.61985 56.61985 [2,] 54.61985 56.61985 58.61985 60.61985 [3,] 55.61985 58.61985 61.61985 64.61985 > Note tha

[R] unvectorized option for outer()

2005-10-28 Thread Tony Plate
1:2, numeric(0), f, 2, VECTORIZED=F) [1,] [2,] > If a patch to add this feature would be considered, I'd be happy to submit one (including documentation). If so, and if there are any potential traps I should bear in mind, please let me know! -- Tony Plate Rau, Roland wrote: > Dear all,

Re: [R] unvectorized option for outer()

2005-10-28 Thread Tony Plate
Apologies for the cross post. I explicitly tried to avoid this but somehow r-help got tacked onto the end of the To: line without my realizing it. -- Tony Plate Tony Plate wrote: > [following on from a thread on R-help, but my post here seems more > appropriate to R

Re: [R] Still a bug with NA in sd() or var()?

2005-10-31 Thread Tony Plate
e warning message). Only the first element of that vector is used, so you are passing essentially a random value. By luck, in your example, the first element was T, which is why you got a value of 1.707825 as the result, and not NA. The rest might fall int

Re: [R] timeDate & business day

2007-03-13 Thread Tony Plate
nInfo() R version 2.4.1 (2006-12-18) 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] "stats" "graphics&quo

Re: [R] timeDate & business day

2007-03-13 Thread Tony Plate
tes, Time, and, Calendars, Diethelm W¨urtz http://www.itp.phys.ethz.ch/econophysics/R/docs/rCalendar.pdf S4 ’timeDate’ and ’timeSeries’ Classes for R, Diethelm W¨urtz http://www.itp.phys.ethz.ch/econophysics/R/pdf/calendar.pdf -- Tony Plate Michael Toews wrote: > Sadly, I don't know of any tu

Re: [R] data.frame handling

2007-03-19 Thread Tony Plate
(1,2,3,1,2,1,2,3)]) > table(x, y) y x a b c x 1 1 1 y 1 1 1 z 1 0 1 > If x and y are already columns in a data frame, then just do > table(X$factor1, X$factor2) hope this helps, Tony Plate Michela Cameletti wrote: > Dear R-users, > I have a little problem that

Re: [R] Prefered date and date/time classes

2007-03-27 Thread Tony Plate
;tips" section on the Wiki, please go ahead!) -- Tony Plate Petr Pikal wrote: > Hi > > On 27 Mar 2007 at 9:09, Charles Dupont wrote: > > Date sent:Tue, 27 Mar 2007 09:09:27 -0500 > From: Charles Dupont <[EMAIL PROTECTED]> > Organization:

Re: [R] Replacement in an expression - can't use parse()

2007-03-27 Thread Tony Plate
Peter Dalgaard wrote: > Daniel Berg wrote: >> Dear all, >> >> Suppose I have a very long expression e. Lets assume, for simplicity, that >> it is >> >> e = expression(u1+u2+u3) >> >> Now I wish to replace u2 with x and u3 with 1. I.e. the 'new' >> expression, after replacement, should be: >> >>

Re: [R] Fastest way to repeatedly subset a data frame?

2007-04-20 Thread Tony Plate
Here's some timings on seemingly minor variations of data structure showing timings ranging by a factor of 100 (factor of 3 if the worst is omitted). One of the keys is to avoid use of the partial string match that happens with ordinary data frame subscripting. -- Tony Plate > n

Re: [R] Fastest way to repeatedly subset a data frame?

2007-04-20 Thread Tony Plate
ed to know for myself what sort of speed differences there was now among the various approaches. -- Tony Plate Iestyn Lewis wrote: > This is fantastic. I just tested the first match() method and it is > acceptably fast. I'll look into some of the even better methods > later. Thank

Re: [R] Handling of arrays

2007-04-24 Thread Tony Plate
Try the following and look at what they return: str(ca) dimnames(ca) -- Tony Plate [EMAIL PROTECTED] wrote: > Dear R-Experts, > > I just imported a workspace from Matlab. I know that I can get the names of > the imported variables with names(). It works. The variable &quo

Re: [R] intersect more than two sets

2007-04-24 Thread Tony Plate
I don't think there's that sort of "apply-reduce" function in R, but for this problem, the last line below happens to be a "one-liner": > set.seed(1) > x <- lapply(1:10, function(i) sample(letters, 20)) > table(unlist(x)) a b c d e f g h i j k l m n o p q r s t u v w

Re: [R] regular expressions with grep() and negative indexing

2007-04-25 Thread Tony Plate
I use regexpr() instead of grep() in cases like this, e.g.: x2[regexpr("exclude",x2)==-1] (regexpr returns a vector of the same length as character vector given it, so there's no problem with it returning a zero length vector) -- Tony Plate Peter Dalgaard wrote: > St

Re: [R] applying rbind to list elements

2007-04-25 Thread Tony Plate
do.call("rbind", l) or, in the case of matrices, using the abind package: abind(l, along=1) > library(abind) > l <- list(matrix(1:6, ncol=2), matrix(11:14, ncol=2)) > abind(l, along=1) [,1] [,2] [1,]14 [2,]25 [3,]36 [4,] 11 13 [5,] 12 14 > Hendrik Fuß w

[R] [R-pkgs] new package: RSVGTipsDevice: create SVG plots with tooltips & hyperlinks

2007-05-03 Thread Tony Plate
the DESCRIPTION file: Package: RSVGTipsDevice Version: 0.7.0 Date:04/30/2007 Title: An R SVG graphics device with dynamic tips and hyperlinks Author: Tony Plate <[EMAIL PROTECTED]>, based on RSvgDevice by T Jake Luciani <[EMAIL PROTECTED]> Maintainer: Tony Plate <[

[R] getting informative error messages

2007-05-07 Thread Tony Plate
s there anything I can do to get a more informative error message in this type of situation? I couldn't find any help in the section "Debugging R Code" in "R-exts" (or anything at all relevant in "R-intro"). (Different values for options(error=...) and different

Re: [R] getting informative error messages

2007-05-11 Thread Tony Plate
ast and easy way of distinguishing those from the ones that do matter. I did look in R-exts, and on developer.r-project.org but was unable to find clear guidance there either. -- Tony Plate > > > On Mon, 7 May 2007, Tony Plate wrote: > >> Certain errors seem to generate mes

Re: [R] R2 always increases as variables are added?

2007-05-24 Thread Tony Plate
6503186 > y.hat <- fitted(lm3) > # no-intercept version of R^2 (2 ways to compute) > 1-sum((y.hat-data$y)^2)/sum((data$y)^2) [1] 0.6503186 > sum((y.hat)^2)/sum((data$y)^2) [1] 0.6503186 > # standard (assuming model has intercept) computations for R^2: > SSE <- sum((y.hat -

Re: [R] Interactive plots?

2007-05-25 Thread Tony Plate
The package RSVGTipsDevice allows you to do just it just -- you create a plot in an SVG file that can be viewed in a browser like FireFox, and the points (or shapes) in that plot can have pop-up tooltips. -- Tony Plate mister_bluesman wrote: > Hi there. > > I have a matrix that

Re: [R] Access Rows in a Data Frame by Row Name

2006-09-13 Thread Tony Plate
An Introduction to R" will probably be well worth it. The relevant sections are "5 Arrays and matrices", and "6.3 Data frames". -- Tony Plate Michael Gormley wrote: > I have created a data frame using the read.table command. I want to be able > to access the row

Re: [R] symbolic matrix elements...

2006-09-18 Thread Tony Plate
* x + 4) > Using list() with language objects is much safer if you just want to make lists of them. -- Tony Plate Evan Cooch wrote: > > Eik Vettorazzi wrote: > >>test=matrix(c( expression(x^3-5*x+4), expression(log(x^2-4*x >>works. > > Well, not really (or I&#

Re: [R] List-manipulation

2006-09-29 Thread Tony Plate
Does this do what you want? > x <- list(1,2,3:7,8,9:10) > sapply(x, function(xx) xx[1]) [1] 1 2 3 8 9 > -- Tony Plate Benjamin Otto wrote: > Hi, > > > > Sorry for the question, I know it should be basic knowledge but I'm > struggling for two hours no

Re: [R] how ot replace the diagonal of a matrix

2006-10-03 Thread Tony Plate
q(len=n)) (For very large matrices, the third will be more efficient, I believe.) -- Tony Plate roger bos wrote: > Dear useRs, > > Trying to replace the diagonal of a matrix is not working for me. I > want a matrix with .6 on the diag and .4 elsewhere. The following > code looks lik

Re: [R] shifting a huge matrix left or right efficiently ?

2006-10-09 Thread Tony Plate
06600 400980 5000 12 10 > I don't know if the conversion to and from a time-series class will impact the timing, but if this might serve your purposes, it's easy to do some experiments to find out. - Tony Plate Huang-Wen Chen wr

Re: [R] Fwd: rarefy a matrix of counts

2006-10-11 Thread Tony Plate
e(c(1,2,2,3,3,3), rep=F, size=4) -- Tony Plate From reading ?sample, I was a little unclear on whether sampling without replacement could work Petr Pikal wrote: > Hi > > a litle bit different story. But > > x1 <- sample(c(rep("red",400),rep("green", 100),

Re: [R] Fwd: rarefy a matrix of counts

2006-10-11 Thread Tony Plate
[sample(rep(1:3,c(400,100,300)), 5)] [1] "red" "blue" "red" "red" "red" > -- Tony Plate Brian Frappier wrote: > I tried all of the approaches below. > > the problem with: > > > x <- data.frame(matrix(NA,100,3)) &g

Re: [R] not understanding a do.call

2006-10-18 Thread Tony Plate
- 4:6 > c <- 7:9 > x1 <- list(a=a,b=b) > x2 <- list(a=a,b=b,c=c) > do.call("cbind", x1) a b [1,] 1 4 [2,] 2 5 [3,] 3 6 > do.call("cbind", x2) a b c [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > -- Tony Plate Leeds, Mark (IED) wrote: > I did

Re: [R] problem about using list element in for cycle

2006-10-23 Thread Tony Plate
Your problem is that you are using cat() on a factor. Use as.character() or format() to convert the factor to character data, which cat will then print in the way you want. > x <- data.frame(L=letters[1:3]) > x L 1 a 2 b 3 c > x$L [1] a b c Levels: a b c > cat(x$L, "\n") 1 2 3 > cat(as.

Re: [R] data storage/cubes and pointers in R

2006-11-09 Thread Tony Plate
will bind together vectors and arrays into higher dimensional arrays -- it might come in handy for you. -- Tony Plate Piet van Remortel wrote: > Hi all, > > I am faced with the situation where I want to store/analyze > relatively large, organized sets of numerical data, which dep

Re: [R] Nonlinear statistical modeling -- a comparison of R and AD Model Builder

2006-11-24 Thread Tony Plate
nd I believe it is very widely used. Did you try using that optimization routine with this problem? -- Tony Plate dave fournier wrote: > There has recently been some discussion on the list about > AD Model builder and the suitability of R for constructing the > types of models

Re: [R] R and databases - a comment

2005-12-09 Thread Tony Plate
This is very useful, thanks for posting! I created a page for this at the R Wiki: http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?DataBases If any one has any info to add, go at it! -- Tony Plate charles loboz wrote: > 1. That was a part of a private email exchange. It has > been suggeste

[R] update to posting guide: use 'sessionInfo()' instead of 'version'

2005-12-29 Thread Tony Plate
e that sessionInfo() currently does not report all the information that 'version' does (it omits at least "Status" and "svn rev"). R-core members are aware of this -- whether or not they change this is up to them.] -- Tony Plate __

Re: [R] Wikis etc.

2006-01-06 Thread Tony Plate
can gather momentum? -- Tony Plate Frank E Harrell Jr wrote: > I feel that as long as people continue to provide help on r-help wikis > will not be successful. I think we need to move to a central wiki or > discussion board and to move away from e-mail. People are extremely > helpf

Re: [R] Correct way to test for exact dimensions of matrix or array

2006-01-10 Thread Tony Plate
There's a gotcha in using identical() to compare dimensions -- it also compares names, e.g.: > x <- array(1:14, dim=c(rows=3,cols=5)) > dim(x) rows cols 35 > identical(dim(x)+0, c(3,5)) [1] FALSE > identical(as.numeric(dim(x)+0), c(3,5)) [1] TRUE > Gabor Grothendieck wrote: > If its

Re: [R] Convert matrix to data.frame

2006-01-12 Thread Tony Plate
complaint. Can you explain exactly how it didn't work for you? (e.g., show the exact error message). -- Tony Plate Chia, Yen Lin wrote: > Hi all, > > > > I wonder how could I convert a matrix A to a dataframe such that > whenever I'm running a linear model such lm

Re: [R] for loop should check the looping index !!

2006-01-13 Thread Tony Plate
sing something like seq(1,len=length(x)) (or simply seq(len=length(x)), or seq(2, len=length(x)-1) or seq(along=x)[-1]. -- Tony Plate johan Faux wrote: > Hello , > > a<-c(1) > for(i in 2:length(a)) > do.something with a[[i]] > > I get : > Error in

Re: [R] how to find how many modes in 2 dimensions case

2007-06-09 Thread Tony Plate
atches your definition of "neighbor" (the above formula does not include diagonal neighbors). And of course, ties make things more complicated (note that the above simple algorithm misses the local maximum consisting of two 8's in the last row.) -- Tony Plate Patrick Wang wrot

Re: [R] Problem with RSVGTipsDevice

2007-06-18 Thread Tony Plate
The new version of RSVGTipsDevice (0.7.1) that is now available on CRAN should fix this problem. Please let me know if it doesn't, or if there are other problems. -- Tony Plate mister_bluesman wrote: > Hi there. > > I am still trying to get the RSVGTipsDevice to work, yet I c

Re: [R] poor rbind performance

2007-07-18 Thread Tony Plate
t;rbind", list.of.dfs) > myData i c 1 3 c 2 4 d 3 5 e 4 6 f 5 7 g 6 8 h > (and of course, these last two expressions can be composed into a single expression if you want) -- Tony Plate Aydemir, Zava (FID) wrote: > Hi > > I rbind data frames in a loop in a

Re: [R] Subset dataframe based on condition

2006-04-17 Thread Tony Plate
actors, I would have expected a warning from the comparison operator). You might get more help by distilling your problem to a simple example that can be tried out by others. -- Tony Plate Sachin J wrote: > Hi, > > I am trying to extract subset of data from my original data frame

Re: [R] how to multiply a constant to a matrix?

2006-05-26 Thread Tony Plate
result of the quadratic expression must be treated as a scalar? -- Tony Plate Michael wrote: > imagine when you have complicated matrix algebra computation using R, > > you cannot prevent some middle-terms become quadratic and absorbs into one > scalar, right? > > if R cannot intel

Re: [R] max / pmax

2006-05-30 Thread Tony Plate
Here's an example of how I think you can do what you want. Play with the definition of the function highest.use() to get random selection of multiple maxima. > drug.names <- c("marijuana", "crack", "cocaine", "heroin") > drugs <- factor(drug.names, levels=drug.names) > drugs [1] marijuana cr

Re: [R] ifelse question

2006-12-12 Thread Tony Plate
1:3, 11:14) -- Tony Plate Jacques Ropers wrote: >>But you got only two (eventually one) distinct values, right? Look at >>the code for 'ifelse': yes and no are only called once each, then >>recycled to desired length. >> >>I guess you want something li

Re: [R] How to avoid test for NAs in foreign function call

2006-12-14 Thread Tony Plate
ode making unwanted interpretations of certain bit patterns. -- Tony Plate Knut M. Wittkowski wrote: > We have packed logical vectors into integers, 32 flags at a time and > then want to AND or OR these vectors of "integers" using other C functions. > > The problem: occasio

Re: [R] Simple Date problems with cbind

2007-01-30 Thread Tony Plate
;)) int date 1 1 2005-01-24 2 2 2006-01-23 3 3 2006-01-23 > (x <- data.frame(int=1:3, date=as.Date(c("2005/01/24" ,"2006/01/23" ,"2006/01/23"), "%Y/%m/%d"))) int date 1 1 2005-01-24 2 2 2006-01-23 3 3 2006-01-23 > class

Re: [R] Outlook does threading

2007-01-31 Thread Tony Plate
033.aspx, one can view threads in Outlook by selecting "View->Arrange By->Conversation". Hope this helps (in case the horse was not thoroughly dead already.) -- Tony Plate Kimpel, Mark William wrote: > See below for Bert Gunter's off list reply to me (which I do > apprec

Re: [R] indexing

2007-02-01 Thread Tony Plate
> a <- data.frame(value=c(6.5,7.5,8.5,12.0),class=c(1,3,5,2)) > x <- c(1,1,2,7,6,5,4,3,2,2,2) > match(x, a$class) [1] 1 1 4 NA NA 3 NA 2 4 4 4 > a[match(x, a$class), "value"] [1] 6.5 6.5 12.0 NA NA 8.5 NA 7.5 12.0 12.0 12.0 > -- Tony Pla

Re: [R] How to print a double quote

2007-02-22 Thread Tony Plate
> cat('Open fnd "test"\n') Open fnd "test" > cat("Open fnd \"test\"\n") Open fnd "test" > Bos, Roger wrote: > Can anyone tell me how to get R to include a double quote in the middle > of a character string? > > For example, the following code is close: > >> fnd<-"Open fnd 'test'" >>

Re: [R] optim(method="L-BFGS-B") abnormal termination

2007-02-23 Thread Tony Plate
te point for a reasonably well-behaved function. It may be possible to increase the number of steps, but I don't see how from the docs for ?optim. Of course, the source is available. hope this helps, Tony Plate Petr Klasterecky wrote: > Hi, > my call of optim() with the L-BFGS-B

Re: [R] "privileged slots",

2004-06-03 Thread Tony Plate
ool to deal with software updates is automated testing. I highly recommend it. R comes with a testing framework. -- Tony Plate cheers, jari oksanen -- Jari Oksanen <[EMAIL PROTECTED]> __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch

Re: [R] Importing binary data

2004-06-03 Thread Tony Plate
Probably the simplest way to improve the speed of your code would be to write the data so that all the data in a column is contiguous. Then you'll be able to read each column with a single call to readBin(). hope this helps, Tony Plate At Tuesday 04:02 AM 6/1/2004, Uli Tuerk wrot

Re: [R] How to Describe R to Finance People

2004-06-08 Thread Tony Plate
debugging is harder than it needs to be. Yup, that's why I proposed (and provided an implementation) of an alternative "$$" operator that did report an error when object$$name didn't have a "name" component (and also didn't allow abbreviation), but there was n

Re: [R] direct data frame entry

2004-06-09 Thread Tony Plate
easy to do it by column: > d <- data.frame(name=c("obs1name","obs2name","obs3name"),val1=c(0.2,0.4,0.6),val2=c(0.3,1.0,2.0),row.names=c("r1","r2","r3")) > d name val1 val2 r1 obs1name 0.2 0.3 r2 obs2name 0.4 1.0 r3 obs3name 0.6 2.0 > (when you do it by row, you get the numbers as fac

Re: [R] a scope problem

2004-06-10 Thread Tony Plate
This looks like it probably is a scope problem with non-standard evaluation rules for the argument subset= of nnet. Instead of subset=sub[-i], try data=dftc[-i,] (I've not tested this since I don't have the data objects you used.) hope this helps, Tony Plate At Thursday 04:38 PM

Re: [R] Elementary sapply question

2004-06-21 Thread Tony Plate
so the standard argument interpretation rules result in the arguments having the values y=3, x=1. hope this help, Tony Plate Thanks, -ans. -- Ajay Shah Consultant [EMAIL PROTECTED] Department of Economic Affairs http

Re: [R] Re: summaries (was: SUMMARY: "elementary sapply question")

2004-06-24 Thread Tony Plate
ago at: > > http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?RwikiHome > > yet no one really used it. Some critical mass of use is needed > to get such a project off the ground. Comments? -- Tony Plate __ [EMAIL PROTECTED] mailing list htt

Re: [R] naive question

2004-06-30 Thread Tony Plate
file, then, as others have suggested, writing a C program wouldn't be that hard, as long as you make the format inflexible. -- Tony Plate At Tuesday 06:19 PM 6/29/2004, Igor Rivin wrote: I was not particularly annoyed, just disappointed, since R seems like a much better thing than SAS i

Re: [R] naive question

2004-06-30 Thread Tony Plate
t R is an open source volunteer project suggests that the time is ripe for one of those disappointed people to fix the matter and contribute the function read.table.fast()! -- Tony Plate At Wednesday 10:08 AM 6/30/2004, Igor Rivin wrote: Thank you! It's interesting about S-Plus, since they appare

Re: [R] Can R read data from stdin?

2004-07-09 Thread Tony Plate
The easiest way would probably be to do the hack of creating a temporary file to hold stdin, then call R to process that file. That would be easy to do in a shell script. If this really won't suffice, this older message might lead to something useful: Rd] R scripting patches for R-1.8.0 Neil

Re: [R] Regular Expressions

2004-07-12 Thread Tony Plate
t;thomas"), function(re) grep(re, x)) $perl [1] 3 $program [1] 3 4 $thomas [1] 2 3 4 > unlist(sapply(c("perl","program","thomas"), function(re) grep(re, x)), use.names=F) [1] 3 3 4 2 3 4 > y <- table(unlist(sapply(c("perl","prog

Re: [R] Stumped with subsetting

2004-07-29 Thread Tony Plate
c("x","y") > data[mylist] x y 1 1 4 2 2 5 3 3 6 > data[,mylist] x y 1 1 4 2 2 5 3 3 6 > I'd generally use the second form of subsetting above (i.e., data[,mylist], because that will work with matrices as well). hope this helps, Tony Plate At Thursday 01:22

Re: [R] lapply drops colnames

2004-08-02 Thread Tony Plate
7 0.00 0.27 NA NA > all.equal(x1, x2) [1] TRUE > hope this helps, Tony Plate At Monday 04:35 PM 8/2/2004, Jack Tanner wrote: Wolski wrote: What you can do is to extend the column (list) by an addtional attribute attr(mydataframe[i],"info")<-names(mydataframe)[i] and store they

Re: [R] How to import specific column(s) using "read.table"?

2004-08-10 Thread Tony Plate
st containing NULL is quite a different object to NULL). E.g.: > rep(NULL, 20) NULL > c(rep(list(NULL), 3), rep(list(0), 2)) [[1]]: NULL [[2]]: NULL [[3]]: NULL [[4]]: [1] 0 [[5]]: [1] 0 > Tony Plate But anyway, it works and saves a lot of memory for me. Thank you again. Frank Quot

RE: [R] numerical accuracy, dumb question

2004-08-14 Thread Tony Plate
; So, for long vectors with relatively few different values, storage as factors is far more memory efficient (this is because the character data is stored only once per level, and each element is stored as a 4-byte integer). (The above was done on Windows 2000). -- Tony Plate If any mathematical

Re: [R] Suggestion for posting guide

2004-08-20 Thread Tony Plate
what gets put on the R-project site might be willing to put it up there, and a link to it from the posting guide would seem like a good idea. Tony Plate At Thursday 07:17 AM 8/19/2004, Gabor Grothendieck wrote: I have a suggestion for the posting guide. One problem with some posts is that th

Re: [R] Loss of rownames and colnames

2004-08-20 Thread Tony Plate
26 > xr <- sample(rownames(x), 1) > length(xr) [1] 1 > system.time(y <- x[xr, ]) [1] 2.22 0.00 2.30 NA NA > system.time(y <- x[match(xr, rownames(x)), ]) [1] 0.09 0.00 0.09 NA NA > HTH -- Tony Plate My bad workaround solution so far has been to generate obj

Re: [R] apply ( , , table)

2004-08-24 Thread Tony Plate
y (a, 1, function(x) table(factor(x, levels=0:9))) > b1 [,1] [,2] [,3] [,4] 00100 12112 21001 30100 40220 50011 6 1 001 71000 80010 90000

Re: [R] (no subject)

2004-08-24 Thread Tony Plate
(which.max(table(x))) [1] "2" > Note that this method returns the first max value in the case of ties. hope this helps, Tony Plate At Tuesday 11:01 AM 8/24/2004, Jonathan Baron wrote: On 08/24/04 13:50, Paolo Tommasini wrote: >Hi my name is Paolo Tommasini does anyone know how to compu

Re: [R] S <-> R

2004-08-25 Thread Tony Plate
ible to read data dumps from S-PLUS 5.x and 6.x written with >data.dump(oldStyle=T). -- Tony Plate At Wednesday 10:29 AM 8/25/2004, Zachary Skrivanek wrote: >Hello! I would like to be able to read in list data objects in R/S >created in R/S. (Ie R->S or S->R.) I have tried 'dpu

Re: [R] S <-> R

2004-08-25 Thread Tony Plate
oldStyle=T) R> dget("junk1.dat") Error in eval(expr, envir, enclos) : Object "g" not found R> # with package "foreign" loaded R> data.restore("junk2.dat") Error in ReadSdump(TRUE, " ") : S mode "junk" (near byte offset 45) not sup

Re: [R] enter browser on error

2004-08-31 Thread Tony Plate
use options(error=recover), e.g.: > remove("x") NULL Warning message: remove: variable "x" was not found > (function() {x})() Error in (function() { : Object "x" not found > options(error=recover) > (function(y=1) {x})(2) Error in (function(y = 1) { : Object "x" not found Enter a frame number, or 0

Re: [R] Signs of loadings from princomp on Windows

2004-09-14 Thread Tony Plate
em i386, mingw32 status Under development (unstable) major2 minor0.0 year 2004 month 09 day 13 language R > -- Tony Plate At Tuesday 10:25 AM 9/14/2004, Prof Brian Ripley wrote: On Tue, 14 Sep 2004, Francisco Chamu wrote: > I have run this on both Windows 2000 and XP. Al

Re: [R] efficient submatrix extraction

2004-09-15 Thread Tony Plate
42 50 58 [3,] 35 43 51 59 [4,] 36 44 52 60 [,1] [,2] [,3] [,4] [1,] 37 45 53 61 [2,] 38 46 54 62 [3,] 39 47 55 63 [4,] 40 48 56 64 > hope this helps, Tony Plate At Wednesday 03:10 PM 9/15/2004, Rajarshi Guha wrote: Hi, I have a matrix of

Re: [R] Signs of loadings from princomp on Windows

2004-09-15 Thread Tony Plate
they could reproduce the behavior that bothered you, but didn't bother dig deeper suggests it didn't bother them that much, which further suggests that you are the person most motivated by this and thus the best candidate for investigating it further...) -- Tony Plate At Wednesday 05

Re: [R] There were 50 or more warnings (use warnings() to see the first 50)

2004-09-16 Thread Tony Plate
Try putting options(warn=1) at the start of your R code. This should cause the warnings to be printed as they occur, instead of the default of being saved up until the top-level command terminates. See ?warning and ?option. -- Tony Plate At Thursday 08:52 AM 9/16/2004, Mag. Ferri Leberl wrote: I

Re: [R] read "4-jan-02" as date

2004-10-11 Thread Tony Plate
01" "11-Jan-01" "10-Jan-01" "9-Jan-01" "8-Jan-01" "5-Jan-01" > as.Date(d, format="%d-%b-%y") [1] "2001-01-12" "2001-01-11" "2001-01-10" "2001-01-09" "2001-01-08" [6] "2001-01-05&

Re: [R] How might one write this better?

2004-10-05 Thread Tony Plate
The trick to vectorizing > asset <- numeric(T+1) > for (t in 1:T) asset[t+1] <- cont[t] + ret[t]*asset[t] is to expand it algebraically into a sum of terms like: asset[4] = cont[3] + ret[3] * cont[2] + ret[3] * ret[2] * cont[1] (where the general case should be reasonably obvious, but is more work

Re: [R] Equivalents of Matlab's 'find' and 'end'

2004-10-07 Thread Tony Plate
At Thursday 08:10 AM 10/7/2004, Bryan L. Brown wrote: Sorry if these questions have been asked recently--I'm new to this list. I'm primarily a Matlab user who is attempting to learn R and I'm searching for possible equivalents of commands that I found very handy in Matlab. So that I don't seem u

Re: [R] R-(wiki)-pedia?

2004-10-07 Thread Tony Plate
as a framework to get things going? If the existing R-docs are "dumped" into a wiki, won't the copy in the Wiki quickly get out of date? How does one get around this problem? -- Tony Plate __ [EMAIL PROTECTED] mailing list https://stat.

Re: [R] indexing problem

2004-10-19 Thread Tony Plate
Maybe this does what you want: > dm <- cbind(1:2,11:12,101:102) > idx <- cbind(c(1,2),c(2,3)) > row(idx) [,1] [,2] [1,]11 [2,]22 > cbind(as.vector(row(idx)), as.vector(idx)) [,1] [,2] [1,]11 [2,]22 [3,]12 [4,]23 > dm[cbind(as.vector(row(idx)

  1   2   >