# search for: sappli

Displaying 20 results from an estimated 762 matches for "sappli".

Did you mean: sapply
2009 Jan 02
7
the first and last observation for each subject
I have the following data ID x y time 1 10 20 0 1 10 30 1 1 10 40 2 2 12 23 0 2 12 25 1 2 12 28 2 2 12 38 3 3 5 10 0 3 5 15 2 ..... x is time invariant, ID is the subject id number, y is changing over time. I want to find out the difference between the first and last observed y value for each subject and get a table like ID x y 1 10 20 2 12 15 3 5 5 ...... Is there any easy way to generate
2018 Mar 13
4
Possible Improvement to sapply
While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function if (!identical(simplify, FALSE) && length(answer)) This seems superfluous to me, in particular this part: !identical(simplify, FALSE) The preceding
2018 Mar 13
2
Possible Improvement to sapply
Martin In terms of context of the actual problem, sapply is called millions of times because the work involves scoring individual students who took a test. A score for student A is generated and then student B and such and there are millions of students. The psychometric process of scoring students is complex and our code makes use of sapply many times for each student. The toy example used
2011 Dec 27
2
sapply Call Returning " the condition has length > 1" Error
Dear all, Happy new year! I have a question re using sapply. Below is a dummy example that would replicate the error I saw.  ##Code Starts here DummyFunc <- function(x) { if (x > 0) { return (x) } else { return (-x) } } Y = data.frame(val = c(-3:7)) sapply(Y, FUN = DummyFunc) ##Code ends here When I run it, I got:      val  [1,]   3  [2,]   2  [3,]   1  [4,]   0  [5,]  -1  [6,]  -2
2010 Jun 17
3
how to use sapply code
Hi, I have this code here and try to use sapply code.  But I got error message that I don't really understand to correct. bt   <- c(24.96874, 19.67861, 23.51001, 19.86868); round(bt,2) alp  <- c(2.724234, 3.914649, 3.229146, 3.120719); round(alp,2) bt_alp <- data.frame(bt,alp) sapply(bt_alp, function(bt,alp) ((bt_m/bt)^alp), bt_m = min(bt)) > sapply(bt_alp,
2018 Mar 13
0
Possible Improvement to sapply
Wouldn't that change how simplify='array' is handled? > str(sapply(1:3, function(x)diag(x,5,2), simplify="array")) int [1:5, 1:2, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,5,2), simplify=TRUE)) int [1:10, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,5,2), simplify=FALSE)) List of 3 \$ : int [1:5, 1:2] 1 0 0 0 0 0 1 0 0
2010 Jun 13
2
Scope and sapply
I am puzzled by the scope rules that apply with sapply. If I want to modify a vector with sapply I tried... N <- 10 vec <- vector(mode="numeric", length=N) test <- function(i){ vec[i] <- i } sapply(1:N, test) vec but it not work. How can this be done? Worik [[alternative HTML version deleted]]
2018 Mar 13
0
Possible Improvement to sapply
On 03/13/2018 09:23 AM, Doran, Harold wrote: > While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function > > if (!identical(simplify, FALSE) && length(answer)) > > This seems superfluous
2011 Jul 05
2
Stuck ...can't get sapply and xmlTreeParse working
Can't seem to get the code below working. It gets stuck on line 24 inside the function hm; comments show the line in question. The function hm is called by sapply and is at the bottom of the code. Other stuff above line 24 works correctly including the first couple of lines of the function hm. Should I be using a different apply function or am I doing something wrong with xmlTreeParse ?
2018 Mar 13
1
Possible Improvement to sapply
You?re right, it sure does. My suggestion causes it to fail when simplify = ?array? From: William Dunlap [mailto:wdunlap at tibco.com] Sent: Tuesday, March 13, 2018 12:11 PM To: Doran, Harold <HDoran at air.org> Cc: r-help at r-project.org Subject: Re: [R] Possible Improvement to sapply Wouldn't that change how simplify='array' is handled? > str(sapply(1:3,
2018 Mar 13
0
Possible Improvement to sapply
Quite possibly, and I?ll look into that. Aside from the work I was doing, however, I wonder if there is a way such that sapply could avoid the overhead of having to call the identical function to determine the conditional path. From: William Dunlap [mailto:wdunlap at tibco.com] Sent: Tuesday, March 13, 2018 12:14 PM To: Doran, Harold <HDoran at air.org> Cc: Martin Morgan <martin.morgan
2012 Aug 02
1
sapply and matrix command
HI, You can also try this: d<-1:25 A<-sample(combn(20:30,2)) B<-sample(combn(20:30,2)) lapply(d,function(x) matrix(c(1,A[x],B[x],1),2,2)) [[1]] [,1] [,2] [1,] 1 23 [2,] 27 1 [[2]] [,1] [,2] [1,] 1 21 [2,] 21 1 [[3]] [,1] [,2] [1,] 1 29 [2,] 23 1 [[4]] [,1] [,2] [1,] 1 25 [2,] 20 1 [[5]] [,1] [,2] [1,] 1 23 [2,]
2018 Mar 13
1
Possible Improvement to sapply
Could your code use vapply instead of sapply? vapply forces you to declare the type and dimensions of FUN's output and stops if any call to FUN does not match the declaration. It can use much less memory and time than sapply because it fills in the output array as it goes instead of calling lapply() and seeing how it could be simplified. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue,
2016 Apr 08
2
identical() versus sapply()
Sorry if this has been answered elsewhere, but I can't find any discussion of it. Wondering why the following situation occurs (duplicated on 3.2.2 CentOS6 and 3.0.1 Win2k, so I don't think it is a bug): > sapply(1, identical, 1) [1] TRUE > sapply(1:2, identical, 1) [1] FALSE FALSE > sapply(1:2, function(i) identical(as.numeric(i),1) ) [1] TRUE FALSE > sapply(1:2,
2010 Feb 13
1
Using getSYMBOL, annotate package on a list with empty elements.
Hi, I have been trying to find a solution to this issue, but have not been able to so ! I am trying to use sapply on the function getSYMBOL, an extract from the list is: > test.goP[13:14] \$`GO:0000050` IEA IEA IEA IEA TAS TAS TAS IEA "5270753" "5720725" "1690128" "4850681" "110433" "2640544"
2018 Mar 13
2
Possible Improvement to sapply
FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut some corners compared to identical(): > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) Unit: nanoseconds expr min lq mean median uq max neval identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584 100 isFALSE(FALSE) 713 761 1133.53 809.5 871.5
2005 Apr 21
2
apply vs sapply vs loop - lm() call appl(y)ied on array
Christoph -- There was just a thread on this earlier this week. You can search in the archives for the title: "refitting lm() with same x, different y". (Actually, it doesn't turn up in the R site search yet, at least for me. But if you just go to the archive of recent messages, available through CRAN, you can search on refitting and find it. The original post was from William
2016 Apr 12
6
[FORGED] Re: identical() versus sapply()
Hi Jeff, We are splitting hairs because R is splitting hairs, and causing us problems. Integer and numeric are different R classes with different properties, mathematical relationships notwithstanding. For instance, the counterintuitive result: > identical(as.integer(1), as.numeric(1)) [1] FALSE Unfortunately the reply-to chain doesn't extend far enough -- here is the original
2018 Mar 14
0
Possible Improvement to sapply
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Tue, 13 Mar 2018 10:12:55 -0700 writes: > FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut > some corners compared to identical(): > > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) > Unit: nanoseconds > expr
2017 Oct 24
2
as.data.frame doesn't set col.names
You left out all the most important bits of information. What is yo? Are you trying to assign a data frame to a single column in another data frame? Printing head(samples) tells us nothing about what data types you have, especially if the things that look like text are really factors that were created when you used one of the read.*() functions. Use str(samples) to see what you are dealing with.