Skip to content

Commit bba19dc

Browse files
committed
#73 move code back into pipe
- change extraction of scaled vec to as.numeric - checked with hist() that results in same vec / dist
1 parent 29a774c commit bba19dc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

main.R

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,35 +166,30 @@ veg_richness <- veg_richness |>
166166
## TODO: generate npoint_tm1 variable to calculate correct log_pr_cover_tm1 variable - also talk to Jian about log(+1 of this var)
167167
# standardise predictors and remove rows with missing flow info - note we need to add a small value to everything?
168168

169-
veg_cover_ar$days_above_baseflow_std <- scale(veg_cover_ar$days_above_baseflow)[, 1]
170-
veg_cover_ar$days_above_springfresh_std <- scale(veg_cover_ar$days_above_springfresh)[, 1]
171169

172170
veg_cover_ar <- veg_cover_ar |>
173171
mutate(
174172
pr_cover = hits/npoint,
175173
log_hits_tm1 = log(hits_tm1 + 1),
176174
#log_pr_cover_tm1 = log((hits_tm1/npoint) + 1),
177-
# days_above_baseflow_std = scale(days_above_baseflow)[, 1],
178-
# days_above_springfresh_std = scale(days_above_springfresh)[, 1],
175+
days_above_baseflow_std = scale(days_above_baseflow) %>% as.numeric,
176+
days_above_springfresh_std = scale(days_above_springfresh) %>% as.numeric,
179177
days_above_baseflow_std_sq = days_above_baseflow_std ^ 2,
180178
days_above_springfresh_std_sq = days_above_springfresh_std ^ 2
181179
) |>
182-
filter(!is.na(days_above_springfresh)) # temporary due to incomplete flow data
183-
184-
veg_cover_ar_sum$days_above_baseflow_std <- scale(veg_cover_ar_sum$days_above_baseflow)[, 1]
185-
veg_cover_ar_sum$days_above_springfresh_std <- scale(veg_cover_ar_sum$days_above_springfresh)[, 1]
180+
filter(!is.na(days_above_springfresh)) #TODO temporary due to incomplete flow data
186181

187182
veg_cover_ar_sum <- veg_cover_ar_sum |>
188183
mutate(
189184
pr_cover = hits/npoint,
190185
log_hits_tm1 = log(hits_tm1 + 1),
191186
#log_pr_cover_tm1 = log((hits_tm1/npoint) + 1),
192-
# days_above_baseflow_std = scale(days_above_baseflow)[, 1],
193-
# days_above_springfresh_std = scale(days_above_springfresh)[, 1],
187+
days_above_baseflow_std = scale(days_above_baseflow) %>% as.numeric,
188+
days_above_springfresh_std = scale(days_above_springfresh) %>% as.numeric,
194189
days_above_baseflow_std_sq = days_above_baseflow_std ^ 2,
195190
days_above_springfresh_std_sq = days_above_springfresh_std ^ 2
196191
) |>
197-
filter(!is.na(days_above_springfresh)) # temporary due to incomplete flow data
192+
filter(!is.na(days_above_springfresh)) #TODO temporary due to incomplete flow data
198193

199194
# find the minimum proportion cover score for each dataset
200195

0 commit comments

Comments
 (0)