Hello, I have a dataframe that need to change the format. Current format has Visit as variable. It means the number of visits to a field. It can be two or three, depending on the field ID. In each visit I counted birds and set the count as a column.
This is how the current format looks like:
Property<-c(rep("A",3), rep("B",2))
Field<-c(rep("y",3), rep("f",2))
Visit<-c("1","2","3","1","2")
bird.count<-c(0,1,1,0,1)
df<-cbind.data.frame(Property, Field, Visit, bird.count)
And here is how I need the data look like (same information but different format):
Property<-c("A","B")
Field<-c("y","f")
Visit1<-c(0,0)
Visit2<-c(1,1)
Visit3<-c(1,NA)
df2<-cbind.data.frame(Property, Field, Visit1, Visit2, Visit3)
I appreciate a recommendation to do this with dplyr or other R tool.
Thanks in advanced