Hola, ¿qué tal? Quisiera consultar cuál es la forma óptima de generar el vector "a, "a", "a","a","b","b","b","b" a partir del vector "a", "b" He probado ésto:> sapply(vars, rep, 4)a b [1,] "a" "b" [2,] "a" "b" [3,] "a" "b" [4,] "a" "b" Pero yo lo que necesito es un vector... Gracias. Eva [[alternative HTML version deleted]]
Intenta> rep(c("a", "b"), each = 4)[1] "a" "a" "a" "a" "b" "b" "b" "b" Jorge.- 2012/5/20 Eva Prieto Castro <>> Hola, ¿qué tal? > > Quisiera consultar cuál es la forma óptima de generar el vector > > "a, "a", "a","a","b","b","b","b" > > a partir del vector > > "a", "b" > > He probado ésto: > > > sapply(vars, rep, 4) > a b > [1,] "a" "b" > [2,] "a" "b" > [3,] "a" "b" > [4,] "a" "b" > > Pero yo lo que necesito es un vector... > > Gracias. > > Eva > [[alternative HTML version deleted]] > > > _______________________________________________ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > >[[alternative HTML version deleted]]
Gracias Jorge!! --- El dom, 20/5/12, Jorge I Velez <jorgeivanvelez@gmail.com> escribió: De: Jorge I Velez <jorgeivanvelez@gmail.com> Asunto: Re: [R-es] Duda vectores Para: "Eva Prieto Castro" <evapcastro@yahoo.es> CC: "r-help-es@r-project.org" <r-help-es@r-project.org> Fecha: domingo, 20 de mayo, 2012 19:22 Intenta> rep(c("a", "b"), each = 4)[1] "a" "a" "a" "a" "b" "b" "b" "b" Jorge.- 2012/5/20 Eva Prieto Castro <> Hola, ¿qué tal? Quisiera consultar cuál es la forma óptima de generar el vector "a, "a", "a","a","b","b","b","b" a partir del vector "a", "b" He probado ésto:> sapply(vars, rep, 4)a b [1,] "a" "b" [2,] "a" "b" [3,] "a" "b" [4,] "a" "b" Pero yo lo que necesito es un vector... Gracias. Eva [[alternative HTML version deleted]] _______________________________________________ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]]