Re: [R] Array analogue of row and col

2013-04-06 Thread Tony Plate
slice.index() in base On 4/2/2013 9:53 AM, Enrico Bibbona wrote: Great! Thanks a lot, Enrico 2013/4/2 Duncan Murdoch On 02/04/2013 6:36 AM, Enrico Bibbona wrote: Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for

Re: [R] Array analogue of row and col

2013-04-06 Thread Tony Plate
slice.index() in base On 4/2/2013 6:36 AM, Enrico Bibbona wrote: Is there any function that extends to multidimentional arrays the functionalities of "row" and "col" which are just defined for matrices? Thanks, Enrico Bibbona [[alternative HTML version deleted]] ___

Re: [R] list of matrices --> array

2013-02-17 Thread Tony Plate
abind() (from package 'abind') can take a list of arrays as its first argument, so in general, no need for do.call() with abind(). As another poster pointed out, simplify2array() can also be used; while abind() gives more options regarding which dimension is created and how dimension names are

Re: [R] Problem in installing and starting Rattle

2011-03-19 Thread Tony Plate
x[file.exists(x)]) [1] "C:\\R\\GTK2-Runtime\\bin/zlib1.dll" > There are many ways to modify the PATH. To set PATH inside R: > Sys.setenv(PATH=paste(grep("UNWANTEDPATH", strsplit(Sys.getenv("PATH"), > ";")[[1]], value=T, invert=T), collapse=&q

Re: [R] mvbutils and trackObjs

2010-06-02 Thread Tony Plate
into mvbutils, but it would probably be a significant amount of work. -- Tony Plate On 05/31/2010 09:56 PM, Day, Roger S wrote: Hello Colleagues, I've recently become a fan of Mark Bravington's mvbutils package for organizing analysis projects in a tree. Using cd(), Save(), fix

Re: [R] Variable variables using R ... e.g., looping over data frames with a numeric separator

2010-05-18 Thread Tony Plate
bove, try something like this: for (i in 1:(L-1)) { dataName <- paste("fData.", i, sep="") df <- get(dataName) ... do something with data frame df ... } You can also give additional arguments to get() to tell it where to look (pos=,envir=), and wh

Re: [R] How to change the default Date format for write.csvfunction?

2009-12-28 Thread Tony Plate
ply(d, function(x) if (is(x, "Date")) format(x, "%m/%d/%Y") else x)) write.table(d1, quote=which(sapply(d, function(x) !is.numeric(x) & !is(x, "Date" "ticker" "date" "price" "1" "IBM" 12/03/2009 120 "2&qu

Re: [R] 2D array of strings

2009-12-28 Thread Tony Plate
matrix(str, ncol=1) Francesco Napolitano wrote: Sorry for the dumb question, but I couldn't figure this out myself. Consider the following: str <- c("abc","def") array(str, c(2,1)) [,1] [1,] "abc" [2,] "def" How can i obtain the outcome of the second instruction without specifying the

Re: [R] [Rd] Error in namespaceExport(ns, exports) :

2009-12-03 Thread Tony Plate
Try looking in the NAMESPACE file (in the same directory as the DESCRIPTION file). -- Tony Plate David Scherrer wrote: Dear all, I get the error "Error in namespaceExport(ns, exports) : undefined exports function1 , function2" when compiling or even when I roxygen my packag

Re: [R] Help with complicated regular expression

2009-11-13 Thread Tony Plate
;more words in front(2)") grep("[[:alpha:]]+[ \t]*\\([ \t]*[0-9]+[ \t]*\\)", x) [1] 1 2 3 4 6 grep("^[[:alpha:]]+[ \t]*\\([ \t]*[0-9]+[ \t]*\\)", x) [1] 1 2 3 4 -- Tony Plate Dennis Fisher wrote: Colleagues, I am using R (2.9.2, all platforms) to search for a

Re: [R] Loadings and scores from fastICA?

2009-11-12 Thread Tony Plate
Hyvärinen and Erkki Oja * (http://www.cis.hut.fi/aapo/papers/IJCNN99_tutorialweb/) -- it's an excellent introduction. -- Tony Plate Joel Fürstenberg-Hägg wrote: Ok, so then the S gives the individual components, good. Thanks Tony! But what about the principal components from the PCA

Re: [R] Loadings and scores from fastICA?

2009-11-11 Thread Tony Plate
uot;S" (the estimated source matrix) and "A" (the estimated mixing matrix). Are these what you want? -- Tony Plate Joel Fürstenberg-Hägg wrote: Hi all, Does anyone know how to get the independent components and loadings from an Independent Component Analysis (ICA), as well as

Re: [R] partial cumsum

2009-11-11 Thread Tony Plate
long computationally intensive job. And if that's the case, it would make sense to code it in C. -- Tony Plate Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com any ideas? thank you and best regards, stefan __ R-help@r-pro

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread Tony Plate
uot;, \"b\"" "\"b\"" row2 "\"c\"""\"d\"" # use R's parsing and evaluation to turn '"a", "b"' into c("a", "b"), and turn that # into a matrix containing characte

Re: [R] Comparison of vectors in a matrix

2009-11-10 Thread Tony Plate
;=apply(x, 1, function(ab) setdiff(ab[[1]], ab[[2]] A B A-B 1 Character,2 Character,5 "b" 2 Character,2 Character,5 "g" 3 Character,3 Character,3 Character,3 4 Character,5 Character,3 Character,2 5 Character,2 "i"

Re: [R] prcomp - principal components in R

2009-11-09 Thread Tony Plate
e a shortcut for computing the values of D in the SVD of a matrix -- you could look for that if you have demanding computations (e.g., the sqrts of the eigen values of the covariance matrix of scaled x: sqrt(eigen(var(scale(x, center=T, scale=F)), only.values=T)$values)). -- Tony Plate

Re: [R] rm(list<-ls()) error

2009-11-05 Thread Tony Plate
; argument having the value of ls() Here's an example that doesn't confuse things by having non-standard evaluation rules: f <- function(a=1, b=2) cat("a=", a, "b=", b, "\n") b Error: object 'b' not found f(b <- 33) a= 33 b= 2 b [1]

Re: [R] Create Artificial Binary Matrix based on probability

2009-11-03 Thread Tony Plate
x <- matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30) table(x) x 01 1131 69 x <- matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30) table(x) x 01 1151 49 bikemike42 wrote: Dear All, I am trying to create an artificial binary matrix

Re: [R] column names of a correlation matrix

2009-10-28 Thread Tony Plate
col a 1 2 b 2 3 cbind(ii, cor=xc[ii]) row colcor a 1 2 -0.3767034 b 2 3 0.6040273 -- Tony Plate Lee William wrote: Hi! All, I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish to obtain pairs with highest correlation values. So, I

Re: [R] LDA Precdict - Seems to be predicting on the Training Data

2009-10-20 Thread Tony Plate
sep="\t") fit <- lda(c1 ~ v1 + v2 + v3, data=myDat[1:10,]) predict(fit, myDat[11:16,]) $class [1] c c c b c a Levels: a b c ... -- Tony Plate BostonR wrote: When I import a simple dataset, run LDA, and then try to use the model to forecast out of sample data, I get a forecast

Re: [R] rbind to array members

2009-10-19 Thread Tony Plate
, you must add a row to all the slices. When I read "to add a row in place to a single table of the 3 dimensional array" it sounds like you might be trying to do something that's not possible with R arrays. However, if I could see your examples, then I probably give more help. --

Re: [R] populating an array

2009-10-16 Thread Tony Plate
R doesn't access arrays like C, use [i,j] to access a 2-d array, e.g.: my_array <- array(0,dim=c(2,2)) for(i in seq(1,2,by=1)){ + for(j in seq(1,2,by=1)){ + my_array[i,j] = i+j + } + } my_array [,1] [,2] [1,]23 [2,]34 tdm wrote: Hi, Can someone please give m

Re: [R] Re use objects from within a custom made function

2009-10-12 Thread Tony Plate
test$x doesn't evaluate the function, you want something like test(1,2)$x, e.g.: test <- function(i, j){ x <- i:j y <- i*j z <- i/j return(list(x=x,y=y,z=z)) } test(1,2)$x [1] 1 2 test(1,2)$y [1] 2 test(1,2)$z [1] 0.5 Or if you want to avoid evaluating y

Re: [R] help with the use of mtext to create main title over multiple plots

2009-10-12 Thread Tony Plate
Try playing around with the "oma" setting in par() -- it sets the outer margins, which by default are zero. The following shows the mtext label for me, using the windows device: par(mfrow=c(2,2)) par("oma") [1] 0 0 0 0 par("oma"=c(0,0,2,0)) for (i in 1:4) plot(0:1,0:1) mtext(text = "my test

Re: [R] how to have 'match' ignore no-matches

2009-10-05 Thread Tony Plate
x <- data.frame(d=letters[1:3], e=letters[3:5]) lookuptable <- c(a="aa", c="cc", e="ee") match.or.keep <- function(x, lookuptable) {if (is.factor(x)) x <- as.character(x); m <- match(x, names(lookuptable)); ifelse(is.na(m), x, lookuptable[m])} # to return a matrix apply(x, 2, match.or.keep, looku

Re: [R] grep or other complex string matching approach to capture necessary information...

2009-09-25 Thread Tony Plate
6, but do be careful of the gotcha that sample(2:3, ...) will generate a selection of 2's and 3's, while sample(3,...) will generate samples from 1, 2, and 3.) -- Tony Plate Jason Rupert wrote: Say I have the following data: house_number<-floor(runif(100, 200, 600)) water_eval

Re: [R] Downloading currency data from from Yahoo

2009-09-24 Thread Tony Plate
0.52 0.52 0.51 0.51 0.51 0.51 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:6] "GBP=X.Open" "GBP=X.High" "GBP=X.Low" "GBP=X.Close" ... Indexed by objects of class: [Date] TZ: GMT xts Attributes: List of 2 $ src: chr "yahoo&q

Re: [R] How can I get "predict.lm" results with manual calculations ? (a floating point problem)

2009-09-14 Thread Tony Plate
m + smallPosNum) + bigNegNum). They can also depend on whether intermediate results are kept in CPU registers, which sometimes have higher precision than 64 bits. Usually, they're nothing to worry about, which is one of the major reasons that all.equal() has a non-zero default for the

Re: [R] un run run...

2009-08-14 Thread Tony Plate
You could try setting options(error=function() NULL). This should cause R in batch mode to continue running after an error (the same way it does in interactive mode.) -- Tony Plate Nir Shachaf wrote: Hi All, I am running an Rscript with a bunch of algorithms that are UNSTABLE under some

Re: [R] A question on operation on list

2009-07-22 Thread Tony Plate
ind(along=0, x2)) [1] 5 2 2 colSums(abind(along=0, x2)) [,1] [,2] [1,] 1.768406 -1.534413 [2,] -1.534413 3.890200 -- Tony Plate megh wrote: Hi, I have created a list object like that : x = vector("list") for (i in 1:5) x[[i]] = rnorm(2) x Now I want to do two th

Re: [R] Checking a (new) package - examples require other package functions

2009-05-13 Thread Tony Plate
Did you try putting library("your-package-name", char=TRUE) at the start of the examples? -- Tony Plate Rebecca Sela wrote: I am creating an R package. I ran R CMD check on the package, and everything passed until it tried to run the examples. Then, the result was: * checkin

Re: [R] Finding rows common to two datasets

2009-04-28 Thread Tony Plate
ded to whole numbers x1 <- x x1$a <- round(x1$a) merge(x1, y, by=c("a", "b")) a b c.x c.y 1 1 3 A C # intersect() returns columns that are the same in each dataframe, not rows intersect(x, y) c 1 C 2 D intersect(x1, y) a c 1 1 C 2 2 D -- Ton

Re: [R] Puzzled by an error with apply()

2009-04-07 Thread Tony Plate
wever, it's difficult to diagnose without at least seeing some cut'n'pasted transcripts. The output of traceback() would also be useful. -- Tony Plate Gang Chen wrote: I've written a function, myFunc, that works fine with myFunc(data, ...), but when I use apply() to run it with an

Re: [R] sorting by creation time in ls()

2009-03-17 Thread Tony Plate
R doesn't keep track of when objects were created, so that's not possible. If this is important to you, you could look at the 'trackObjs' package, which does this and also stores individual objects in individual files (and writes them to the file when they are changed i

Re: [R] Strange behaviour of ISOdatetime

2009-02-10 Thread Tony Plate
_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] TimeWarp_0.7abind_1.2-0 trackObjs_0.8-0 tap.misc_1.0 [5] bmc.misc_1.0RtTests_0.1-5 -- Tony Plate Pedro de Barros w

Re: [R] abind

2008-10-28 Thread Tony Plate
8 [2,]4569 10 ) If none of this is what you want, you could consider storing the matrices in a list, as another poster suggested. -- Tony Plate Suyan Tian wrote: I am trying to combine two arrays with different dimensions into one. For example The first one is 1 2 3

