Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
Sent: Thursday, June 4, 2015 8:58 AM
To: javascriptart25
Cc: r-help@r-project.org
Subject: Re: [R] reshape a data frame
Yes. This is basic stuff, and it seems unnecessary to run to packages for
it, Knowledge of base R should suffice. It would appear that the OP would
benefit by going through an R tutorial or two.
Slightly more economical and more general -- and trickier -- than explicit
concatenation, which could g
You can change ex <- data.frame("gIN" = gIN, "bc1" = bc1, "bc2"=bc2,
"group" = group)
to
ex <- data.frame("gIN" = c(gIN,gIN), "bcX" = c(bc1,bc2), "group" =
c(group,group))
On Wed, Jun 3, 2015 at 2:27 PM, hedelhusk [via R] <
ml-node+s789695n4708145...@n4.nabble.com> wrote:
> Hello,
>
> I would
I found the gather function from the tidyr package, which worked nicely:
gather(ex,bcX,value, bc1:bc2)
gIN group bcX value
1 A_1 A bc1 1219.79
2 A_2 A bc1 1486.84
3 A_3 A bc1 1255.80
4 A_4 A bc1 941.87
5 B_1 B bc1 588.19
6 B_2 B bc1
...@gmail.com
> Sent: Wed, 3 Jun 2015 18:25:02 -0400
> To: r-help@r-project.org
> Subject: Re: [R] reshape a data frame
>
> I found the gather function from the tidyr package, which worked nicely:
>
> gather(ex,bcX,value, bc1:bc2)
>gIN group bcX value
> 1 A_1
Hello,
I would like to ask for some advice in reformatting a data frame such as
the following one:
gIN <- c("A_1","A_2","A_3","A_4","B_1","B_2")
bc1 <- c(1219.79, 1486.84, 1255.80, 941.87, 588.19, 304.02)
bc2 <- c(319.79, 186.84, 125.80, 94.87, 1008.19, 314.02)
group <- c("A","A","A","A","B","B"
6 matches
Mail list logo