Displaying 20 results from an estimated 6000 matches similar to: "unsplit list of data.frames with one column"
2010 Apr 19
2
Using split and then unsplit
Hello everyone,
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
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.7877109
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
Kane Capital Management
jeff at
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 the indexed input.
x Input has size 15 but subscript `rep(NA, len)` has
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
2020 Nov 21
2
Error in unsplit() with tibbles
I get the sentiment, but this is really just bad coding (on my own part, I suspect), 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()`
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 ''row.names'' are not allowed
In
2010 Mar 24
1
R warning and error messages taking a long time and generating pop-up windows
Hi all, thanks for your help in advance.
I was running some scripts and suddenly R began taking a very long time to process mundane errors, which I often generate since I am new to R...such as forgetting to add in my quote
getOption(warn)
Error in options(x) : object 'warn' not found
Not only does the warning message print in the R console when it finally writes the error, but it also
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 using drop = TRUE. This may
appear as
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
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
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()
2020 Nov 21
0
Error in unsplit() with tibbles
Cool - thank you Peter!
@Marc: This is really not 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)
2002 Jul 28
0
[R] bug in unsplit()? (PR#1845)
Hedderik van Rijn <hedderik@cmu.edu> writes:
> > Thanks for pointing this out. I think your code should work, although
> > I'm slightly uneasy about actually 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
2009 Jun 25
2
stringsAsFactors has no impact in expand.grid()?
Hi
I have the feeling, that the argument stringsAsFactors has no impact in the
function expand.grid:
a <- c("PR", "NC", "A2", "BS")
b <- c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)
class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
[1] "factor"
class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
[1] "factor"
Also, when
2009 Jun 03
1
Need help understanding output from aov and from anova
Hi all,
I noticed something strange when I ran aov and anova.
vtot=c(7.29917, 7.29917, 7.29917) #identical values
fac=as.factor(c(1,1,2)) #group 1 has first two elements, group 2 has
the 3rd element
When I run:
> anova(lm(vtot~fac))
Analysis of Variance Table
Response: vtot
Df Sum Sq Mean Sq F value Pr(>F)
fac 1 1.6818e-30 1.6818e-30 0.3333 0.6667
Residuals 1
2005 May 24
1
Contingency tables from data.frames
Dear list,
I'm trying to do a set of generic functions do make contingency tables from
data.frames. It is just running "nice" (I'm learning R), but I think it can be
better.
I would like to filter the data.frame, i.e, eliminate all not numeric variables.
And I don't know how to make it: please, help me.
Below one of the my functions ('er' is a mention to EasieR,
2003 Oct 09
0
New Department of Biostatistics, Multiple Job Openings
NEW DEPARTMENT OF BIOSTATISTICS
The School of Medicine at Vanderbilt University is pleased to announce
the creation of a new Department of Biostatistics. Vanderbilt has
made a major new funding commitment to build a world-class department.
Chaired by Frank E. Harrell, Jr., the new department has exceptional
institutional support from a medical center that is currently 16th in
U.S. News and
2011 Mar 10
1
getting percentiles by factor
Hello,
I'm trying to get percentiles (PERCENTRANK for excel users) by factor in the
following data.frame:
myExample <- data.frame(Ret=seq(-2, 2.5,
by=0.5),PE=seq(10,19),Sectors=rep(c("Financial","Industrial"),5))
myExample <- na.omit(myExample)
Thanks to Patrick I I managed to put together the following lines which does
it for the "Ret" column:
myecdf
2006 Apr 06
3
convert a data frame to matrix - changed column name
I have a question, which very easy to solve, but I can't find a solution.
I want to convert a data frame to matrix. Here my toy example:
> L3 <- c(1:3)
> L10 <- c(1:6)
> d <- data.frame(cbind(x=c(10,20), y=L10), fac=sample(L3, + 6, repl=TRUE))
> d
x y fac
1 10 1 1
2 20 2 1
3 10 3 1
4 20 4 3
5 10 5 2
6 20 6 2
> is.data.frame(d)
[1] TRUE
> sapply(d,