Questions tagged [hmisc]

Hmisc is an R package of miscellaneous utility functions.

Hmisc is an package of miscellaneous functions by Frank Harrell. It contains many functions useful for , ting, utility operations, functions for computing and power, importing datasets, imputing , advanced table making, , manipulation, conversion of R objects to code, and recoding variables.

Repositories

Other resources

Related tags

216 questions
2
votes
1 answer

R-Hmisc impute by cluster result

I want to impute a variable x3 by the its mean corresponding to each cluster calculated considering other 2 variables X1 and X2. I know that you can pass a function to impute from Hmisc package, like "mean" and it does the work. So I would like to…
GabyLP
  • 3,649
  • 7
  • 45
  • 66
2
votes
1 answer

Create function to calculate rcorr on subsets of data frame

I currently manually create a correlation matrix of a large data.frame using the Hmisc Package as below: mydatacorrelation001 <- rcorr(as.matrix(mydata, use = "pairwise.complete.obs")) I now need to calculate the correlation between each variable…
user3740289
  • 265
  • 3
  • 15
2
votes
4 answers

read .csv file with Names and Labels into R

I have a .csv file that I need to read into R. The first row contains the names (e.g. BFI1, BFI2, CAQ2) and the the second row contains the question which I would also like to access in R (e.g. "I enjoy going to parties"). Each row after the first…
David
  • 741
  • 6
  • 5
2
votes
1 answer

Windows API error 2 compiling latex pdf on Hmisc describe

I'm getting a message from Windows saying a .dvi file is missing and that my latex pdf cannot be compiled - see below. The procedure I'm trying to output as a latex table is very simple library(Hmisc) latex(describe(wine)) MiKTeX Problem…
yojan2001
  • 21
  • 3
2
votes
3 answers

How to edit "row.names" after split and cut2 in R?

I want to edit out some information from row.names that are created automatically once split and cut2 were used. See following code: #Mock data date_time <- as.factor(c('8/24/07 17:30','8/24/07 18:00','8/24/07 18:30', …
Yusri
  • 282
  • 1
  • 4
  • 16
2
votes
1 answer

Issues reading .mdb files in R

I'm trying to read a series of microsoft access databases in R. I found the mdb.get function from the Hmisc package which uses mdb-tools. This is my workflow for one particular .mdb file system("wget…
eclark
  • 819
  • 7
  • 16
2
votes
2 answers

How can I get cut2 to use commas?

I am using the R function cut2 in the library Hmisc. I am giving it a vector of numbers which it then turns into equally sized intervals: library(Hmisc) vals = c(100, 1000, 2000, 3000, 40000, 50000, 60000) vals_cut = cut2(vals, g=3) vals_cut [1] [ …
Ari
  • 1,819
  • 14
  • 22
2
votes
1 answer

Strange behavior of Latex table generated by Latex() from Hmisc package and Knitr

I have some code that I am using to make a table in Knitr. I have typed in some numbers manually to make the code reproducible. Expenditure <-…
user33102
  • 323
  • 1
  • 2
  • 10
2
votes
1 answer

Include latex tables generated by Hmisc latex in knitr slides

I am sorry, I am new to using knitr to make slides. I generally use the latex() function in Hmisc package to generate my tables based on R objects. I would like to produce a slide that shows the r code and then below it displays the properly…
2
votes
0 answers

using Hmisc function latex in knitr evironment

I am using knitr to produce pdf reports. One thing I am trying to do is to add multicloumns to a table. I am referting to this link. The question is how can I put the code showed in the post in my Rnw file. This is what I've tried in my Rnw…
user2854008
  • 1,161
  • 4
  • 17
  • 23
2
votes
1 answer

How to calculate Somer's D / C-index for an external validation dataset given a ordinal response

I have fit a proportional odds regression model using the lrm function within Harrell's 'rms' package. I am wondering how I can calculate the c-index / Somer's D for an external validation dataset applied to my fitted model. These statistics can be…
Steve Reno
  • 1,304
  • 3
  • 14
  • 21
2
votes
2 answers

Hmisc package changes original codes from 0:1 to 1:2

I use Hmisc to sign factor names and variable names, and it is very handy. But I found a problem here is the code a <- c(1,0,1,0,1,0,1,0,1,0) b <- c("a","b","a","b","a","b","a","b","a","b") df.new <- data.frame(a,b) library(Hmisc) df.new.1 <-…
Rafik Margaryan
  • 455
  • 1
  • 4
  • 9
2
votes
1 answer

Escaping LaTeX control symbols in Hmisc::latex

I have a data frame in R which unfortunately has strings in it containing dollar signs. When the function latex() from the package Hmisc converts this data frame to a LaTeX table, the dollar signs are not escaped. This renders the LaTeX…
roelandvanbeek
  • 659
  • 8
  • 20
1
vote
1 answer

Python weighted quantile as R wtd.quantile()

I want to convert the R package Hmisc::wtd.quantile() into python. Here is the example in R: I took this as reference and it seems that the logics are different than R: # First function def weighted_quantile(values, quantiles, sample_weight =…
Peter Chen
  • 1,464
  • 3
  • 21
  • 48
1
vote
2 answers

variables lose their labels after mutate() function is applied in R

so assume some of my df columns have labels. library(Hmisc) df1 <- data.frame(a = c(0,1,2), b = c(0,1,2), d = c(0,1,2), e = c(0,1,2), f= c("m","f","o"), output = c(0,1,2)) var_labs <- c(a = "aaa", b = "bbb", …
Mathica
  • 1,241
  • 1
  • 5
  • 17