Attached is a screenshot of a dataframe I am working with. In order to use some other software that I have, I need all of the data to be on one row. What I essentially want to do is to copy all of the data from row 2 and onwards and just paste it onto the end of row one. I have tried to do that a few times in R but I usually end up with something that either orders all of the data (for example, every data point under "ParticipantName" would show up first then everything under "Name", "Age", and so on) or will have all of the data under a certain column in just one cell. My current code is this:
alan=read.csv("Alan.csv") print(alan) combined_data <- apply(alan, 2, function(x) paste(x, collapse = "")) combined_alan <- data.frame(t(combined_data)) file_path <- "C:\\my_path\\alan.csv" #(Not my actual file path) # Save the dataframe as a CSV file write.csv(collapsed_row, file = file_path, row.names = FALSE)
Any help is greatly appreciated.