I have the following sample data:
"","Class","Sex","Age","Survived","Freq"
"1","1st","Male","Child","No",0
"2","2nd","Male","Child","No",0
"3","3rd","Male","Child","No",2
"4","Crew","Male","Child","No",0
I have stored it in a list in R using the following:
dat = read.csv("File.csv", header = TRUE)
Now I would like to copy this list to another which does not have the "Freq" column but has more rows based on the value of the "Freq" (please refer to reqd. data below)(Freq = 0 has no effect) :
"","Class","Sex","Age","Survived"
"1","1st","Male","Child","No"
"2","2nd","Male","Child","No"
"3","3rd","Male","Child","No"
"3","3rd","Male","Child","No"
"4","Crew","Male","Child","No"
The 3rd row in the original data was doubled in the new data due to its Freq = 2. However, the rows with Freq = 0 still had 1 row in the output data. Any help would be much appreciated.