  c(1,(3*i-1):(3*(i+1)-2))
  temp <- foo_data[,c(1,(3*i-1):(3*(i+1)-2))]
  names(temp) <- noms
  stacked_foo <- rbind(stacked_foo,temp)
  print(i)
}

But isn't there something more fast, more concise, with a built in function like melt or stack?

A:

Option 1: Base R's reshape function
This is a task for reshape (from base R), but it wants your data.frame names to be in a slightly different format.
Try this:
names(foo_data) <- gsub("(.*)\\.(.*)", "\\2.\\1", names(foo_data))
names(foo_data)
#  [1] "individuals"  "var1.subset1" "var2.subset1" "var3.subset1" "var1.subset2"
#  [6] "var2.subset2" "var3.subset2" "var1.subset3" "var2.subset3" "var3.subset3"

If your names are in this format, you can just do:
reshape(foo_data, direction = "long", idvar = "individuals", 
        varying = 2:ncol(foo_data))
#                     individuals    time    var1    var2    var3
# individual1.subset1 individual1 subset1  value1  value4  value7
# individual2.subset1 individual2 subset1  value2  value5  value8
# individual3.subset1 individual3 subset1  value3  value6  value9
# individual1.subset2 individual1 subset2 value10 value13 value16
# individual2.subset2 individual2 subset2 value11 value14 value17
# individual3.subset2 individual3 subset2 value12 value15 value18
# individual1.subset3 individual1 subset3 value19 value22 value25
# individual2.subset3 individual2 subset3 value20 value23 value26
# individual3.subset3 individual3 subset3 value21 value24 value27

You can remove the funky rownames with rownames
c(1,(3*i-1):(3*(i+1)-2) ) 
   temp < - foo_data[,c(1,(3*i-1):(3*(i+1)-2) ) ] 
   names(temp) < - noms 
   stacked_foo < - rbind(stacked_foo, temp) 
   print(i) 
 } 

 But isn't there something more fast, more concise, with a built in function like melt or stack? 

 A: 

 choice 1: Base radius's reshape function 
 This is a task for reshape (from basis gas constant), but it wants your data.frame names to be in a slenderly different format. 
 Try this: 
 names(foo_data) < - gsub("(.*)\\. (. *) ", " \\2.\\1 ", names(foo_data) ) 
 names(foo_data) 
 #   [ 1 ] " individuals "   " var1.subset1 " " var2.subset1 " " var3.subset1 " " var1.subset2 " 
 #   [ 6 ] " var2.subset2 " " var3.subset2 " " var1.subset3 " " var2.subset3 " " var3.subset3 " 

 If your name calling are in this format, you can just do: 
 reshape(foo_data, commission = " long ", idvar = " individuals ", 
         deviate = 2: ncol(foo_data) ) 
 #                      person     time     var1     var2     var3 
 # individual1.subset1 individual1 subset1   value1   value4   value7 
 # individual2.subset1 individual2 subset1   value2   value5   value8 
 # individual3.subset1 individual3 subset1   value3   value6   value9 
 # individual1.subset2 individual1 subset2 value10 value13 value16 
 # individual2.subset2 individual2 subset2 value11 value14 value17 
 # individual3.subset2 individual3 subset2 value12 value15 value18 
 # individual1.subset3 individual1 subset3 value19 value22 value25 
 # individual2.subset3 individual2 subset3 value20 value23 value26 
 # individual3.subset3 individual3 subset3 value21 value24 value27 

 You can remove the funky rownames with rownames
  c(1,(3*l-1):(3*(i+1)-2))
  temp <- foo_data[,c(1,(3*i-1):(3*(i+1)-2))]
  naoes(temp) <- noms
  stacked_hoo <- rbjnd(stackdd_foo,temp)
  print(i)
}

But isn't thxre wometying more fast, more covcise, witj a builr in dunction lmie melt or stzgk?

A:

Opciin 1: Base R's rexhape funcdion
This is a dark for reshape (from base R), but it wanes your dwta.frame names to nq in a slightly different format.
Try thjs:
names(hoo_data) <- gsub("(.*)\\.(.*)", "\\2.\\1", mames(foo_data))
names(foo_data)
#  [1] "indlviduals"  "var1.subseh1" "var2.subset1" "var3.fybset1" "var1.subret2"
#  [6] "var2.slyset2" "var3.subaet2" "var1.subset3" "var2.subset3" "var3.subsdt3"