Re: [R] name returned by lapply

2008-07-21 Thread Tony Plate
If you return the value as named list, you get your answer using unlist(res, recursive=F): > res <- lapply(1:2, function(i) {val <- list(i); names(val) <- paste("Hugo", i, sep="_"); return(val)}) > unlist(res, rec=F) $Hugo_1 [1] 1 $Hugo_2 [1] 2 > Antje wrote: Oh true, this would solve the

Re: [R] automation of R? running an R script at a certain time each night?

2008-05-23 Thread Tony Plate
May 23 10:40:01 2008 (I'm sure there are dozens of other ways of doing this, but the above worked for me.) -- Tony Plate --- Edward Wijaya <[EMAIL PROTECTED]> wrote: You might try cron job under Windows. http://drupal.org/node/31506 HTH. - Edward On Thu, May 22, 2008 at

Re: [R] R is a virus, spyware or malware (gasp!)

2008-05-19 Thread Tony Plate
couldn't see any email contact address on their web page.) -- Tony Plate Peter Dalgaard wrote: Ioannis Dimakos wrote: Of course it's a virus. Once you catch the virus, you feel this rush, this fever to abandon all other statistical packages. On a more serious note, though, the siz

Re: [R] Accessing items in a list of lists

2008-05-14 Thread Tony Plate
Try this: > data1 <- list(a = 1, b = 2, c = 3) > data2 <- list(a = 4, b = 5, c = 6) > data3 <- list(a = 3, b = 6, c = 9) > comb <- list(data1 = data1, data2 = data2, data3 = data3) > sapply(comb, "[[", "a") data1 data2 data3 1 4 3 > # Also, this can be useful: > comb[[c("data2", "b")]

Re: [R] Max consecutive increase in sequence

2008-05-13 Thread Tony Plate
If the increases or decreases could be any size, rle(sign(diff(x))) could do it: > x <- c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1) > r <- rle(sign(diff(x))) > r Run Length Encoding lengths: int [1:5] 3 2 2 5 4 values : num [1:5] 1 0 1 -1 0 > i1 <- which(r$lengths==max(r$lengths[r$v

Re: [R] test

2008-05-12 Thread Tony Plate
this option to No. I see 5 identical posts with the subject "Several questions about MCMClogit" on R-help recently. -- Tony Plate j t wrote: Sorry to bother your. I am trying to post my question for more than 10 times, but I still didn't see it. It drives my crazy!!! It i

Re: [R] Format integer

2008-05-12 Thread Tony Plate
Try something like one of these (as documented in ?formatC) > formatC(13, flag="0", width=10) [1] "13" > sprintf("%010g", 13) [1] "13" > Anh Tran wrote: Hi, What's one way to convert an integer to a string with preceding 0's? such that '13' becomes '013' to be put into a

Re: [R] Replicating Rows

2008-05-08 Thread Tony Plate
Another way is using straightforward indexing: > x <- cbind(trips=c(1,3,2), y=1:3, z=4:6) > x trips y z [1,] 1 1 4 [2,] 3 2 5 [3,] 2 3 6 > # generate row indices with the appropriate > # number of repeats > ii <- rep(seq(len=nrow(x)), x[,1]) [1] 1 2 2 2 3 3 > # use these indices

Re: [R] How to stop buffering of "cat"

2008-04-30 Thread Tony Plate
If you're using Rgui under Windows, see FAQ 7.1: 7.1 When using Rgui the output to the console seems to be delayed. This is deliberate: the console output is buffered ... (the FAQ says how to turn it off -- it's a menu item). Vidhu Choudhary wrote: Hi All, My R code takes very long time to f

Re: [R] Applying user function over a large matrix

2008-04-29 Thread Tony Plate
lling simpleLoess() with, and then try calling stats:::simpleLoess() directly. (Of course you have to be careful with this because this is not using the published API). -- Tony Plate Sudipta Sarkar wrote: Respected R experts, I am trying to apply a user function that basically calls and applies

Re: [R] What objects will save.image saves ? And how to specify objects to be saved..

2008-04-16 Thread Tony Plate
track of those manually. AFAIK, it's not possible to add some new vars to an existing .RData file -- that's why I wrote the above to save them in a .RData file that's different to the one that contained the old variables. -- Tony Plate Ng Stanley wrote: > Read and reread, can&#

Re: [R] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Tony Plate
bbreviations might break, but it will likely break quickly and noisily, so it's not too bad (the only case where it wouldn't break is when fn has a '...' argument itself, and it ignores unrecognized components, or where the are other argument name collisions). -- Tony Plate >

Re: [R] using eval-parse-paste in a loop

2008-02-26 Thread Tony Plate
son your attempts with parse() were failing is that default argument of parse() is a filename (do args(parse) to see this quickly). You wanted parse(text=...). -- Tony Plate Michael Anyadike-Danes wrote: > R-helpers > > > > I have 120 small Excel sheets to read and I am usin

Re: [R] Data frame with 0 rows.

2008-02-20 Thread Tony Plate
? I'm unsure of their virtue or seediness, but here are some alternatives: > data.frame(a=numeric(0), b=numeric(0)) # include 9 arguments if you like [1] a b <0 rows> (or 0-length row.names) > as.data.frame(rep(list(a=numeric(0)), 9)) [1] a a.1 a.2 a.3 a.4 a.5 a.6 a.7 a.8 &

Re: [R] Odp: How to make t.test handle "NA" and "essentially constant values" ?

2008-02-12 Thread Tony Plate
(is(obj, "try-error")) return(NA) else return(obj$p.value) + } > my.t.test.p.value(numeric(0)) [1] NA > my.t.test.p.value(1:10) [1] 0.000278196 > my.t.test.p.value(1) [1] NA > my.t.test.p.value(c(1,1,1)) [1] NA > my.t.test.p.value(c(1,2,NA)) [1] 0.2048328 >

