similar to: function and apply

Displaying 20 results from an estimated 10000 matches similar to: "function and apply"

2012 Feb 13
3
Change dataframe-structure
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120213/d2a5afa6/attachment.pl>
2005 Jul 20
2
Turning off return warning messages.
Dear All, Is there a way I can turn off the following warning message for using multi-argument returns? multi-argument returns are deprecated in: return(p1, p2, p3, p4) Steve. ************************************************************************************** Steve Su (s.su@qut.edu.au) Postdoctoral fellow Faculty of Business Queensland University of Technology Postal
2011 Feb 02
2
Help with one of "those" apply functions
Hello there, I'm still struggling with the *apply commands. I have 5 people with id's from 10 to 14. I have varying amounts (nrep) of repeated outcome (value) measured on them. nrep <- 1:5 id <- rep(c("p1", "p2", "p3", "p4", "p5"), nrep) value <- rnorm(length(id)) I want to create a new vector that contains the sum of the
2006 Mar 15
2
Regarding aov Error()
The following dummy data frame has factor Q (with 2 levels) nesting factor P (with levels p1 and p2 nested under q1, and p3 and p4 nested under q2), but both crossing the random variate s, which has 8 levels. The dependent measure is dv. > # The data frame: > testnest dv s P Q 1 1 s1 p1 q1 2 2 s2 p1 q1 3 1 s3 p1 q1 4 2 s4 p1 q1 5 1 s5 p1 q1 6 3 s6 p1 q1 7 3 s7
2011 Dec 26
2
Recoding multiple TRUE/FALSE columns into a single list of TRUE columns
Hi everyone, I need to recode multiple columns in a dataframe into a single column in a variety of different ways. Often the values will be TRUE/FALSE and I want a list of the columns that are true as in the Result column below: P1 P2 P3 P4 Result 1 0 0 1 1 P3,P4 2 0 1 1 1 P2,P3,P4 3 1 0 0 0 P1 4 0 0 0 0 NA 5 1 1 1
2006 Jul 14
1
Optim()
Dear all, I have two functions (f1, f2) and 4 unknown parameters (p1, p2, p3, p4). Both f1 and f2 are functions of p1, p2, and p3, denoted by f1(p1, p2, p3) and f2(p1,p2,p3) respectively. The goal is to maximize f1(p1, p2, p3) subject to two constraints: (1) c = k1*p4/(k1*p4+(1-k1)*f1(p1,p2,p3)), where c and k1 are some known constants (2) p4 = f2(p1, p2, p3) In addition, each parameter
2011 Jan 10
2
Calculating Portfolio Standard deviation
Dear R helpers I have following data stocks <- c("ABC", "DEF", "GHI", "JKL") prices_df <- data.frame(ABC = c(17,24,15,22,16,22,17,22,15,19),                                          DEF = c(22,28,20,20,28,26,29,18,24,21),                                           GHI = c(32,27,32,36,37,37,34,23,25,32),                                          
2016 Apr 19
2
Creating two new variables conditional on retaining values from previous rows
Hello, Iam looking for an R solution that can efficiently produce the output shown below. I can produce this easily in SAS with retain statement and a few lines of if-then-else logic, etc.. but I am not find anything similar on the Rforum archives. Below is the logic I am trying to apply to produce the output table below. Thanks in any help! if the ID is the first ID encountered then group=1 and
2003 Jun 19
2
Subseting by more than one factor...
Is it possible in R to subset a dataframe by more than one factor, all at once? For instance, I have the dataframe: >data p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 pred 1 0 1 0 0 0 0 0 0 0 0 0.5862069 4 0 0 0 0 0 0 0 0 0 1 0.5862069 5 0 0 0 0 0 0 1 0 0 0 0.5862069 6 0 0 0 0 0 0 0 1 0 0 0.5862069 7 0 0 1 0 0 0 0 0 0
2018 Mar 18
1
How to take difference of sets when there is an empty subset involved
Hello, Problem I am facing is as follows: Set A is made of 2 sets x and y x<-{"P1", "P2", "P3", "P4"} y<-{} A<-set(x,y) #A={{}, {"P1", "P2", "P3", "P4"}} i need to use A in a recursive loop where i need to take set difference of A and it 's elements. Example: for (i in A){ print(i)
2018 Mar 18
1
Set Difference Problem
Hello All, I am facing a problem and am unable to find much help online as sets package in R is relatively new. My problem is as follows: Set R is made of 2 sets x and y x<-{"P1", "P2", "P3", "P4"} y<-{} R<-set(x,y) #R={{}, {"P1", "P2", "P3", "P4"}} i need to use R in a recursive loop where i need to take
2008 Feb 04
2
make dataframe from table
Dear R-experts, I have got a dataframe: data ID disease V1 V2 1 p1 1 2 p1 3 3 p3 3 4 p3 5 5 p5 1 From which I extract a usefull table: affect affect 1 3 5 p1 1 1 0 p3 0 1 1 p5 1 0 0 I want to merge this with anotherdataframe: age p1 23 p2 24 p3 23 p4 11 p5 45 If have tried as.data.frame(affect) and other solutions to get the following comment going:
2011 Dec 19
1
calculating correlation coefficients on repeated measures
Dear list, I have 9 repeated measures (measurement variable == 'Delta13C') for individuals (ID variable == 'Individual_ID'. Each repeated measure is "indexed" (right term?) by the variable 'FeatherPosition' and given as c('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9'). I would like to
2011 Aug 24
1
Passing a large amount of parameters to a function
Hello, I have a function with a long list of parameters (of different types, numeric and string) myFunc <-function(p1, p2, p3, p4, p5...etc) { do.something(p1,p2,....) } I want to loop over this to provide a different set of parameters to the list every time. for (ii in 1:N) { myFunc(p1(ii), p2(ii),....etc) } I would like to simplify the notation and use some kind of structure, maybe
2018 Mar 20
2
Elements of Sets as dataframe column names
Hello all, I have a set B and a dataframe df. I want to name the columns of the dataframe after the elements of the set B. For example, for set B with elements {{"P1"}, {"P2"}, {"P3", "P4"}} I want to create a new dataframe with 3 columns named {"P1"} and {"P2"} and {"P3","P4"}. I tried colnames(df)<-(B). But it
2010 Jul 23
1
(no subject)
Dear R list, I use the constrOptim to maximize a function with four constriants but the answer does not leave from the starting value and there is only one outer iteration. The function is defined as follows: tm<-function(p){ p1<-p[1]; p2<-p[2]; p3<-p[3]; p4<-1-p1-p2-p3; p1*p2*p3*p4} ##the constraints are p1>=0; p2>=0; p3>=0 and p4>=0 i.e. p1+p2+p3<=1
2010 Sep 25
1
margin control in lattice package
Hi all, I am difficulty with simple layout of plots in the lattice package I have created a series of levelplots and would like to plot them to a single device, but need to reduce the margin areas. This is easily accomplished with par(oma) and par(mar) in the base graphics package but I am having problems finding the equivalent features in the lattice package. Ideally, I would like to reduce
2012 Sep 26
3
replace string values with numbers
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3. Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does any know if there is anything wrong with my code? Thanks, Zhengyu
2000 Jan 06
1
nlme
Among others, datam contains the columns: logconc, tm, dose, subj, bilirubin. None of these are factor variables. The following compartment models work (the first still has not converged after 100 interations): res1 <- nlme(logconc~p2+p3+log(dose/(exp(p1)-exp(p2))* (exp(-exp(p2)*tm)-exp(-exp(p1)*tm))),start=list(fixed=c(5,-2,-0.1)), fixed=list(p1+p2+p3~1),control=list(maxIter=100),
2024 Jan 29
1
linear programming in R | limits to what it can do, or my mistake?
Question for 'experts' in LP using R (using the lpSolve package, say) -- which does not apply to me for the sort of problem I describe below. I've run any number of LP's using lpSolve in R, but all of them to date have objective and constraint functions that both contain the same variables. This lets you set up a LHS and RHS matrix/vector that are symmetrical. But, for a