similar to: aggregate with non-scalar functions

Displaying 20 results from an estimated 8000 matches similar to: "aggregate with non-scalar functions"

2008 Sep 24
2
keep the row indexes/names when do aggregate
Hi, R-users, If I have a data frame like this: >x<-data.frame(g=c("g1","g2","g1","g1","g2"),v=c(1,7,3,2,8)) g v 1 g1 1 2 g2 7 3 g1 3 4 g1 2 5 g2 8 It contains two groups, g1 and g2. Now for each group I want the max v: > aggregate(x$v,list(g=x$g),max) g x 1 g1 3 2 g2 8 Beautiful. But what if I want to keep the row index of (g1
1999 Nov 20
1
seg.fault: 'print(aggregate(),n)' (digits= omitted) (PR#330)
Dear Sirs, I had the following (reproducible) problem: g1 <- gl(3,4) g2 <- gl(2,2,12) y <- rnorm(12) AA <- aggregate(y,list(g1,g2),mean) print(AA,2) # I should've said 'digits=2' but ... Segmentation fault (core dumped) # print(AA) and print(AA,digits=2) work as expected Many thanks, -Rashid Nassar --please do not edit the information below--
2009 Oct 06
1
how to output profile plots for groups using lattice package
Dear R users, I am trying to have an xyplot of a data set which has the following variables: case (n=10,20,30) parameter (parm=a,b) group (grp=g1,g2) y (y values) x (x=2,4,8) My plot should be parameter by case such that I have 2 rows (each row= each parameter) and 3 columns (each column=each case). My R-code is as follows but I am not able to get what I want to: tp1.sim <- xyplot(y~ x | case
2004 Jan 14
1
Collapsing a factor in R
I'm trying to collapse the following table along the sub-group factor. In this case, collapsing means taking the average ages within a subgroup and creating a new table. I seem to be running into trouble trying to create this new data frame. I can use the ave() function to find averages within a subgroup but how do I maintain the Group/Gender factors after collapsing? (see bottom table) Can
2009 Dec 29
2
pass functions and arguments to function
Hi, I wonder how to pass several functions and their arguments as arguments to a function. For example, the main function is f = function(X ) { process1(X) ... process2(X) } I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2), g3(X, par3). par1, par2 and par3 are parameters and of different types. I would like to pass g1, g2, g3 and their arguments to f and g1,
2009 Jul 15
1
Help with averaging
Hi I am using the following script to average a set of data 0f 62 columns into 31 colums. The data consists of values of ln(0.01) or -4.60517 instead of NA's. These need to be averaged for each row (i.e 2 values being averaged). What I would I need to change for me to meet the conditions: 1. If each run of the sample has a value, the average is given 2. If only one run of the sample has a
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users, I used to "OPTIM" to minimize the obj. function below. Even though I used the true parameter values as initial values, the results are not very good. How could I improve my results? Any suggestion will be greatly appreciated. Regards, Kathryn Lord #------------------------------------------------------------------------------------------ x = c(0.35938587,
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users, I used to "OPTIM" to minimize the obj. function below. Even though I used the true parameter values as initial values, the results are not very good. How could I improve my results? Any suggestion will be greatly appreciated. Regards, Kathryn Lord #------------------------------------------------------------------------------------------ x = c(0.35938587,
2012 Dec 04
1
Solve system of equations (nleqslv) only returns origin
I'm solving 4 complex equations simultaneously. Code is below. The code returns only zero's for the solution though there should also be a non-zero result. I'm pretty confident that the equations are correct because they are straight from a published paper and I checked them pretty thoroughly. The parameter values I used are from the published paper as well. Any suggestions for how
2013 Jul 18
1
Bland Altman summary stats for all column combinations
Hello, I have the following data.frame structure(list(Study = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
2013 Jan 24
1
Pairwise Comparrisons
Dear all, I''m trying to write a function, that will take as an argument, some aligned genome sequences, and using a sliding window, do pairwise comparisons of sequence similarity. Coding the sliding window I think I can manage but what I''m trying to get to grips with is getting it so as every pairwise comparison is made, no matter how many genomes are added, from 3 to N. So if
2009 Mar 26
1
loop problem
Dear R members I have a problem regarding storing the lists. Let L=number of distinct values of any predictor (say L=5) P=number of predictors (say P=20) g1 <- c() for(i in 1:P){ if(L > 1){ for(j in 1:(L-1)){ g <- .... g1[j] <- g } } g2[]=sort.list(g1) } Now the question is: What should we use inside brackets of g2[....], whether
2012 Jun 04
1
simulation of modified bartlett's test
Hi, I run this code to get the power of the test for modified bartlett's test..but I'm not really sure that my coding is right.. #normal distribution unequal variance asim<-5000 pv<-rep(NA,asim) for(i in 1:asim) {print(i) set.seed(i) n1<-20 n2<-20 n3<-20 mu<-0 sd1<-sqrt(25) sd2<-sqrt(50) sd3<-sqrt(100) g1<-rnorm(n1,mu,sd1) g2<-rnorm(n2,mu,sd2)
2012 Feb 25
2
Finding name of variable supplied as function argument
Greetings All. I want to do the following simple thing. I have defined a function med3x3() such that, given vectors X,Y, med3x3(X,Y) returns a 3x3 table where: Row 1: X > median(X) Row 2: X = median(X) Row 3: X < median(X) Col 1: Y < median(Y) Col 2: Y = median(Y) Col 3: Y > median(Y) (with intersections of these conditions for the individual cells). I can easily define fixed
2006 Dec 29
1
Genotypes are not all the same
I have been merrily using the genetics package and more specifically have been using the makeGenotypes and genotypes function. I check my accomplishments by going > class(g2) [1] "genotype" "factor" and likewise > class(g1) [1] "genotype" "factor" Yet when I execute a command such as allele count I get this > allele.count(g1) D I [1,]
2020 Oct 06
2
Optimizing assembly generated for tail call
Hello, I recently found that LLVM generates sub-optimal assembly for a tail call optimization case. Below is an example (https://godbolt.org/z/ao15xE): > void g1(); > void g2(); > void f(bool v) { > if (v) { > g1(); > } else { > g2(); > } > } > The assembly generated is as follow: > f(bool): # @f(bool) > testb %dil, %dil > je .LBB0_2 >
2004 Aug 02
2
random seed puzzle
After reading the help page on set.seed, I am unsure about how to solve the following problem. I need to call function f a thousand times. The list of values returned by f, should be as random as possible. f calls g twice: f <- function(){g1 <- g(1); g2 <- g(2); c(g1; g2)} The function g in turn calls sample and returns a number, but also depends on its argument, so, starting from the
2006 Jan 06
1
Problem with integrating ISDN PBX using NT mode
Hi, I'm just in the process of replacing a crappy Siemens PBX with a new and shiny Asterisk system. To connect Legacy equipment I hooked up a small ISDN PBX (DeTeWe OpenCom 36) to one port on a Junghanns.net quadBRI card. That port is configured for NT Point to Multipoint (Mehrgeraeteanschluss) mode. Now I can place calls from the ISDN PBX to the other Asterisk extensions but the other way
2014 Nov 18
2
Change Objects on 2 DCs without connection
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I like to know what will happend if: - - one Domain with 2 DCs - - two Admins working on their Windows-ws with RSAT. - - Admin1 is connected to DC1 - - Admin2 is connected to DC2 - - Admin1 creats a user "u1" and a group "g1" - - then the two DCs will lose connection, the user and group is replicated to DC2 - - now Admin1
2018 May 05
1
error in chol.default((value + t(value))/2) : , the leading minor of order 1 is not positive definite
Dear friends - I'm having troubles with nlme fitting a simplified model as shown below eliciting the error Error in chol.default((value + t(value))/2) : ? the leading minor of order 1 is not positive definite - I have seen the threads on this error but it didn't help me solve the problem. The model runs well in brms and identifies the used parameters even with fixed effects for TRT?