Hello everybody,
I would like to transform a table with the following data:
##data frame input:
Document<-c(1,2,3,4)
Day<-c(5,6,8,10)
Month<-c(25,12,8,6)
FORM_Day<-c(1,1,1,1)
CO_Day<-c(0,0,1,1)
FORM_Month<-c(0,0,1,1)
CO_Month<-c(0,0,1,0)
test_data<-data.frame(Document,Day,Month,FORM_Day,CO_Day,FORM_Month,CO_Month)
test_data
In this data frame we have information about document, day, and month. "FORM" and "CO" variables are 2 types of data validation.
For example, in the first document we have month_value=25. It is impossible bacause we only have 12 months, so in the FORM_Month variable we have a "1" in order to identify a data error.
My target is to restructure the table in order to show the information in a easy way.
Specifically I would like to get the following structure:
Validation_type<-c("FORM", "CO", "FORM", "CO" , "FORM", "CO", "FORM", "CO", "FORM" ,"CO", "FORM", "CO" ,"FORM", "CO", "FORM", "CO")
camp<-c("Day", "Day", "Month", "Month" ,"Day" , "Day" , "Month", "Month", "Day" , "Day" , "Month" ,"Month", "Day" , "Day" , "Month", "Month" )
value<-c( "5", "5" , "25", "25", "6" ,"6" ,"12", "12", "8", "8", "8", "8","10", "10", "6", "6")
document<-c("1", "1", "1", "1", "2", "2", "2", "2", "3", "3", "3", "3", "4", "4", "4", "4")
result<-c("0", "0", "1", "0", "0", "0", "0","0", "1", "1", "1", "1", "1", "1", "0", "0")
df_example<-data.frame(Validation_type,campo,value, document,result)
df_example
I tried some transpose funcitons but I can't find out how to get this agregation level.
Could someone help me ,please?
Thanks in advance!
Robert