I'd like to take each cell from V9-13 here and create a new row below each existing row, adding the values from cells V9-13 to the new row. This means that row 1 will have values V1-V8, then the new row below it will have V9-V13 from row 1 in the V1-V5 columns of that row.
{
library("readxl")
library("dplyr")
text_data <- read.delim("C:\\Users\\Kavin Kadam\\Desktop\\UBC\\PCIGR\\IoliteOutlier\\Individual Answers_472.txt", skip=19, header=FALSE)
x<-(nrow(text_data))
for (i in 1:x) {
text_data_refined<-dplyr::add_row(
text_data,
V1 = text_data$V9[i-1],
V2 = text_data$V10[i-1],
V3 = text_data$V11[i-1],
V4 = text_data$V12[i-1],
V5 = text_data$V13[i-1],
.after = text_data_refined[i,]
)
}
}
The sample output would be as in this image - it takes the V9-V13 from the previous row and adds it to the new row here: