Undergraduate degree in Systems Engineering, CS
Microsoft
Phd Quantitative Ecology
Now: creating generalized tools for fisheries modeling at ECS Federal for NOAA
Best when starting to use a new package for the first time. Step-by-step reference with guidance on syntax, dependencies, and workflow.
Best for understanding syntax and testing environment.
## Error in tibble(vec_col = 1:10) %>% mutate(vec_sum = sum(vec_col)): could not find function "%>%"
## # A tibble: 10 x 2
## vec_col vec_sum
## <int> <int>
## 1 1 55
## 2 2 55
## 3 3 55
## 4 4 55
## 5 5 55
## 6 6 55
## 7 7 55
## 8 8 55
## 9 9 55
## 10 10 55
input_data <- list(c(1, 5, 7),
5,
c(10, 10, 11))
tibble(list_col = input_data) %>%
mutate(list_sum = sum(list_col))
## Error in sum(list_col): invalid 'type' (list) of argument
## List of 3
## $ : num [1:3] 1 5 7
## $ : num 5
## $ : num [1:3] 10 10 11
str()
to see input structureR
- still useful!foo <- c(1,2,3)
sum_the_cols <- function(dat){
tibble(list_col = input_data) %>%
mutate(list_sum = sum(list_col))
}
sum_the_cols(foo)
## Error in sum(list_col): invalid 'type' (list) of argument
R
- still useful!## Error in eval_tidy(xs[[i]], unique_output): object 'input_data' not found
debugonce()
browser()
input_data <- list(c(1, 5, 7),
5,
c(10, 10, 11))
foo <- 1:10
sum_the_cols <- function(dat){
browser()
tibble(list_col = input_data) %>%
mutate(list_sum = sum(list_col))
}
sum_the_cols(input_data)
## Called from: sum_the_cols(input_data)
## debug at <text>#9: tibble(list_col = input_data) %>% mutate(list_sum = sum(list_col))
## Error in sum(list_col): invalid 'type' (list) of argument
foo <- c(1,2,3)
sum_the_cols <- function(dat){
if(is.list(dat)){
stop("Error: mutate doesn't work on list inputs!")
}
tibble(list_col = dat) %>%
mutate(list_sum = sum(list_col))
}
sum_the_cols(input_data)
## Error in sum_the_cols(input_data): Error: mutate doesn't work on list inputs!
reprex
stop()
to prevent the next time!