Displaying 20 results from an estimated 8000 matches similar to: "Questions on dividing lists and tapply"
2011 May 03
3
help with the maxBHHH routine
Hello R community,
I have been using R's inbuilt maximum likelihood functions, for the
different methods (NR, BFGS, etc).
I have figured out how to use all of them except the maxBHHH function. This
one is different from the others as it requires an observation level
gradient.
I am using the following syntax:
maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)
2011 Feb 06
5
Help with integrating R and c/c++
Hi,
I have been using R for close to two years now and have grown quite
comfortable with the language. I am presently trying to implement an
optimization routine in R (Newton Rhapson). I have some R functions that
calculate the gradient and hessian (pre requisite matrices) fairly
efficiently. Now, I have to call this function iteratively until some
convergance criterion is reached. I think the
2011 Feb 21
1
Mutiplying a data frame to a list
Hi R community,
I have a question I'm sure is very simple for most of you.
I have a list, with each element being a matrix and the names of the
elements are numbers (like 1,3,...). I can extract the matrices and the
names individually. Now, I want to multiply each of the names to the
individual list matrices (after converting to numbers of course).
I could use a for loop, but the very
2012 Jan 28
1
Using the digest and t distribution.
Hello R community,
I have two questions:
The first might be one of the silliest ever posted here and I
apologize if I've missed some thing very obvious. It relates to using
this digest. When I subscribed to the forum, I had chosen the "digest"
option that bundles all mails every day into a single digest.
Now, I posted a question a while ago on the logistic regression
function and
2012 Jan 15
1
Need help interpreting the logit regression function
Hello R community,
I have a question about the logistic regression function.
Specifically, when the predictor variable has not just 0's and 1's,
but also fractional values (between zero and one). I get a warning
when I use the "glm(formula = ... , family = binomial(link =
"logit"))" which says:
"In eval(expr, envir, enclos) : non-integer #successes in a binomial
2010 Jan 20
5
standardizing one variable by dividing each value by the mean - but within levels of a factor
Hello!
I have a data frame with a factor and a numeric variable:
x<-data.frame(factor=c("b","b","d","d","e","e"),values=c(1,2,10,20,100,200))
For each level of "factor" - I would like to divide each value of
"values" by the mean of "values" that corresponds to the level of
"factor"
In other
2012 Oct 16
1
data dividing
hey
I'd like to divide my data into four seasons. for this I made a function:
Jahreszeit <- function(x) {
if (x<=02 || x==12) {return("Winter")
}else{
if (x>=03 && x<=05) {return("Fruehling")
}else{
if (x>=06 && x<=08) {return("Sommer")
}else{
if (x>=09 && x<=11) {return("Herbst")
}}}}}
Now, I have some
2017 Jan 26
0
RFC: tapply(*, ..., init.value = NA)
It would be cool if the default for tapply's init.value could be
FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
FUN=all, -Inf for FUN=max, etc. But that would take time and would
break code for which FUN did not work on length-0 objects.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Jan 26, 2017 at 2:42 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
2008 Jul 08
0
Fwd: Re: extracting index list when using tapply()
The following message is provided by Erik
Please provide the reproducible code to do this. Generate a sample data
set using the random data generating functions and show us what you'd
like, we can then more easily help.
ctu at bigred.unl.edu wrote:
> Hi,
> How about using "subset"?
> x1<-tapply(subset(years, length(area)>20), function(x) length(unique(x)))
>
2007 Nov 06
1
A suggestion for an amendment to tapply
Dear R-developers,
when tapply() is invoked on factors that have empty levels, it returns
NA. This behaviour is in accord with the tapply documentation, and is
reasonable in many cases. However, when FUN is sum, it would also
seem reasonable to return 0 instead of NA, because "the sum of an
empty set is zero, by definition."
I'd like to raise a discussion of the possibility of an
2009 Sep 03
2
dividing a dataframe column by different constants
Dear R users, today I've got the following problem.
Here you are a dataframe as example.
There are some SAMPLES for which a CONCentration was recorded through TIME.
The time during which the concentration was recorded is not always the same,
10 points for Sample A, 7 points for Sample B and 11 for sample C
Also the initial concentration was not the same for the three samples.
I would like
2007 Jun 18
1
getting tapply() to work across multiple columns
I have the following data.frame:
index <- c("a","a","b","b","b")
alpha <- c(1,2,3,4,5)
beta <- c(2,3,4,5,6)
table <-data.frame(index,alpha,beta)
I'm now interested in getting means of alpha and beta for each of the
index values and do a tapply() for each of the columns, e.g.
means.alpha <- tapply(table$alpha, index,mean)
2017 Jan 27
0
RFC: tapply(*, ..., init.value = NA)
> On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org>
> wrote:
> It would be cool if the default for tapply's init.value could be
> FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
> FUN=all, -Inf for FUN=max, etc. But that would take time and would
> break code for which FUN did not work on
1999 Feb 19
1
Potential problem with tapply
Is the following behaviour of tapply not disappointing?
Problem with tapply occurs when dealing with na.rm when an
argument additional to na.rm is sent to the applied function (here
quantile).
Any comment?
Thank you,
Philippe Lambert
> x <- c(12,10,12,2,4,11,3,7,2,1,18,7,NA,NA,7,5)
> fac <- gl(4,4,16)
> # Works fine
> tapply(x,fac,quantile,na.rm=T)
$"1"
0% 25%
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists:
xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) )
xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site
, FUN=function(z)yield[z]))
I can convert xa to a dataframe easily with:
as.data.frame(xa)
But if i try the same with xb I get:
as.data.frame(xb)
Error in as.data.frame.default(xb) :
can't coerce array into a data.frame
What
2004 May 13
2
tapply & hist
I'm learning how to use tapply.
Now I'm having a go at the following code in which dati contains almost 600
lines, Pot - numeric - are the capacities of power plants and SGruppo - text
- the corresponding six technologies ("CCC", "CIC","TGC", "CSC","CPC", "TE").
.....................................................
2012 Sep 03
1
Scatter plot from tapply output, labels of data
Hei,
i am trying to plot the means of two variables (d13C and d15N), by 2
grouping factors (Species and Year) that i obtained by the function tapply.
I would like to plot with different colours according to the Year and show
the "Species" as data labels.
My data looks like this:
Species d13C d13N Year
"Species1" 14,4 11.5 2009
"Species2"
2009 Dec 01
1
Remark on tapply().
Consider the following:
> set.seed(42)
> ff <- factor(sample(c(1,3,5),42,TRUE),levels=1:5)
> x <- runif(42)
> tapply(x,ff,sum)
1 2 3 4 5
3.675436 NA 7.519675 NA 9.094210
I got bitten by those NAs in the result of tapply(). Effectively
one is summing over the empty set, and consequently (according to what
I learned as a child)
2005 Jan 26
0
tapply with weighted.mean
We were caught out recently attempting to use tapply to get a table of
weighted means. This gives the wrong answer (or, more correctly, not
the answer we were expecting), as the following example shows:
R> x <- 1:10 #some data
R> w <- c(1:5,5:1) #weights
R> id <- rep(1:2,rep(5,2)) #id values
R> weighted.mean(x[id==1],w[id==1]) #Weighted mean of x in group 1
[1] 3.666667
2010 Feb 02
3
tapply for function taking of >1 argument?
I'm sure I can put this together from the various 'apply's and split, but I
wonder if anyone has a quick incantation:
E.g. I can do tapply( data, groups, mean)
but how can I do something like: tapply( list(data,weights), groups,
weighted.mean ) ?
(or: mapply is to sapply as ? is to tapply )
Thanks for your help.
--
View this message in context: