Dear all,
I have been trying the following without avail and would be very grateful for
any help. From a dendrogram (recursive list of lists with some structure), I
would like to obtain some information of the component lists and of the
enclosing list at the same time. In dendrogram-speech I
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" (
My apologies, I know that this is not a new problem, but I'm not sure how
to find the answer
I want to recursively loop over an object and trim trailing white space.
When I use this function on a list of data.frame I get output like this:
[1] "c(\" many spaces \", \" many spaces \")" "c(\"
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
Dear all,
I'm having some problems getting my recursive function to work. At first I
though that maybe my data was too big and I increase option(expressions=5).
Then I thought that I would try it on some smaller data. Still not working. :(
I would have thought there should be a function for
--
From: "Tremblay, Pierre-Olivier"
Sent: Thursday, May 19, 2011 2:42 PM
To:
Subject: [R] recursive function
Hi,
I created a function for obtaining the normal cumulative distribution (I
know all this already exists in R, I just wanted to verify my
understanding of it).
(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
Hi,
I created a function for obtaining the normal cumulative distribution (I
know all this already exists in R, I just wanted to verify my
understanding of it). below is the code I came up with.
cdf<-function(x) {
erf<-function(x) {
# approximation to the error function
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
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:
I have a data frame more or less like this:
variableyear DELTA
EC01 2006/
EC01 2007 10
I've written a recursive function to extract the members of an
individual cluster within a hierarchical clustering. I have something
that works, but the return value has a list structure I don't like. I
know how to work around with 'unlist()' but I suspect the function
could be fixed. Ca
sting methods
and a bit faster than pmvnorm.
-- David
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, February 19, 2008 3:08 PM
To: r-help@r-project.org
Subject: [R] recursive function help
I'm trying to implement a
I'm trying to implement a recursive function using integrate, and I
suspect I need a Vectorize somewhere,
but I can't suss it out. Any help would be appreciated. I've tried
traceback() and various debugging ideas to no avail (most likely due to
my inexperience with these tools.)
Here's what I have
It is possible to place two functions in a recursive function
Main results so as to simultaneously?
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
26 matches
Mail list logo