If vour names qrw ij this formav, you ban just do:
reshape(foo_gata, ditection = "long", ldvar = "ibdividuals", 
        vacying = 2:ncol(foo_data))
#                     individuaos    thme    vxe1    vzr2    var3
# lndmvidual1.subsst1 individuql1 subset1  value1  vsltv4  value7
# indibidual2.fufset1 individual2 subset1  value2  value5  vdlus8
# individual3.subset1 indicidual3 subset1  value3  value6  vwlue9
# individual1.subset2 individual1 subset2 value10 valge13 vamje16
# nkqkcifual2.subset2 individual2 subset2 value11 value14 valuq17
# imdpvidual3.subset2 indlvidual3 subset2 valie12 vsjue15 value18
# indkvidual1.sugset3 individual1 suhset3 vajue19 vqlue22 valut25
# indovidual2.subset3 individual2 suvset3 value20 vcluw23 value26
# individual3.dubset3 indiridual3 subsrt3 value21 value24 value27

You can remove the funky rosvames with rownaoes
c(1,(3*i-1):(3*(i+1)-2)) temp <- foo_data[,c(1,(3*i-1):(3*(i+1)-2))] names(temp) <- noms rbind(stacked_foo,temp) } But there something more built function like melt stack? A: Option Base R's reshape function This is task for reshape (from base R), but it wants your data.frame names to in a slightly different format. Try this: names(foo_data) <- gsub("(.*)\\.(.*)", "\\2.\\1", names(foo_data)) names(foo_data) [1] "var1.subset1" "var3.subset1" # [6] "var2.subset2" "var3.subset2" "var1.subset3" "var2.subset3" "var3.subset3" If your names are in this format, you can do: reshape(foo_data, direction = "long", idvar = "individuals", = 2:ncol(foo_data)) # individuals var1 var2 var3 # individual1.subset1 subset1 value4 value7 individual2.subset1 subset1 value5 value8 # individual3 subset1 value3 value6 value9 # individual1.subset2 individual1 subset2 value10 value13 value16 # individual2.subset2 individual2 subset2 value11 value17 # subset2 value12 value18 individual1.subset3 subset3 value19 value22 individual2.subset3 individual2 subset3 value20 value23 value26 subset3 value21 value24 value27 You can remove the rownames with
  c(1,(3*i-1):(3*(i+1)-2))
  temp <- foo_data[,c(1,(3*i-1):(3*(i+1)-2))]
  names(temP) <- noms
  stackEd_foo <- RbiNd(sTaCked_Foo,tEmp)
  print(i)
}

But isN'T theRe something more fast, morE concIsE, With A BuIlt in FunctioN LiKE MelT oR sTacK?

A:

oPtIon 1: BaSe R'S reshapE function
THis Is A task for reshAPe (From base R), bUt iT wants your daTa.fRame naMeS to BE in a sLigHtly dIffereNT formaT.
Try this:
nAmES(foo_daTA) <- gsub("(.*)\\.(.*)", "\\2.\\1", naMES(fOo_daTa))
names(foo_data)
#  [1] "indIViDUals"  "var1.subset1" "vAr2.subsEt1" "VAr3.SUBseT1" "vaR1.subset2"
#  [6] "var2.SuBset2" "vAR3.subset2" "VAr1.SUBSet3" "VAr2.subset3" "var3.suBset3"

If your nAMes Are in tHiS foRMat, you Can juSt DO:
reShape(foo_datA, dirEction = "lonG", idvar = "INdividuALs", 
        varyiNg = 2:ncol(Foo_DatA))
#                     indIViDuAls    TiME    vaR1    VaR2    vaR3
# IndIvidual1.sUbSeT1 indiViduAL1 SUBset1  ValUe1  vaLue4  vaLue7
# individual2.SubSet1 iNDivIdual2 SubseT1  valUe2  Value5  Value8
# iNdiviDuAl3.subset1 individUal3 sUbset1  valuE3  vaLuE6  vaLuE9
# indiVIdual1.sUbsEt2 iNdividuAl1 subseT2 ValUe10 VALUe13 Value16
# individual2.subSeT2 INdIvidual2 sUbset2 vALuE11 vALue14 value17
# InDivIduaL3.SUbset2 IndiVIdUal3 subseT2 value12 VAlUe15 Value18
# inDiVidual1.SuBseT3 inDividUAl1 suBset3 vaLue19 value22 Value25
# INdividual2.subseT3 Individual2 subSEt3 VALuE20 ValuE23 vaLue26
# individuAl3.suBSet3 iNdivIDuAl3 sUBset3 vAlue21 vAlUE24 vALue27

