Displaying 4 results from an estimated 4 matches for "nameslong".
2023 Apr 03
4
Simple Stacking of Two Columns
...R-Helpers,
Sorry to bother you, but I have a simple task that I can't figure out how to do.
For example, I have some names in two columns
NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
and I simply want to get a single column
NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
> NamesLong
Names
1 Tom
2 Dick
3 Larry
4 Curly
Stack produces an error
NamesLong<-stack(NamesWide$Name1,NamesWide$Names2)
Error in if (drop) { : argument is of length zero
So does bind_rows
&...
2023 Apr 04
1
Simple Stacking of Two Columns
Just to repeat:
you have
NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
and you want
NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
There must be something I am missing, because
NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2))
appears to do the job in the simplest possible manner. There are all sorts
of al...
2023 Apr 03
1
Simple Stacking of Two Columns
...but I have a simple task that I can't figure out how to do.
>
> For example, I have some names in two columns
>
> NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
>
> and I simply want to get a single column
> NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
> > NamesLong
> Names
> 1 Tom
> 2 Dick
> 3 Larry
> 4 Curly
>
>
> Stack produces an error
> NamesLong<-stack(NamesWide$Name1,NamesWide$Names2)
> Error in if (drop) { :...
2023 Apr 04
1
Simple Stacking of Two Columns
...39 PM
To: r-help at r-project.org
Subject: Re: [R] Simple Stacking of Two Columns
Jeff Newmiller wrote/hat geschrieben on/am 03.04.2023 18:26:
> unname(unlist(NamesWide))
Why not:
NamesWide <- data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
NamesLong <- data.frame(Names=with(NamesWide, c(Name1, Name2)))
>
> On April 3, 2023 8:08:59 AM PDT, "Sparks, John" <jspark4 at uic.edu> wrote:
>> Hi R-Helpers,
>>
>> Sorry to bother you, but I have a simple task that I can't figure out how
to do.
>>
>...