Function to reshape fieldbook according a separation character
fieldbook_reshape( data, last_factor, sep, new_colname, from_var = NULL, to_var = NULL, exc_factors = NULL )
data | Field book raw data. |
---|---|
last_factor | The last factor in your field book. |
sep | Character that separates the last value. |
new_colname | The new name for the column created. |
from_var | The first variable in case you want to exclude several. variables. |
to_var | The last variable in case you want to exclude several variables. |
exc_factors | Factor to exclude during the reshape. |
data frame
If you variable name is variable_evaluation_rep
. The reshape function
will help to create the column rep
and the new variable name will be
variable_evaluation
.
library(inti) library(googlesheets4) if (gs4_has_token()) { url <- paste0("https://docs.google.com/spreadsheets/d/" , "1lslvNuebfI0YQw3KMz7clN8nIs3x8G9Da63E1em7J5o/") # browseURL(url) gs <- as_sheets_id(url) (data <- gs %>% range_read("fb")) fbrs <- fieldbook_reshape(data = data , last_factor = "imbt" , sep = "_" , new_colname = "rep" , from_var = "sch_0_1" , to_var = "swc_0_1" , exc_factors = "bar_code" ) fbrs }