Re: [R] Maximum number of variables allowed in a multiple linearregression model

2008-02-06 Thread Tony Plate
handle up to 1 million rows - recent versions prior to 2008 could handle on 64K rows - see http://en.wikipedia.org/wiki/Microsoft_Excel#Versions ). So, the suggestion to consult a local statistician is good advice - there may be other more suitable approaches, and if some form of linear regre

Re: [R] unload & reload a (new version of a) package

2008-01-14 Thread Tony Plate
See ?detach, in particular the 'unload' argument and "Details" (issues involve namespaces & methods, among other things). Also, note that if the package loaded any compiled code (DLL's in Windows), some OS's do not support unloading & reloading these.

Re: [R] `[.data.frame`(df3, , -2) and NA columns

2008-01-10 Thread Tony Plate
;undefined columns selected") so, if a dataframe x has NA values for column names, you should expect x[...] to *sometimes* stop with that error (with a bit of reading and testing you could probably work out exactly when that error will occur). -- Tony Plate Dieter Menne wrote: > Dear base

[R] [R-pkgs] new version of trackObjs

2007-12-22 Thread Tony Plate
ent. o Fixed bug that stopped track.stop(all=TRUE) from working -- Tony Plate ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mail

Re: [R] Efficient way to find consecutive integers in vector?

2007-12-21 Thread Tony Plate
--- > ## using text & parse {cheap and dirty} : > mkseq <- function(i,j) if(i == j) i else paste(i,":",j, sep="") > parse(text = > paste("c(", paste(mapply(mkseq, s1,s2), collapse = ","), ")",

Re: [R] assigning and saving datasets in a loop, with names changing with "i"

2007-12-21 Thread Tony Plate
Marie Pierre Sylvestre wrote: > Dear R users, > > I am analysing a very large data set and I need to perform several data > manipulations. The dataset is so big that the only way I can play with it > without having memory problems (E.g. "cannot allocate vectors of size...") > is to write a batch s

Re: [R] Function reference

2007-12-19 Thread Tony Plate
ot; "stu(2)" "stu(3)" > parse( text = paste( fun, "(", x, ")", sep = "" ) ) expression(stu(0), stu(1), stu(2), stu(3)) attr(,"srcfile") > (Others have observed that in a very large proportion of the situations where people reach f

Re: [R] Factor Madness

2007-12-18 Thread Tony Plate
nks to Mark Leeds for pointing that out to me in a private message! (I see this still in the source at https://svn.r-project.org/R/trunk/src/library/base/man/cbind.Rd -- is that the right place to look for the latest source to make sure it hasn't been fixed already?) -- Tony Plate

Re: [R] Factor Madness

2007-12-18 Thread Tony Plate
ssing 'spectrum' is a data.frame before the code fragment you've shown) hope this helps, Tony Plate Johannes Graumann wrote: > Why is class(spectrum[["Ion"]]) after this "factor"? > > spectrum <- cbind(spectrum,Ion=rep("", > nrow(spectrum)

Re: [R] Array dimnames

2007-12-17 Thread Tony Plate
ata (Qty), so you're probably storing it in a data frame. AFAIK, there is no 3d object in R that can store mixed-type data like a data frame can. An array object in R has to have the same data type for every column etc. -- Tony Plate dave mitchell wrote: > Dear all, > Possibly a rudimen

Re: [R] what does cut(data, breaks=n) actually do?

2007-12-14 Thread Tony Plate
ct(s) are masked from package:base : format.pval, round.POSIXt, trunc.POSIXt, units > cut2(x1, g=2) [1] 1 1 1 1 1 1 1 1 1 2 Levels: 1 2 > (Additionally, a potentially dangerous peculiarity of quantile() for this kind of purpose is that its

Re: [R] matrix graph

2007-12-11 Thread Tony Plate
Try these: > x <- matrix(rnorm(100), ncol=10) > persp(x) > contour(x) Also, look at the R graph gallery: http://addictedtor.free.fr/graphiques/ -- Tony Plate threshold wrote: > Hi All, simple question: > do you know how to graph the following object/matrix in

Re: [R] How to know created time of object in R?

2007-11-28 Thread Tony Plate
c[1] 1 2007-09-07 08:50:58 0 1 > # (TA="total accesses", TW="total writes") (creation time is tracked too, but not displayed with default settings) For more info, look in the trackObjs package. -- Tony Plate Dong-hyun Oh wrote: > Dear UseRs,

Re: [R] timezone conversion difficulties with the new US daylight saving time switch over

2007-10-31 Thread Tony Plate
Mike Waters wrote: > Tony Plate wrote: >> [...] > You don't say if this an R-specific problem, or if it afflicts your > computer system clock as well. Thanks, I should have noted that my computer system clock is fine, and as far as I can tell it (correctly) believes we a

[R] timezone conversion difficulties with the new US daylight saving time switch over

2007-10-30 Thread Tony Plate
2006-11-10 11:38:47"), "EST5EDT") [1] "2006-11-10 11:38:47 EST" > The problem in 2006 goes away if I set TZ="EST5EDT": > Sys.setenv(TZ = "EST5EDT") > Sys.timezone() [1] "EST" > as.POSIXlt(as.POSIXct("2006-10-30 11:38:47&q

Re: [R] functions applied to two vectors

2007-10-23 Thread Tony Plate
> a <- c(2, 3, 7, 5) > b <- c(4, 7, 8, 9) > mapply(seq, a, b) [[1]] [1] 2 3 4 [[2]] [1] 3 4 5 6 7 [[3]] [1] 7 8 [[4]] [1] 5 6 7 8 9 > mapply(sum, a, b) [1] 6 10 15 14 > hope this helps, Tony Plate Anya Okhmatovskaia wrote: > Hi, > > I am very new to R, s

Re: [R] Input appreciated: R teaching idea + a way to improve R-wiki

2007-10-23 Thread Tony Plate
eople to provide good advice. > The wiki seems to be riddled with poor practice and "hacks" to get > around misunderstandings of the way R works. Is there any way on the R-Wiki for people to quickly and easily add an annotation indicat

Re: [R] Save and load workspace in R: strange error.

2007-10-03 Thread Tony Plate
ygwin, but essentially disable use of a particular file. I generally fix this by resetting ownership and all permissions using Windows dialogs. It sounds like you need to get your sysadmins to help you sort this problem out. -- Tony Plate Hongxiao Zhu wrote: > Tony, > > Thanks for return.

Re: [R] Save and load workspace in R: strange error.

2007-10-03 Thread Tony Plate
, I would suggest posting more details back to the list, e.g., what OS you are using, and a directory listing that shows file sizes and permissions (i.e., as you get with 'ls -l' on Unix systems.) -- Tony Plate Hongxiao Zhu wrote: > Hi, > > I tried to load a .RData object on unix s

Re: [R] how can I attach a variable stored in

2007-09-20 Thread Tony Plate
Here's a function that does what I think you want to do: > attach.firstvar <- function(file) { + tmpenv <- new.env() + vars <- load(file, envir=tmpenv) + x <- get(vars[1], envir=tmpenv, inherits=FALSE) + if (is.list(x)) + attach(x, name=vars[1]) + return(vars) + } > x

Re: [R] a quick question about "format()"

2007-09-18 Thread Tony Plate
runner wrote: > In the documentation of 'pairs'(package:graphics), within the last example, > it reads: > > format(c(r, 0.123456789), digits=3)[1] > > Why not simple use: format(r, digits=3)? What is the difference? Here are some examples of the difference: > for (r in 1.2*10^(-6:9)) cat(form