博文

ubuntu配置环境变量

  配置两个环境变量:OLLAMA_HOST和OLLAMA_MODEL。我们可以使用以下步骤来完成这个配置: 打开终端。 编辑您的bash配置文件。对于大多数Ubuntu系统,这个文件是~/.bashrc。使用以下命令打开它: TEXT nano ~/.bashrc 滚动到文件末尾,添加以下两行: TEXT export OLLAMA_HOST="http://192.168.3.216:11434" export OLLAMA_MODEL="gemma2" 保存文件并退出编辑器。如果您使用的是nano,按Ctrl+X,然后按Y,最后按Enter。 为了使更改立即生效,运行: TEXT source ~/.bashrc 验证设置是否成功,可以运行: TEXT echo $OLLAMA_HOST echo $OLLAMA_MODEL 这应该分别显示 http://192.168.3.216:11434和gemma2。

gtsummary 制表

library(gtsummary) library(knitr) theme_gtsummary_language("en", big.mark = "") options(knitr.kable.NA = '') library(flextable) library(officer)  #分类变量显示百分比,2位小数 set_gtsummary_theme(list(   `tbl_summary-fn:percent_fun` = function(x) sprintf("%.2f", x * 100) )) theme_gtsummary_journal("lancet") # 允许不同风格相互叠加 theme_gtsummary_compact() my_test <- function(data, variable, by, ...) {   if (is.numeric(data[[variable]])) {     # For continuous variables, use oneway.test     oneway.test(data[[variable]] ~ as.factor(data[[by]])) %>%       broom::tidy() %>%       select(statistic, p.value)   } else {     # For categorical variables, use chisq.test     chisq.test(table(data[[variable]], data[[by]])) %>%       broom::tidy() %>%       select(statistic, p.value)   } } my_table <- df %>%   select(服药依从性, 年龄, 民族, 性别, 文化程度, 职业, 婚姻状况, 经济状况, 户别, 医疗费用支付方式, 家族史...

ibis 测试

import ibis import pandas as pd from ibis import _ penguins = ibis . examples .penguins. fetch () df = pd . DataFrame (     [[ "a" , 1 , 2 ], [ "b" , 3 , 4 ]],     columns = [ "one" , "two" , "three" ],     index = [ 5 , 6 ], ) t = ibis . memtable ( df , name = "t" ) ( penguins . filter ([ _ .species == "Adelie" , _ .island.isin([ "Biscoe" , "Dream" ])])) ( penguins . limit ( 11 , offset = 9 )) ( penguins . order_by ([ _ .island, _ .bill_length_mm.desc()])) ( penguins . select ( _ .bill_length_mm, _ .sex)) ( penguins . rename ( bill_length = "bill_length_mm" , bill_depth = "bill_depth_mm" )) (     penguins . mutate ( ones = 1 , bill_length = _ .bill_length_mm / 10 )     . mutate ( bill_length_squared = _ .bill_length ** 2 )     . select ( _ .ones, _ .bill_length_mm, _ .bill_length, _ .bill_length_squared) ) (     penguins . select (         _ .island,         _ ....

pandas case_when 使用

 jz= pd.read_sql(sqltxt, conn).rename(columns=str.lower) jz=(     jz     .assign(         age=lambda x: (x['jz_sj']-x['csrq']).dt.days//365,         age_group=lambda df:df.age.case_when(             [                 (lambda s:(s>=15) & (s<=44),'15-44'),                 (lambda s:(s>=45) & (s<=59),'45-59'),                 (lambda s:s>=60,'>60'),                 (lambda s:s<15,'<15'),             ]         ),         year=lambda x: x['jz_sj'].dt.strftime('%Y')     ) ) (     jz.query("age_group!='unknown' & jzdd_dm.str.len()==10")     .groupby(['jzdd_mc','jzdd_dm','year','age_group'],as_index=False).agg(...

出生队列接种率数据预处理

 gnldet <- readxl::read_xlsx('/mnt/c/Users/xuefliang/Downloads/gnldet_jzl.xlsx', sheet = 1, skip = 2) %>%   slice(-1) %>%   fill(区划名称, 区划编码, 疫苗, .direction = "down") %>%   rename(jc = `...4`) %>%   {     new_names <- c()     for (i in 1:18) {       new_names <- c(new_names, paste0(i, "岁接种数"), paste0(i, "岁接种率"))     }     old_names <- colnames(.)     colnames(.)[5:length(old_names)] <- new_names     .   } %>%   mutate(across(contains("率"), ~ as.numeric(str_replace_all(., "%", ""))),          across(contains("数"), ~ as.numeric(.))) %>%   filter(疫苗 != '总人数') gnldet %>%    filter(疫苗=='乙肝疫苗' & jc=='1.0') %>%    select(区划名称,区划编码,疫苗,jc,`1岁接种率`) %>%    mutate(`1岁接种率大于90` = `1岁接种率` > 90) %>%    filter(`1岁接种率大于90`==FALSE) ->test

率及其95%置信区间

  binom.test(3,10,conf.level = 0.95)#x为分子,y为分母 binom.test(30,100,conf.level = 0.95)#x为分子,y为分母

R json解析

 library(jsonlite) ch1 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921201605302722(1).txt') ch2 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622927202110102510(1).txt') ch3 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202303047214(1).txt') ch4 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202403302112(1).txt') ch5 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202403011825(1).txt') person1 <- as_tibble(ch1$data$PersonInfoList) person2 <- as_tibble(ch2$data$PersonInfoList) person3 <- as_tibble(ch3$data$PersonInfoList) person4 <- as_tibble(ch4$data$PersonInfoList) person5 <- as_tibble(ch5$data$PersonInfoList) person <- bind_rows(person1,person2,person3,person4,person5) vaccination <- person %>%   unnest(VaccinationInfoList) %>%    mutate(EntryDate=ymd_hms(EntryDate),UpdateDate=ymd_hms(UpdateDate),UplodeDate=ymd_hms(UplodeDate)) %>%    mutate(scjs = case_when(     difftime(UplodeDate, EntryD...