[R] Dplyr question
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Tue Jun 21 19:02:59 CEST 2022
Beware of being too specific about how you want something solved... not just here, but in all contexts. Your question is like "how do I slice this apple with this potholder"... dplyr actually doesn't do that, and you can benefit from learning how to do things in general, not just in your preferred idiom.
ans <-
do.call( rbind
, lapply( names(dta[ -1 ])
, function( nm )
data.frame( dta[1]
, Location = nm
, Measurement = dta[[nm]]
, stringsAsFactors = FALSE ) ) )
On June 21, 2022 9:22:48 AM PDT, Thomas Subia <thomas.subia using fmindustries.com> wrote:
>Colleagues:
>
>The header of my data set is:
>Time_stamp P1A0B0D P190-90D
>Jun-10 10:34 -0.000208 -0.000195
>Jun-10 10:51 -0.000228 -0.000188
>Jun-10 11:02 -0.000234 -0.000204
>Jun-10 11:17 -0.00022 -0.000205
>Jun-10 11:25 -0.000238 -0.000195
>
>I want my data set to resemble:
>
>Time_stamp Location Measurement
>Jun-10 10:34 P1A0B0D -0.000208
>Jun-10 10:51 P1A0B0D -0.000228
>Jun-10 11:02 P1A0B0D -0.000234
>Jun-10 11:17 P1A0B0D -0.00022
>Jun-10 11:25 P1A0B0D -0.000238
>Jun-10 10:34 P190-90D -0.000195
>Jun-10 10:51 P190-90D -0.000188
>Jun-10 11:02 P190-90D -0.000204
>Jun-10 11:17 P190-90D -0.000205
>Jun-10 11:25 P190-90D -0.000195
>
>I need some advice on how to do this using dplyr.
>
>V/R
>Thomas Subia
>
>FM Industries, Inc. - NGK Electronics, USA | www.fmindustries.com
>221 Warren Ave, Fremont, CA 94539
>
>"En Dieu nous avons confiance, tous les autres doivent apporter des donnees"
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list