hmisc

R - describe() output to a data frame

杀马特。学长 韩版系。学妹 提交于 2020-06-12 06:33:08
问题 I want to create a data frame using describe() function. Dataset under consideration is iris. The data frame should look like this: Variable n missing unique Info Mean 0.05 0.1 0.25 0.5 0.75 0.9 0.95 Sepal.Length 150 0 35 1 5.843 4.6 4.8 5.1 5.8 6.4 6.9 7.255 Sepal.Width 150 0 23 0.99 3.057 2.345 2.5 2.8 3 3.3 3.61 3.8 Petal.Length 150 0 43 1 3.758 1.3 1.4 1.6 4.35 5.1 5.8 6.1 Petal.Width 150 0 22 0.99 1.199 0.2 0.2 0.3 1.3 1.8 2.2 2.3 Species 150 0 3 Is there a way out to coerce the output

“Hmisc” package or namespace failed to load - no package called 'latticeExtra'

依然范特西╮ 提交于 2020-05-14 18:35:29
问题 I'm having trouble loading and running the Hmisc package. When installing it, I get the following error; library(Hmisc) Loading required package: lattice Loading required package: survival Loading required package: Formula Loading required package: ggplot2 Error: package or namespace load failed for ‘Hmisc’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘latticeExtra’ I'm running Rstudio 3.5.3 I've tried to update all packages. The

Escaping LaTeX control symbols in Hmisc::latex

假装没事ソ 提交于 2020-03-03 05:09:26
问题 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 uncompilable. Is there a way within Hmisc to escape dollar signs when formatting values from a data frame? I can't run search and replace over all dollar signs afterwards either, because the Hmisc itself adds dollar signs for the empty cells. Minimal example:

Escaping LaTeX control symbols in Hmisc::latex

你。 提交于 2020-03-03 05:08:19
问题 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 uncompilable. Is there a way within Hmisc to escape dollar signs when formatting values from a data frame? I can't run search and replace over all dollar signs afterwards either, because the Hmisc itself adds dollar signs for the empty cells. Minimal example:

R - Inconsistent p-value in running Spearman correlation

孤街浪徒 提交于 2020-01-15 10:30:33
问题 My problem is when I compute running correlation for some odd reason I do not get the same p-value for the same estimates/correlations values. My target is to calculate a running Spearman correlation on two vectors in the same data.frame (subject1 and subject2 in the example below). In addition, my window (length of the vector) and stide (the jumps/steps between each window) are constant. As such, when looking at the formula below (from wiki) I should get the same critical t hence the same p

data.table: lapply a function with multicolumn output

╄→尐↘猪︶ㄣ 提交于 2020-01-02 05:00:47
问题 I'm using a function smean.cl.normal from Hmisc package that returns a vector with 3 values: the mean and the lower and upper CI. When I use it on a data.table with 2 groups, I obtain 2 columns and 6 rows. Is there a way to obtain the result with two rows corresponding to 2 groups and separate columns for each of function's outputs, i.e. the mean and CIs? require(Hmisc) require(data.table) dt = data.table(x = rnorm(100), gr = rep(c('A', 'B'), each = 50)) dt[, lapply(.SD, smean.cl.normal), by

R: Assign variable labels of data frame columns

若如初见. 提交于 2019-12-29 14:15:11
问题 I am struggling with variable labels of data.frame columns. Say I have the following data frame (part of much larger data frame): data <- data.frame(age = c(21, 30, 25, 41, 29, 33), sex = factor(c(1, 2, 1, 2, 1, 2), labels = c("Female", "Male"))) # I also have a named vector with the variable labels for this data frame: var.labels <- c(age = "Age in Years", sex = "Sex of the participant") I want to assign the variable labels in var.labels to the columns in the data frame data using the

Error in loading package SASxport: object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

依然范特西╮ 提交于 2019-12-24 05:25:11
问题 I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this: library("Hmisc") sasxport.get("C:/path/file.XPT") and library("SASxport") read.xport("C:/path/file.XPT") The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport") , I get the error message:

Sample size and power calculation in r as viable alternative to proc power in SAS?

痞子三分冷 提交于 2019-12-22 05:16:20
问题 So I am trying to see how close the sample size calculations (for two sample independent proportions with unequal samples sizes) are between proc power in SAS and some sample size functions in r. I am using the data found here at a UCLA website. The UCLA site gives parameters as follows: p1=.3,p2=.15,power=.8,null difference=0, and for the two-sided tests it assumes equal sample sizes; for the unequal sample size tests the parameters are the same, with group weights of 1 for group1 and 2 for

Evaluation Error when tidyverse is loaded after Hmisc

折月煮酒 提交于 2019-12-21 04:07:09
问题 I am using r 3.3.3, dplyr 0.7.4, and Hmisc 4.1-1. I noticed that the order I load packages effects whether or not a dplyr::summaries function wold work or not. I understand that loading packages in a different order would mask certain functions but I am using the package::function() syntax to avoid that issue. The exact issue revolves around labeled variables. I know that there has been issues in the past with tidyverse and variable labels but none seem to address why this particular