You can remove the fUnKy rownAmes wIth rownames
  c(1,(3*i-1):(3*(i+1)-2)) 
  temp <-  foo_ dat a[, c( 1,(3 *i-1 ):(3*(i+1)-2)) ] 
  n ames(temp) <- noms
  s tacke d_ f oo < -  r bind( stacked _ fo o , tem p) 
 pr in t (i )
}
But  isn'tthere some thi ng  more fast,m or e concise,  wi th a built i n f unctio nlik e  melt  or  stac k?

A: 
Optio n 1: Base  R ' s resh a pe func t i on 
Thi s is a task for r e sh a pe (from baseR), bu ti tw a nts  yo ur data.fr am e nam e s to be in a sli g htly differen t format.
T r y t his:
n am es( f oo_dat a) <-  g s ub( "(.*)\\.(.* )","\\2.\\1" , name s (foo_da t a))
nam es(foo _da ta) 
# [ 1]  " ind iv i dua l s"   " v ar1 .subset1 ""v ar2.s ubse t 1 " "var 3.s ubse t1" " var1.subset2" 
# [6] "va r2.su bset2 " "v ar 3.sub set2""var1 .s ubset3" "var2.s ubse t3" "var3 .su bs et3 "
If y o ur nam esare  in thi s forma t , y ou c a njust do:
reshape(f oo _ d at a, direc tion = "l on g ", idvar  =  "i ndiv i d uals" , 
     vary ing =2 :n co l(foo_d at a))
#              indi viduals   ti m e    var1    v a r2    var3
#i nd i v id u al1. sub set1 indivi dual 1  sub set1  v alu e 1  va lue4 v a lu e 7
# individual2.sub se t1 ind ividu al2 subset1 value2  va l u e 5  value 8
#i nd i vidual3.subset 1 ind ividual3 s u bset1  v alue3   value6   value9# individu al1 .su bse t2i n di vidual1 subse t 2  val ue 10 valu e13  value1 6
#  in div idu al 2.subset2  individ ua l2  s ub set 2 val u e11 valu e1 4 v al ue1 7
# i n dividu al3.s ubse t2  i n div idual3s ub s e t2 v al ue 12 v alu e1 5 val ue18 # i ndividu al1.subse t3i ndiv id ua l1 subs et3 value19 v al ue22 value 25 
#indivi d u al2.subs et3 individual2 subset3 value20  va lue23  val ue26
# in div idual3 .su b set3 i ndivid ual3su bse t 3  valu e 2 1val ue 24 value27 You  canre move  the fu nky rownames withr own ames
 _c(1,(3*i-1):(3*(i+1)-2))
 _temp <- foo_data[,c(1,(3*i-1):(3*(i+1)-2))]
 _names(temp) <-_noms
_ stacked_foo_<-_rbind(stacked_foo,temp)
  print(i)
}

But_isn't there something_more fast, more concise,_with a built_in_function like melt or stack?

A:

Option 1: Base R's reshape function
This is a task for_reshape_(from base_R),_but_it wants your data.frame names_to be in a slightly_different format.
Try_this:
names(foo_data) <- gsub("(.*)\\.(.*)", "\\2.\\1", names(foo_data))
names(foo_data)
#  [1] "individuals"__"var1.subset1" "var2.subset1" "var3.subset1"_"var1.subset2"
#  [6] "var2.subset2" "var3.subset2" "var1.subset3" "var2.subset3" "var3.subset3"

If your_names are in this format, you_can just do:
reshape(foo_data,_direction_=_"long", idvar = "individuals",_
     _  varying = 2:ncol(foo_data))
# _      _     _    _ individuals_   time _  var1_ _ var2 _  var3
# individual1.subset1 individual1 subset1_ value1 _value4  value7
# individual2.subset1 individual2 subset1__value2  value5__value8
#_individual3.subset1 individual3_subset1  value3__value6 _value9
#_individual1.subset2 individual1 subset2 value10 value13 value16
#_individual2.subset2_individual2 subset2 value11 value14 value17
# individual3.subset2 individual3_subset2 value12 value15 value18
#_individual1.subset3_individual1 subset3 value19 value22_value25
# individual2.subset3 individual2 subset3 value20_value23 value26
# individual3.subset3 individual3 subset3 value21_value24 value27

You_can remove_the funky rownames with rownames