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] 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 murdoch.dun...@gmail.com 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

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

Re: [R] Problem in installing and starting Rattle

2011-03-19 Thread Tony Plate
PATH, strsplit(Sys.getenv(PATH), ;)[[1]], value=T, invert=T), collapse=;)) (substitute some pattern that matches the unwanted directory for UNWANTEDPATH, remembering to use four backslashes to match one). -- Tony Plate __ R-help@r-project.org

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(), fixr(), mlazy

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

2010-05-18 Thread Tony Plate
- 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 whether to look in parent environments (inherits=TRUE/FALSE). -- Tony Plate

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 number

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

2009-12-28 Thread Tony Plate
) 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 IBM 12/04/2009 123 -- Tony Plate William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org

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 package. The two

Re: [R] Help with complicated regular expression

2009-11-13 Thread Tony Plate
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 complicated text string using regular expressions. I would appreciate any help you can provide. The string consists

Re: [R] Loadings and scores from fastICA?

2009-11-12 Thread Tony Plate
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 plot, how

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread Tony Plate
(, x, ))), eval), ncol=ncol(x), dimnames=dimnames(x)) X Y row1 Character,2 b row2 c d - Tony Plate esterhazy wrote: Yes, thanks for this, this is exactly what I want to do. However, I have a remaining problem which is how to get R to understand that each entry in my

Re: [R] partial cumsum

2009-11-11 Thread Tony Plate
. 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-project.org mailing list https://stat.ethz.ch

Re: [R] Loadings and scores from fastICA?

2009-11-11 Thread Tony Plate
(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 principal components

Re: [R] Comparison of vectors in a matrix

2009-11-10 Thread Tony Plate
Character,5 g 3 Character,3 Character,3 Character,3 4 Character,5 Character,3 Character,2 5 Character,2 i Character,2 y[1,3] [[1]] [1] b -- Tony Plate esterhazy wrote: Hi, I have a matrix with two columns, and the elements of the matrix are vectors. So for example, in line 3

Re: [R] prcomp - principal components in R

2009-11-09 Thread Tony Plate
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 zubin wrote: Hello, not understanding

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

2009-11-05 Thread Tony Plate
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] 33 f(b=33) a= 1 b= 33 -- Tony Plate Feng Li wrote: Dear R, Why rm(list-ls()) gives an error but rm(list=ls()) not? I

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
[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 did this b=matrix(data=NA,nrow=4217,ncol=1) rownames(b

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

2009-10-20 Thread Tony Plate
, 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 for the training set not the out of sample set. Others

Re: [R] rbind to array members

2009-10-19 Thread Tony Plate
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. -- Tony Plate Another

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

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

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 your

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,

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

2009-09-25 Thread Tony Plate
(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_evaluation-c(No water damage, Water damage, Water On, Water off, water pipes damaged, leaking water) water_evaluation_selection-floor

Re: [R] Downloading currency data from from Yahoo

2009-09-24 Thread Tony Plate
(*, 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 $ updated: POSIXct[1:1], format: 2009-09-24 19:58:01 -- Tony Plate Bogaso wrote: Hi, I wanted to download

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

2009-09-14 Thread Tony Plate
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 tol= argument. -- Tony Plate Tal Galili wrote

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
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 things : 1. for each i, I want to do

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: * checking examples

Re: [R] Finding rows common to two datasets

2009-04-28 Thread Tony Plate
# 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 -- Tony Plate jim holtman wrote: You are missing a comma: common - intersect(data_frame_x[,c(Latitude, Longitude)], data_frame_y[,c(Latitude,Longitude

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

2009-04-07 Thread Tony Plate
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 array of data apply(myArray, 1, myFunc, ...) I get

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 in R). -- Tony Plate

Re: [R] Strange behaviour of ISOdatetime

2009-02-10 Thread Tony Plate
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 wrote: Hi All, I am

Re: [R] abind

2008-10-28 Thread Tony Plate
) 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 4 5 6 The second one is 7 8 9 10

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 problem

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

2008-05-23 Thread Tony Plate
.) -- 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 8:51 AM, Thomas Pujol [EMAIL PROTECTED] wrote: I am using R in a Windows environment. I store my data in a Microsoft SQL database

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

2008-05-19 Thread Tony Plate
The most common objects with the name of RGUI.EXE have yet to be classified as safe by our research department. So, I suspect that they don't actually classify it as a virus, they just haven't classified it as safe... (I couldn't see any email contact address on their web page.) -- Tony Plate

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)]] [1] 5 [EMAIL

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 -

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 is a test for posting some

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 to

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

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

2008-04-29 Thread Tony Plate
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 the R

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

2008-04-16 Thread Tony Plate
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't make out. Will try an experiment later On Wed, Apr 16, 2008 at 7:51 PM

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

2008-03-13 Thread Tony Plate
argument name collisions). -- Tony Plate Thank you very much. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine

Re: [R] Data frame with 0 rows.

2008-02-20 Thread Tony Plate
, 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 0 rows (or 0-length row.names) -- Tony Plate cheers

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

2008-02-12 Thread Tony Plate
my.t.test.p.value(c(1,2)) [1] 0.2048328 hope this helps, Tony Plate Regards Petr [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

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

2007-12-22 Thread Tony Plate
. 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 mailing

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 script

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

2007-12-21 Thread Tony Plate
3 4 5 10 12 13 14 -- Tony Plate Martin MS HTH, MS Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

Re: [R] Function reference

2007-12-19 Thread Tony Plate
large proportion of the situations where people reach for parse/eval, there's a neater, cleaner more direct way of doing the job.) -- Tony Plate Talbot Katz wrote: Hi. I'm looking for an R equivalent to something like function pointers in C/C++. I have a search procedure that evaluates

Re: [R] Factor Madness

2007-12-18 Thread Tony Plate
'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)),Deviation.AMU=rep(0.0, nrow(spectrum))) slowly going crazy ... Joh

Re: [R] Array dimnames

2007-12-17 Thread Tony Plate
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 rudimentary question, however any help

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 a 'surface manner': [,1

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

2007-11-28 Thread Tony Plate
settings) For more info, look in the trackObjs package. -- Tony Plate Dong-hyun Oh wrote: Dear UseRs, I would like to know the created time and date of specific object. Is there any function for it? Thank you in advance. Sincerely, __ R-help

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 are still in Daylight Saving

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

2007-10-30 Thread Tony Plate
/datetime.c:do_asPOSIXlt, and it looks like this isdst value comes from a call to localtime() from localtime0() ... thanks in advance for any help, Tony Plate PS. I do not see the same problem in an old version of R (2.2.1) running under Ubuntu Linux: Sys.timezone() [1] as.POSIXlt((d - Sys.time()), EST5EDT

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

2007-10-23 Thread Tony Plate
that they believe some particular advice is poor practice? Ideally, these annotations would be easily searchable so that other users could find and fix or respond to them. -- Tony Plate Hadley __ R-help@r-project.org mailing list https://stat.ethz.ch

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, so I apologize if I have missed some

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

2007-10-03 Thread Tony Plate
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 system using R, it gives error

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

2007-10-03 Thread Tony Plate
, 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. Actually, the data object

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 -