Guest User

Untitled

a guest
Jun 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. library(readr)
  2. library(tidyr)
  3.  
  4. file_path <- "C:/Users/user/Desktop/to_melt.csv"
  5. input <- read_csv(file_path)
  6.  
  7. # create vector of field names that you want melted
  8. ## in this instance select the 8th field through end of data frame
  9. fields_to_melt <- names(input[8:length(names(input))])
  10.  
  11. # melt the data from wide- to long-format
  12. melted <- gather(input fields_to_melt key = variable value = values)
  13.  
  14. write_csv(melted C:/Users/user/Desktop/melted.csv)
Add Comment
Please, Sign In to add comment