tpointtech.wordpress.com/2025/06/05/h...
#ifelsecpp #c++ifelse
tpointtech.wordpress.com/2025/06/05/h...
#ifelsecpp #c++ifelse
x <- c(2,0,NA,3)
ifelse(x>1,1,0)
[1] 1 0 NA 1
x <- c(2,0,NA,3)
ifelse(x>1,1,0)
[1] 1 0 NA 1
my first thought is, yours is worst-case quadratic if x is all NA, but linear if there are no NAs
so just throw outer() at it so it's always quadratic:
my first thought is, yours is worst-case quadratic if x is all NA, but linear if there are no NAs
so just throw outer() at it so it's always quadratic:
Old Dice Parser: X < Y && Z < A ? B : C
New Dice Parser: ifelse(and(lt(X, Y), lt(Z, A)), B, C)
These say the same thing, but I find the first one significantly more understandable than the latter v_v
Old Dice Parser: X < Y && Z < A ? B : C
New Dice Parser: ifelse(and(lt(X, Y), lt(Z, A)), B, C)
These say the same thing, but I find the first one significantly more understandable than the latter v_v
Theme: A Journey
Response: Journey's Journey 2024 - The 73(!) venues being played by the band Journey in 2024. Concert details from setlist.fm/search?artist=3d6b507&upcoming=true&year=2024 with a bunch of additional getting venue coordinates as commitment to the bit.
Theme: A Journey
Response: Journey's Journey 2024 - The 73(!) venues being played by the band Journey in 2024. Concert details from setlist.fm/search?artist=3d6b507&upcoming=true&year=2024 with a bunch of additional getting venue coordinates as commitment to the bit.
after = before + ifelse(before>=5, 0, sample(c(-1, 0, 1), sample_size, replace = TRUE)),
after = before + ifelse(before>=5, 0, sample(c(-1, 0, 1), sample_size, replace = TRUE)),
x = readr::read_lines("input.txt")
xdir = substring(x,1,1)
xlen = as.numeric(substring(x,2))
xcum = cumsum(c(50,xlen*ifelse(xdir=="L",-1,1)))
sum(
0.5 * abs(diff(floor(xcum / 100))) +
0.5 * abs(diff(floor((xcum-1) / 100)))
)
x = readr::read_lines("input.txt")
xdir = substring(x,1,1)
xlen = as.numeric(substring(x,2))
xcum = cumsum(c(50,xlen*ifelse(xdir=="L",-1,1)))
sum(
0.5 * abs(diff(floor(xcum / 100))) +
0.5 * abs(diff(floor((xcum-1) / 100)))
)
A bit of the key #rstats graph making code in alt text
A bit of the key #rstats graph making code in alt text
age_bin <- age_months %/% 12
age_bin <- ifelse(age_bin > 7, 7, age_bin)
# pipe-y
age_bin <- (age_months %/% 12) |> pmin(7)
age_bin <- (a$age_months %/% 12) |>
scales::oob_squish(range = c(NA, 7))
age_bin <- age_months %/% 12
age_bin <- ifelse(age_bin > 7, 7, age_bin)
# pipe-y
age_bin <- (age_months %/% 12) |> pmin(7)
age_bin <- (a$age_months %/% 12) |>
scales::oob_squish(range = c(NA, 7))
r = c('R' = 'LRL', 'L'='LRR')
x = 'RRRR'
for (i in 1:8) {
moves = strsplit(x, '')[[1]]
angles = c(); a = 0
for (m in moves) {
a = a + pi/2 * ifelse(m == "R", -1, 1)
angles = c(angles, a)
}
x = paste(r[strsplit(x, "")[[1]]], collapse = "")
plot(c(0 […]
[Original post on mastodon.social]
r = c('R' = 'LRL', 'L'='LRR')
x = 'RRRR'
for (i in 1:8) {
moves = strsplit(x, '')[[1]]
angles = c(); a = 0
for (m in moves) {
a = a + pi/2 * ifelse(m == "R", -1, 1)
angles = c(angles, a)
}
x = paste(r[strsplit(x, "")[[1]]], collapse = "")
plot(c(0 […]
[Original post on mastodon.social]
ifelse(1 == 2, "Yes", c("Yes", "No"))
ifelse(1 == 2, "Yes", c("Yes", "No"))
library(tidyr); library(dplyr)
df_tidy <- df %>%
pivot_longer(-strain,
names_to=c("genotype","min","rep"),
names_pattern="(.*)_(\\d+)_?(\\d*)") %>%
mutate(genotype=ifelse(grepl("normal",genotype),"normal","mutant"),
rep=ifelse(rep=="","1",rep))
library(tidyr); library(dplyr)
df_tidy <- df %>%
pivot_longer(-strain,
names_to=c("genotype","min","rep"),
names_pattern="(.*)_(\\d+)_?(\\d*)") %>%
mutate(genotype=ifelse(grepl("normal",genotype),"normal","mutant"),
rep=ifelse(rep=="","1",rep))
library(tidyr); library(dplyr)
df_tidy <- df %>%
pivot_longer(-strain,
names_to=c("genotype","min","rep"),
names_pattern="(.*)_(\\d+)_?(\\d*)") %>%
mutate(genotype=ifelse(grepl("normal",genotype),"normal","mutant"),
rep=ifelse(rep=="","1",rep))
library(tidyr); library(dplyr)
df_tidy <- df %>%
pivot_longer(-strain,
names_to=c("genotype","min","rep"),
names_pattern="(.*)_(\\d+)_?(\\d*)") %>%
mutate(genotype=ifelse(grepl("normal",genotype),"normal","mutant"),
rep=ifelse(rep=="","1",rep))
ft_dt$disp <- ifelse(
ft_dt$disp > 200,
cell_spec(ft_dt$disp, color = "red", bold = T),
cell_spec(ft_dt$disp, color = "green", italic = T)
)
ft_dt$hp <- color_bar("lightgreen")(ft_dt$hp)
ft_dt <- ft_dt[c("car", "mpg", "cyl", "disp", "hp")]
to be continued
ft_dt$disp <- ifelse(
ft_dt$disp > 200,
cell_spec(ft_dt$disp, color = "red", bold = T),
cell_spec(ft_dt$disp, color = "green", italic = T)
)
ft_dt$hp <- color_bar("lightgreen")(ft_dt$hp)
ft_dt <- ft_dt[c("car", "mpg", "cyl", "disp", "hp")]
to be continued