Displaying 20 results from an estimated 60000 matches similar to: "calling functions"
2009 Jun 23
2
an idiom to handle i'th element of a set of lists simultaneously
Hi, I have 3 lists, x, y, z and I'd like to perform a calculation over all
the lists simultaneously. If it were a single list I could use lapply, but
for more than one list I'm using a for loop. Is there an idiom that would
let me use something like lapply, but the function specified to lappy would
have access to an element from each list? (In Python, I would have used for
a,b,c in
2009 Nov 10
2
All possible combinations of functions within a function
Dear All,
I wrote a function for cluster analysis to compute cophenetic correlations
between dissimilarity matrices (using the VEGAN library) and cluster
analyses of every possible clustering algorithm (SEE ATTACHED)
http://old.nabble.com/file/p26288610/cor.coef.R cor.coef.R . As it is now,
it is extremely long, and for the future I was hoping to find a more
efficient way of doing this sort of
2008 Jan 08
1
using mapply()
useR's,
This is a follow up question to one I previously asked. Consider the
3-element list below
> res
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[,13] [,14]
[1,] NA NA NA 1.25 0.25 0.75 NA NA NA NA NA NA 1.25
0.25
[2,] 1.25 0.25 0.75 NA NA NA NA NA NA 1.25 0.25 0.75 NA
NA
[3,] NA NA NA NA NA
2007 Feb 13
2
Computing stats on common parts of multiple dataframes
Folks,
I have three dataframes storing some information about
two currency pairs, as follows:
R> a
EUR-USD NOK-SEK
1.23 1.33
1.22 1.43
1.26 1.42
1.24 1.50
1.21 1.36
1.26 1.60
1.29 1.44
1.25 1.36
1.27 1.39
1.23 1.48
1.22 1.26
1.24 1.29
1.27 1.57
1.21 1.55
1.23 1.35
1.25 1.41
1.25 1.30
1.23 1.11
1.28 1.37
1.27 1.23
R> b
EUR-USD NOK-SEK
1.23 1.22
1.21 1.36
1.28 1.61
1.23 1.34
1.21 1.22
2009 Jun 03
1
Vectorize fails for function with ... arglist
Vectorize is defined to return a function that acts as if 'mapply' was
called.
So we have:
> mapply(dput,1:2) # mapply form
1L # calls dput on each element of 1:2
2L
[1] 1 2
> Vectorize(dput)(1:2) # Vectorize form
1L # same behavior
2L
[1] 1 2
Same thing with a named argument:
>
2010 Jun 15
1
vectorize subscript ranges?
Hi R'ers-
I'll believe this can be done and that I'm just not clever enough.
I'm trying to do this in 2D, but i think we have the same problem in 1D.
#Assume you have some 1D time series
d<-rnorm(100)
#Say you want to get the average over intervals of different lengths
#like from time 10 to time 24 and time 51 to time 86
starts <- c(10,51)
ends <- c(24,86)
results
2004 Feb 24
3
Calculate Distance and Aggregate Data?
Hi all,
I've been struggling learning R and need to turn to the list again.
I've got a dataset (comma-delimited file) with the following fields: recid, latitude, longitude, population, dwelling and age. For each observation, I'd like to calculate the total number of people and dwellings and average age within 2 k.m. Distance could be Euclidean, however, a proper distance
2011 Feb 02
2
Help me apply mapply
Hello all I would like to ask your help use mapply.
I have a function called findCell that takes two arguments(x,sr)
where x is a vector of size two (e.g x<-c(2,3) and sr is a matrix.
I would like to call many times the findCell function (thus I need mapply) for different x inputs but always for the same sr.
as x is a vector of size two (two cells) I want to pass inside inside the following
2011 Aug 26
3
How to vectorize a function to handle two vectors
Dear R-users
I am trying to "vectorize" a function so that it can handle two vectors of
inputs. I want the function to use phi (a function), k[1] and t[1] for the
first price, and so on for the second, third and fourth price. I tried to do
the mapply, but I dont know how to specify to R what input I want to be
vectors (k and t)(see in the bottom what I tried). I have read the help
file,
2008 Sep 07
3
Averaging 'blocks' of data
Dear all,
I have a large dataset which I hope to reduce in size, to make it more useable. I hope to do this by taking an average of each 60 x 60 blockof values and forming a new data frame out of the averaged values.
How would I go about taking averages of 60 x 60 'blocks' in R, and cycling through the whole dataset, recording each calculated value in a new table/data frame?
Many thanks
2015 Mar 27
5
Netflix
Now that netflix is in Australia, I wouldn't mind giving it a burl. It's
working fine on my fedora-21 lappy with chrome-40 but not on our centos-6
mythtv setup even with chrome-41. I understand the difference might be the
version of NSS - fedora-21 has 3.17 while centos is stuck at 3.16. Other than
that, I'm flumoxed.
Anyone got netflix running on centos-6?
Cheers
Bob
2007 Aug 10
1
[Fwd: Re: How to apply functions over rows of multiple matrices]
[Apologies to Gabor, who I sent a personal copy of the reply
erroneously instead of posting to List directly]
[...]
> Perhaps what you really intend is to
> take the average over those elements in each row of the first matrix
which correspond to 1's in the second in the corresponding
> row of the second. In that case its just:
>
> rowSums(newtest * goldstandard) /
2010 Oct 29
2
vertical list sum
Hi Everyone,
I have a list of vectors like this (in this case it's 3 vectors but assume the vector count and the length of each vector is not known):
[[1]]
[1] 9 5 7 2 14 4 4 3
[[2]]
[1] 3 6 25 2 14 3 3 4
[[3]]
[1] 28 4 14 3 14 2 4 5
What I want to do is take the average vertically. Thus I want to do 9+3+28 /3, 5+6+4 /3, etc... and then have it return a vector. I'm
2010 May 26
5
(no subject)
Dear group,
Here is my data frame:
> dput(u)
structure(list(DESCRIPTION = structure(c(2L, 5L, 6L, 7L, 9L,
11L, 12L, 15L, 14L, 16L, 1L, 10L, 3L, 4L, 13L, 8L, 17L), .Label = c("COFFEE
C Jul/10",
"COPPER May/10", "CORN Jul/10", "CORN May/10", "COTTON NO.2 Jul/10",
"CRUDE OIL miNY May/10", "GOLD Jun/10", "HENRY HUB
2010 Jun 02
3
Seeking help on Vectorize()
Dear falks, here I have written following function :
fn <- Vectorize(function(x = 1:3, y = 3:6) {
x <- matrix(x, nrow=1)
y <- matrix(y, ncol=1)
dat <- apply(x, 2, function(xx) {
apply(y, 1, function(yy) {
return(xx + yy) } ) })
return(dat)}, SIMPLIFY = TRUE)
If I run this function, I got
2010 Jan 27
2
using functions with multiple arguments in the "apply" family
typically, the apply family wants you to use vectors to run functions on.
However, I have a function, kruskal.test, that requires 2 arguments.
kruskal.test(Herb.df$Score,Herb.df$Year)
This easily computes the KW ANOVA statistic for any difference across
years....
However, my data has multiple sites on which KW needs to be run...
here's the data:
Herb.df<-
2009 Feb 26
3
Moving Average
I am looking for some help at removing low-frequency components from a signal, through Moving Average on a sliding window.
I understand thiis is a smoothing procedure that I never done in my life before .. sigh.
I searched R archives and found "rollmean", "MovingAverages {TTR}", "SymmetricMA".
None of the above mantioned functions seems to accept the smoothing
2007 Jun 07
1
Averaging across rows & columns
I use Windows, R version 2.4.1.
I have a dataset in which columns 1-3 are replicates, 4-6, are replicates,
etc. I need to calculate an average for every set of replicates (columns
1-3, 4-6, 7-9, etc.) AND each set of replicates should be averaged every 14
rows (for more detail, to measure fruit color using a spectrometer, I
recorded three readings per fruit -replicates- that I need to average to
2007 Aug 09
1
How to apply functions over rows of multiple matrices
Dear ExpRts,
I would like to perform a function with two arguments
over the rows of two matrices. There are a couple of
*applys (including mApply in Hmisc) but I haven't found
out how to do it straightforward.
Applying to row indices works, but looks like a poor hack
to me:
sens <- function(test, gold) {
if (any(gold==1)) {
sum(test[which(gold==1)]/sum(which(gold==1)))
} else NA
}
2011 Mar 20
2
IL-2 Occasional Freezes
Hi everyone,
I just wiped XP off my old Dell D610 and loaded Ubuntu 10.10... it runs like a brand new machine! (If if weren't for compatibility issues I would do the same to my netbook right away!)
Anyway to test out Wine I installed IL-2 1946, patched up to 4.10m.
With a little tweaking it is running like a dream, save one minor issues.
Occasionally the program hiccups with what looks