On Fri, Aug 3, 2012 at 5:41 PM, Gene Leynes wrote:
> Ah yes, good point.
>
> this was easy enough to write, it doesn't lose dimensions, and there's no
> unnecessary complexity... unless you're passing in data frames, in which
> you'll have to recombine them.
>
> trim = function(x) gsub("^[[:space:
Ah yes, good point.
this was easy enough to write, it doesn't lose dimensions, and there's no
unnecessary complexity... unless you're passing in data frames, in which
you'll have to recombine them.
trim = function(x) gsub("^[[:space:]]+|[[:space:]]+$", "", x)
trimmer = function(x){
if(is.list(x))
> It's nice that R keeps the base function list short enough that you can
> look at it, but it would be nice to have a few more convenience functions
> included, especially ones that mirror common functions, like "trim"
> sum(sapply(search(), function(x) length(ls(x
[1] 2376
Over two thousand
On Fri, Aug 3, 2012 at 3:36 PM, Gene Leynes wrote:
> Rui,
> Yes, that's exactly it, thanks!!
> I wouldn't have thought of the "is.atomic". I was going after a series of
> tests for dimension and is.list.
>
>
One other helpful function that I haven't seen anyone mention this far
is ? rapply [= r
Rui,
Yes, that's exactly it, thanks!!
I wouldn't have thought of the "is.atomic". I was going after a series of
tests for dimension and is.list.
@ R. Michael Weylandt
Good point!
Also, thanks for mentioning stringr. I always forget about that one.
It's nice that R keeps the base function list
Burt,
This is a general problem that I have faced many times, and I'm looking for
the best practices for creating an function with a built in iterator. I
know that others exist, but I couldn't think of their names off the top of
my head... the ones I could remember have the iterator built in at t
On Fri, Aug 3, 2012 at 12:19 PM, Rui Barradas wrote:
> Hello,
>
> This seems to work.
>
> trim2 <- function(x) {
> if(is.atomic(x))
>
> gsub("^[[:space:]]+|[[:space:]]+$", "", x)
> else
> sapply(x, function(y) trim2(y))
> }
>
Using sapply is a bit dangerous here. Compare:
Hello,
This seems to work.
trim2 <- function(x) {
if(is.atomic(x))
gsub("^[[:space:]]+|[[:space:]]+$", "", x)
else
sapply(x, function(y) trim2(y))
}
# Tests
trim2(tempobj)
trim2(tempvec)
trim2(templist)
trim2(tempdf)
# Extra test
templistlist <- list(templist, list(temp
Note that this is a common enough case that Hadley provides for it
with the str_trim() function in his stringr package.
Best,
Michael
On Fri, Aug 3, 2012 at 12:02 PM, Bert Gunter wrote:
> "Recursively loop over an object" is a pretty meaningless phrase,
> since it depends entirely on the structu
"Recursively loop over an object" is a pretty meaningless phrase,
since it depends entirely on the structure of the object. For example,
a character vector is an object, and there is no need for any sort of
recursion to do what you want for it.
The following regex example trims trailing "spaces" (
One more thing - for large data sets, the packages flashClust and
fastcluster provide much faster hierarchical clustering that (at least
for flashClust which I'm the maintainer of) give the exact same
results. Simply insert a
library(flashClust)
before you call the function and your code will run
Hi Paul,
I assume you are using the argument cutoff to specify the p-value
below which nodes are considered connected and above which they are
not connected.
I would use single linkage hierarchical clustering. If you have two
groups of nodes and any two nodes between the groups are connected
(i.e
Sorry bad example. My data is undirected. It's a correlation matrix so probably
better to look at something like:
foomat<-cor(matrix(rnorm(100), ncol=10))
foomat
mine are pvalues from the correlation but same idea.
On 14 Jul 2011, at 11:23, Erich Neuwirth wrote:
> cliques only works for undir
Perhaps this is useful:
x=c(-2,0,2)
sign(x)*abs(x)
[1] -2 0 2
--
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
F
(1) What has this to do with recursion?
(2) You probably need to use ifelse(). I believe that this is
(in effect) an FAQ.
cheers,
Rolf Turner
On 20/05/11 07:42, Tremblay, Pierre-Olivier wrote:
Hi,
I created a function for obtaining the normal cumulative distribution (I
know all
Try this:
transform(x, DELTA = NULL, value = rev(c(5, 5 - cumsum(rev(DELTA[-1])
On Mon, Jun 14, 2010 at 12:29 PM, n.via...@libero.it wrote:
>
> Dear list,
> I have the following problem, what i'm trying to do is to built a function
> which does the following calculationg in a recursive way:
Hi!
Do you mean something like this (df is your original data frame):
--- cut here ---
df1<-df
df1[[1]]<-paste("R",df[[1]],sep="_")
colnames(df1)<-c("SERIES","YEAR","value")
df1$value[ df1$YEAR==2009 ]<-5
for (i in c(2009:2007)) { df1$value[ df1$YEAR==(i-1) ]<-( df1$value[
df1$YEAR==i ]-df$DELTA
Well, it turns out to be very simple - just insert a Vectorize between
integrate and function(x).
However, the special cases where C[i,j]==1 make the actual code quite
messy.
It matches pmvnorm {mvtnorm} and pmnorm {mnormt} quite well.
And the recursive method is incredibly slow for higher dimensio
18 matches
Mail list logo