I am trying to convert data frame into long-form in R. 
This is an example data for surveys conducted in 'id' grids over 9 days and if the variable of interest was detected '1' or not detected '0'. 
I want to convert this data frame so that the number of surveys is reduced from 9 to 3 
but each survey period now contains 3 visits. 
I am trying to do so by stacking three columns at a time, so that survey visits 'v1' to 'v9' (in the image below) gets converted to v1, v2, v3 by adding a column called 'visit\_no' which describe the visit number within the survey period.  

The following link is the image of dataframe in current form and below if the code to generate the data 

[![enter image description here](https://i.stack.imgur.com/rNGxL.png)](https://i.stack.imgur.com/rNGxL.png)

Code to generate data:

```
id<- c(240,220,160)
v1<- c(rep(0,9))
v2<-c(rep(0,3),1,rep(0,5))
v3<- c(1,rep(0,8))

v<-as.data.frame(rbind(v1,v2,v3))

survey<- cbind(id,v)
survey

```

This is the link to the image of data frame I need

Reference data-frame

[![enter image description here](https://i.stack.imgur.com/LjNBl.png)](https://i.stack.imgur.com/LjNBl.png)