search for: unsplit

Displaying 20 results from an estimated 84 matches for "unsplit".

Did you mean: nsplit
2009 Nov 25
0
Possible bug in "unsplit" (PR#14084)
Dear R-bug-people I have encountered a problem with "unsplit", which I believe may be caused by a bug in the function. However, unexpericend with bug-reports I apologise if this is barely a user problem rather than a problem within R. The problem occurs if an object is split by several grouping factors with levels not occuring in the data, and usin...
2005 Sep 27
2
Using unsplit - unsplit does not seem to reverse the effect of split
In data OME in MASS I would like to extract the first 5 observations per subject (=ID). So I do library(MASS) OMEsub <- split(OME, OME$ID) OMEsub <- lapply(OMEsub,function(x)x[1:5,]) unsplit(OMEsub, OME$ID) - which results in [[1]] [1] 1 1 1 1 1 [[2]] [1] 30 30 30 30 30 [[3]] [1] low low low low low Levels: N/A high low [[4]] [1] 35 35 40 40 45 [[5]] [1] coherent incoherent coherent incoherent coherent Levels: coherent incoherent [[6]] [1] 1 4 0 1 2 ............ [[1094]] [...
2020 Nov 21
3
Error in unsplit() with tibbles
Hello, using the `unsplit()` function with tibbles currently leads to the following error: > mtcars_tb <- as_tibble(mtcars, rownames = NULL) > s <- split(mtcars_tb, mtcars_tb$gear) > unsplit(s, mtcars_tb$gear) Error: Must subset rows with a valid subscript vector. ? Logical subscripts must match the size of...
2010 Apr 19
2
Using split and then unsplit
...I use the split function splitting with the f function on a 3 columns and more than 100 000 rows data frame. Once it's split I have a list of data frames still with 3 columns and n rows. I manipulate those list elements and get a list of data frames still with 3 columns but less rows. So when I unsplit it, I get an error as I use the same factor function I used to split ( f in the help split page) I guess because the number of rows changed. Do I need to create a new f function to be able to unsplit or is there another way to unsplit those data frames and rbind them? Thank you! ----- Anna Lippel...
2006 Jun 08
1
NAs in unsplit factor
R-devel, Below is a simple example calling split and unsplit on a numeric vector of length 2 where 'f' is c(1,NA). > unsplit(split(c(1,2), c(1,NA)), c(1,NA)) [1] 1 0 I noticed that the call to vector in unsplit gives us 0 as the 2nd element of the result. Is this the intended result, as opposed to NA? Thanks for your help, Jeff -- Jeff Enos...
2002 Jul 28
1
[R] bug in unsplit()? (PR#1843)
Hedderik van Rijn <hedderik@cmu.edu> writes: > If the second argument to unsplit is not a simple vector (but a "list > containing multiple lists"), the function seems to have some problems. > > Given a slight modification of the examples in help(split): > > > xg <- split(x,list(g1=g,g2=g)) > > unsplit(xg,list(g1=g,g2=g)) > [1] -0.787710...
2020 Nov 21
2
Error in unsplit() with tibbles
..., so we might as well just fix it... -pd > On 21 Nov 2020, at 17:42 , Marc Schwartz via R-devel <r-devel at r-project.org> wrote: > > >> On Nov 21, 2020, at 10:55 AM, Mario Annau <mario.annau at gmail.com> wrote: >> >> Hello, >> >> using the `unsplit()` function with tibbles currently leads to the >> following error: >> >>> mtcars_tb <- as_tibble(mtcars, rownames = NULL) >>> s <- split(mtcars_tb, mtcars_tb$gear) >>> unsplit(s, mtcars_tb$gear) >> Error: Must subset rows with a valid subscript v...
2020 Nov 21
0
Error in unsplit() with tibbles
> On Nov 21, 2020, at 10:55 AM, Mario Annau <mario.annau at gmail.com> wrote: > > Hello, > > using the `unsplit()` function with tibbles currently leads to the > following error: > >> mtcars_tb <- as_tibble(mtcars, rownames = NULL) >> s <- split(mtcars_tb, mtcars_tb$gear) >> unsplit(s, mtcars_tb$gear) > Error: Must subset rows with a valid subscript vector. > ? Logical su...
2024 Oct 06
0
Coda: On the efficiency of unsplit() for Rolf Turner's recent post
(only of interest -- maybe! -- to those who followed this thread of a couple of weeks ago) Just for the heckuva it, I compared the timing of Deepayan's unsplit(x,f) solution to my as.vector(do.call(rbind, x)) approach to the query for a list of 3 vectors each of length 1000 (the original toy example was for a list of 3 vectors of length 5). Unsurprisingly, I think, because the unsplit() approach works for the general case whereas the do.call(rbind) only w...
2009 May 08
1
unsplit list of data.frames with one column
Perhaps this is the intended behavior, but I discovered that unsplit throws an error when it tries to set rownames of a variable that has no dimension. This occurs when unsplit is passed a list of data.frames that have only a single column. An example: df <- data.frame(letters[seq(25)]) fac <- rep(seq(5), 5) unsplit(split(df, fac), fac) For reference, I...
2020 Nov 21
0
Error in unsplit() with tibbles
...t a tidyverse vs base-R debate and I personally think that they should both work together for most parts. The common environment is still R. But just to give you the full picture I also filed a bug for tibbles (https://github.com/tidyverse/tibble/issues/829). With these two fixes I think that split/unsplit would work for tibbles and users (like me) just don't have to care in which "environments" they are working in. Cheers, Mario On Sat, 21 Nov 2020 at 17:54, Peter Dalgaard <pdalgd at gmail.com> wrote: > I get the sentiment, but this is really just bad coding (on my own par...
2011 May 19
1
Problems with unsplit()
Hi everyone, I have already used split() and unsplit() in data frames without problems, but now I’m applying these functions to other data and when using unsplit() I have received the following message: Error in `row.names<-.data.frame`(`*tmp*`, value = c("1", "2", "3", "4", : duplicate ''ro...
2002 Jul 28
0
[R] bug in unsplit()? (PR#1845)
...ly modifying f, so how about > > Just curious, why are you uneasy about that? Does it have side effects? It is largely due superstition, but if you change f before calling split<-() you have split() and split<-() called with different f's even if the same f is used for split() and unsplit(). That can be quite OK, but there's a marginal risk that it causes an inconsistency somewhere so that the split and unsplit aren't exact inverses. > > len <- length(if (is.list(f)) f[[1]] else f) > > The reason I used the interaction() call is that this seems to wo...
2005 Jun 25
1
group means: split and unsplit
Took me a while but I figured out how to put in common values of group means/counts, etc. to do the same thing as egen. lapply with split and then unsplit. Thomas Davidoff Assistant Professor Haas School of Business UC Berkeley Berkeley, CA 94720 phone: (510) 643-1425 fax: (510) 643-7357 davidoff@haas.berkeley.edu http://faculty.haas.berkeley.edu/davidoff [[alternative HTML version deleted]]
2011 Mar 10
1
getting percentiles by factor
...; column: myecdf <- function(x, sortAsc) { w1 <- ecdf(x$Ret) w2 <- if (sortAsc) w1(x$Ret) * 100 else abs(w1(x$Ret) * 100 - 100) w3 <- transform(x, myPerc=w2) return(w3) } myExampleEnd <- lapply(split(myExample, myExample$Sectors), myecdf, sortAsc="True") myExampleEnd <- unsplit(myExampleEnd, myExample$Sectors) I need to make the function more flexible accepting the name of the column to calculate percentiles on as a parameter but the following doesn't work: myecdf2 <- function(x, column, sortAsc=True) { # x data.frame/list being analysed # column to calculate pe...
2010 Apr 13
2
efficiently picking one row from a data frame per unique key
...tly IO bound and never finishes with a data set ~6MB Here's how I'm currently trying to do this d = data.frame(x=c(1,1,2,4),y=c(10,11,12,13),z=c(20,19,18,17)) d.ordered = d[order(-d$y),] aggregate(d.ordered,by=list(key=d.ordered$x),FUN=function(x){x[1]}) I've tried to use split and unsplit, but unsplit complained about duplicate row names when reassembling the sub frames. thanks for your suggestions -james [[alternative HTML version deleted]]
2024 Sep 27
1
Is there a sexy way ...?
...uot;, "2", "3". Almost all solution were simply assuming that the toy example `f` was the real `f`, but that's not realistic. Consequently, in my view, the only valid proposition and a very nice one, indeed, was Deepayan's (well, he's "R core", ...) unsplit(x, f) Martin > On 27/09/2024 11:13, Duncan Murdoch wrote: >> On 2024-09-26 11:55 p.m., Rolf Turner wrote: >>> >>> I have (toy example): >>> >>> x <- list(`1` = c(7, 13, 1, 4, 10), >>> ?????????? `2` = c(2, 5,?...
2009 Nov 19
2
Efficient cbind of elements from two lists
Hi! I have a data.frame "data" and splitted it. data <- split(data, data[,1]) This is a quite slow procedure; and I do not want to do it again. So, any unsplit and "resplit" is no option for me. But: I have to cbind "variables" to the splitted data from another list, that contains of vectors with matching sizes, so for (i in 1:length(data)) { data[[i]] <- cbind(data[[i]], l[[i]])) } works well; but very, very slowly. The lappl...
2010 Aug 20
2
Problem with POSIXct in ave
Hi, I am having trouble using the ave function with a POSIXct object. For example: x<-Sys.time()+0:9*3600 dat<-data.frame(id=rep(c('a',' b','c'),each=10),dt=rep(x,3),i=rep(1:10,3)) dat # This is what I want to do: dat$time.elapsed<-unsplit(lapply(split(dat$dt,dat$id),function(x) x-x[1]),f=dat$id) dat # The above code does the trick, but from the standpoint of simplicity, the ave function seems to be perfect for this problem: ave(dat$dt,dat$id,FUN=function(x) difftime(x,x[1])) # Above doesn't work, returns: Error in as.POSIXct.de...
2015 Jun 18
2
[LLVMdev] New EH representation for MSVC compatibility
On Wed, Jun 17, 2015 at 6:18 PM, Philip Reames <listmail at philipreames.com> wrote: > Since I haven't been following the thread closely, is there an updated > summary of the original proposal available? I know that various parts I > had concerns with (the unsplitable blocks for instance) got addressed, but > I'm having trouble tracking all the changes in discussion. Even just a > quick list of "and we changed X" would be helpful. > We should do an updated summary, but I've been busy. We really do need to keep the unsplittable c...