sep_col is split into multiple columns given by into. If column ageclass is present and values start with 0 one is added to align with agestructure in other functions. Columns without any informations (length(unique()) == 1) are dropped. If the first time step only has zeros as values remove these values. remove zeros overall!

preprocess_txt(df_txt, sep_col = "code", into, removeZeros = TRUE)

Arguments

df_txt

Dataframe read in with load_txt().

sep_col

Column to separate into multiple columns. Default is "code".

into

Character vector given the columns to split sep_col in.

removeZeros

Boolean. Remove all zeros. (Default = T)

Value

Tidy dataframe.

Examples

d <- system.file("extdata", "setas-model-new-becdev", package = "atlantistools") df <- load_txt(file = file.path(d, "outputSETASSpecificPredMort.txt")) df <- preprocess_txt(df_txt = df, into = c("pred", "agecl", "empty_col1", "prey", "empty_col2")) head(df)
#> time pred agecl prey atoutput #> 43 219 FPS 1 FPS 1.012245e-06 #> 44 292 FPS 1 FPS 1.012245e-06 #> 45 365 FPS 1 FPS 1.012245e-06 #> 46 365 FPS 1 FPS 1.012245e-06 #> 47 438 FPS 1 FPS 1.012245e-06 #> 48 511 FPS 1 FPS 1.012245e-06
df <- load_txt(file = file.path(d, "outputSETASSpecificMort.txt")) df <- preprocess_txt(df_txt = df, into = c("species", "agecl", "empty_col", "mort")) head(df)
#> time species agecl mort atoutput #> 2 365 FPS 1 M1 1.194350e-06 #> 3 730 FPS 1 M1 1.567903e+18 #> 5 365 FPS 2 M1 9.918807e-07 #> 6 730 FPS 2 M1 2.266454e-06 #> 8 365 FPS 3 M1 9.514757e-07 #> 9 730 FPS 3 M1 1.834196e-06