Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(readr)
- library(tidyr)
- file_path <- "C:/Users/user/Desktop/to_melt.csv"
- input <- read_csv(file_path)
- # create vector of field names that you want melted
- ## in this instance select the 8th field through end of data frame
- fields_to_melt <- names(input[8:length(names(input))])
- # melt the data from wide- to long-format
- melted <- gather(input fields_to_melt key = variable value = values)
- write_csv(melted C:/Users/user/Desktop/melted.csv)
Add Comment
Please, Sign In to add comment