diff options
Diffstat (limited to 'R/mkin_long_to_wide.R')
-rw-r--r-- | R/mkin_long_to_wide.R | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/R/mkin_long_to_wide.R b/R/mkin_long_to_wide.R new file mode 100644 index 00000000..45ee0a10 --- /dev/null +++ b/R/mkin_long_to_wide.R @@ -0,0 +1,9 @@ +mkin_long_to_wide <- function(long_data, time = "time")
+{
+ colnames <- unique(long_data$name)
+ wide_data <- data.frame(time = subset(long_data, name == colnames[1], time))
+ for (var in colnames) {
+ wide_data[var] <- subset(long_data, name == var, value)
+ }
+ return(wide_data)
+}
|