Use the value in D2
to create a red bar chart relative to the max value in column d
=SPARKLINE(D2,{"charttype","bar"; "color1", "red"; "max",max($D$2:D)})
df %>% | |
ggplot(aes(x, y, color=foo))+ | |
geom_count()+ | |
# Remove legend for only the size aesthetic | |
scale_size(guide = 'none')+ | |
# Increase legend point size | |
guides(colour = guide_legend(override.aes = list(size=5))) |
theme_bw()+ | |
theme( | |
axis.ticks = element_blank(), | |
axis.text = element_text(color='black'), | |
legend.position = 'none', | |
strip.text.y.left = element_text(angle = 0, face = 'bold'), | |
strip.text.x = element_text(face='bold'), | |
strip.placement = 'outside', | |
strip.background = element_rect(fill='white', linetype = 'blank') | |
) |
snippet qq | |
dbGetQuery(con, read_file(here('${0}'))) | |
snippet gl | |
${0} %>% glimpse() | |
snippet vv | |
${0} %>% View() | |
snippet pw |
df %>% | |
select( | |
colA, | |
colB, | |
colC | |
) %>% | |
mutate_all(~as.character(.x)) %>% | |
map_df( | |
~count(data.frame(x=.x), x), | |
.id="var" |
snippet qq | |
dbGetQuery(con, read_file(here('${0}'))) | |
snippet vv | |
${0} %>% View() |
howMany <- function(x){ length(unique(x))} | |
allSame <- function(x){ length(unique(x)) == 1} | |
df %>% | |
# Keep rows that have values for all columns that contain '-' | |
filter(if_all(matches('-'), ~ !is.na(.))) %>% | |
rowwise() %>% | |
# Use c_across to work with rowwise |
ref_doc <- function(fname, prog){ | |
system(paste0("TASKKILL /F /IM ", prog)) | |
browseURL(fname) | |
} | |
ref_doc('foo.docx', | |
'winword.exe') |
import pyodbc | |
import pandas as pd | |
def rs(fname, conn): | |
""" Returns a pandas dataframe from external file. """ | |
with open(fname, 'r') as f: | |
return pd.read_sql_query(f.read(), conn) | |
conn = pyodbc.connect('Driver={SQL Server};' | |
'Server=servername;' |
Use the value in D2
to create a red bar chart relative to the max value in column d
=SPARKLINE(D2,{"charttype","bar"; "color1", "red"; "max",max($D$2:D)})
df = pd.DataFrame({"AAA": [4, 5, 6, 7], "BBB": [10, 20, 30, 40], "CCC": [100, 50, -30, -50]}) | |
Crit1 = df.AAA <= 5.5 | |
Crit2 = df.BBB == 10.0 | |
Crit3 = df.CCC > -40.0 | |
# Could do this | |
# AllCrit = Crit1 & Crit2 & Crit3 | |
# But this is better |