r

How to compute similarity in quanteda between documents for adjacent years only, within groups?

给你一囗甜甜゛ 提交于 2021-02-11 06:17:42
问题 I have a diachronic corpus with texts for different organizations, each for years 1969 to 2019. For each organization, I want to compare text for year 1969 and text for 1970, 1970 and 1971, etc. Texts for some years are missing. In other words, I have a corpus, cc, which I converted to a dfm Now I want to use textstat_simil : ncsimil <- textstat_simil(dfm.cc, y = NULL, selection = NULL, margin = "documents", method = "jaccard", min_simil = NULL) This compares every text with every other text,

How to compute similarity in quanteda between documents for adjacent years only, within groups?

谁说胖子不能爱 提交于 2021-02-11 06:17:17
问题 I have a diachronic corpus with texts for different organizations, each for years 1969 to 2019. For each organization, I want to compare text for year 1969 and text for 1970, 1970 and 1971, etc. Texts for some years are missing. In other words, I have a corpus, cc, which I converted to a dfm Now I want to use textstat_simil : ncsimil <- textstat_simil(dfm.cc, y = NULL, selection = NULL, margin = "documents", method = "jaccard", min_simil = NULL) This compares every text with every other text,

Export coxph summary from R to csv

爱⌒轻易说出口 提交于 2021-02-11 06:11:47
问题 How to export summary of cox_proportional hazard model from R to csv. I ran a test by function coxph. by survival package Now i want to export its summary to csv, how to do that. c <- coxph(Surv(x~y)) summary(c) 回答1: From the ?coxph examples, I'll use: library(survival) test1 <- list(time=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x=c(0,2,1,1,1,0,0), sex=c(0,0,0,0,1,1,1)) mdl <- coxph(Surv(time, status) ~ x + strata(sex), test1) mdl_summ <- summary(mdl) mdl_summ # Call: # coxph(formula = Surv

How to extract all matching patterns (words in a string) in a dataframe column?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 06:10:45
问题 I have two dataframes. one ( txt.df ) has a column with a text I want to extract phrases from ( text ). The other ( wrd.df ) has a column with the phrases ( phrase ). both are big dataframes with complex texts and strings but lets say: txt.df <- data.frame(id = c(1, 2, 3, 4, 5), text = c("they love cats and dogs", "he is drinking juice", "the child is having a nap on the bed", "they jump on the bed and break it", "the cat is sleeping on the bed")) wrd.df <- data.frame(label = c('a', 'b', 'c',

How to safely import timestamps with Nanosecond precision

ぐ巨炮叔叔 提交于 2021-02-11 06:10:41
问题 I’ve discovered this morning that bulk of timestamp formats in R seem to be posix.ct class based, which seems to be risky for use with nano second timestamps due to rounding and accumulation errors. Is this true? If so, What packages and processing steps are needed to safely import timestamps in nano seconds precision - probably from csv files? (Preferably staying with packages within tidyverse) Output Visual tools used currently are ggplot2 , plotly, and d3 回答1: We wrote a package for that:

Export coxph summary from R to csv

倾然丶 夕夏残阳落幕 提交于 2021-02-11 06:09:46
问题 How to export summary of cox_proportional hazard model from R to csv. I ran a test by function coxph. by survival package Now i want to export its summary to csv, how to do that. c <- coxph(Surv(x~y)) summary(c) 回答1: From the ?coxph examples, I'll use: library(survival) test1 <- list(time=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x=c(0,2,1,1,1,0,0), sex=c(0,0,0,0,1,1,1)) mdl <- coxph(Surv(time, status) ~ x + strata(sex), test1) mdl_summ <- summary(mdl) mdl_summ # Call: # coxph(formula = Surv

How to extract all matching patterns (words in a string) in a dataframe column?

主宰稳场 提交于 2021-02-11 06:09:29
问题 I have two dataframes. one ( txt.df ) has a column with a text I want to extract phrases from ( text ). The other ( wrd.df ) has a column with the phrases ( phrase ). both are big dataframes with complex texts and strings but lets say: txt.df <- data.frame(id = c(1, 2, 3, 4, 5), text = c("they love cats and dogs", "he is drinking juice", "the child is having a nap on the bed", "they jump on the bed and break it", "the cat is sleeping on the bed")) wrd.df <- data.frame(label = c('a', 'b', 'c',

Render LaTeX tables in HTML using rmarkwown

佐手、 提交于 2021-02-11 06:08:52
问题 I am trying to render the following table in a RMD file: \begin{table}[] \centering \caption{My caption} \label{my-label} \begin{tabular}{|l|} \hline \\ \hline \end{tabular} \end{table} So far no success. Is there any fundamental reason why rmarkdown cannot compile LaTeX enviroments (other than equations) to HTML? 回答1: In a markdown document, the expected input markup language is (r)markdown. You should not expect pandoc to automatically recognize arbitrarily mixed markup languages. LaTeX

Export coxph summary from R to csv

三世轮回 提交于 2021-02-11 06:08:47
问题 How to export summary of cox_proportional hazard model from R to csv. I ran a test by function coxph. by survival package Now i want to export its summary to csv, how to do that. c <- coxph(Surv(x~y)) summary(c) 回答1: From the ?coxph examples, I'll use: library(survival) test1 <- list(time=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x=c(0,2,1,1,1,0,0), sex=c(0,0,0,0,1,1,1)) mdl <- coxph(Surv(time, status) ~ x + strata(sex), test1) mdl_summ <- summary(mdl) mdl_summ # Call: # coxph(formula = Surv

Render LaTeX tables in HTML using rmarkwown

感情迁移 提交于 2021-02-11 06:08:44
问题 I am trying to render the following table in a RMD file: \begin{table}[] \centering \caption{My caption} \label{my-label} \begin{tabular}{|l|} \hline \\ \hline \end{tabular} \end{table} So far no success. Is there any fundamental reason why rmarkdown cannot compile LaTeX enviroments (other than equations) to HTML? 回答1: In a markdown document, the expected input markup language is (r)markdown. You should not expect pandoc to automatically recognize arbitrarily mixed markup languages. LaTeX