r-haven

Extract the labels attribute from “labeled” tibble columns from a haven import from Stata

送分小仙女□ 提交于 2020-12-27 17:54:26
问题 Hadley Wickham's haven package, applied to a Stata file, returns a tibble with many columns of type "labeled". You can see these with str(), e.g.: $ MSACMSZ :Class 'labelled' atomic [1:8491861] NA NA NA NA NA NA NA NA NA NA ... .. ..- attr(*, "label")= chr "metropolitan area size (cmsa/msa)" .. ..- attr(*, "labels")= Named int [1:7] 0 1 2 3 4 5 6 .. .. ..- attr(*, "names")= chr [1:7] "not identified or nonmetropolitan" "100,000 - 249,999" "250,000 - 499,999" "500,000 - 999,999" ... It would

Extract the labels attribute from “labeled” tibble columns from a haven import from Stata

戏子无情 提交于 2020-12-27 17:42:36
问题 Hadley Wickham's haven package, applied to a Stata file, returns a tibble with many columns of type "labeled". You can see these with str(), e.g.: $ MSACMSZ :Class 'labelled' atomic [1:8491861] NA NA NA NA NA NA NA NA NA NA ... .. ..- attr(*, "label")= chr "metropolitan area size (cmsa/msa)" .. ..- attr(*, "labels")= Named int [1:7] 0 1 2 3 4 5 6 .. .. ..- attr(*, "names")= chr [1:7] "not identified or nonmetropolitan" "100,000 - 249,999" "250,000 - 499,999" "500,000 - 999,999" ... It would

Extract the labels attribute from “labeled” tibble columns from a haven import from Stata

给你一囗甜甜゛ 提交于 2020-12-27 17:41:53
问题 Hadley Wickham's haven package, applied to a Stata file, returns a tibble with many columns of type "labeled". You can see these with str(), e.g.: $ MSACMSZ :Class 'labelled' atomic [1:8491861] NA NA NA NA NA NA NA NA NA NA ... .. ..- attr(*, "label")= chr "metropolitan area size (cmsa/msa)" .. ..- attr(*, "labels")= Named int [1:7] 0 1 2 3 4 5 6 .. .. ..- attr(*, "names")= chr [1:7] "not identified or nonmetropolitan" "100,000 - 249,999" "250,000 - 499,999" "500,000 - 999,999" ... It would

Cannot install Haven R

谁说胖子不能爱 提交于 2020-07-23 06:36:27
问题 I tried using both install.packages("tidyverse") and install.packages("haven"). However, it says -bash: syntax error near unexpected token '(' After running brew doctor, I received this message: Warning: "config" scripts exist outside your system or Homebrew directories. ./configure scripts often look for *-config scripts to determine if software packages are installed, and which additional flags to use when compiling and linking. Having additional scripts in your path can confuse software

Cannot install Haven R

喜欢而已 提交于 2020-07-23 06:35:06
问题 I tried using both install.packages("tidyverse") and install.packages("haven"). However, it says -bash: syntax error near unexpected token '(' After running brew doctor, I received this message: Warning: "config" scripts exist outside your system or Homebrew directories. ./configure scripts often look for *-config scripts to determine if software packages are installed, and which additional flags to use when compiling and linking. Having additional scripts in your path can confuse software

Getting a subset error I did not get two months ago when running logistic regression (svyglm) on survey data (SPSS dataset)

我怕爱的太早我们不能终老 提交于 2020-06-28 04:00:07
问题 I re-run script that previously worked with no errors about two months ago. I used the haven package to upload an (non-public and proprietary) SPSS dataset and the survey package to analyze complex survey data. Now, however, when I run even a simple logistic regression where both variables are dummies (coded 0 for no and 1 for yes)...something like this... f <- read_sav("~/data.sav") fsd <- svydesign(ids=~1, data=f, weights=~f$weight) model <- svyglm(exclhlth~male,design=fsd,family

Error when estimating random effects model with plm package when haven is loaded

大城市里の小女人 提交于 2020-05-16 07:40:28
问题 I have a weird problem when estimating a random effects with the plm package in R. Here is a link to a dput of part of my data: https://pastebin.com/raw/mTdh26dg My code is: library(plm) library(haven) pmales <- pdata.frame(males_part, index = c("NR", "YEAR")) random <- plm(WAGE ~ SCHOOL + EXPER + EXPER2 + BLACK + HISP + MAR + UNION + RUR + NE + NC + S + factor(YEAR), data = pmales, model = "random") The reason I included libary(haven) is that my original data set is a .dta file. When I run

Error when estimating random effects model with plm package when haven is loaded

自作多情 提交于 2020-05-16 07:38:45
问题 I have a weird problem when estimating a random effects with the plm package in R. Here is a link to a dput of part of my data: https://pastebin.com/raw/mTdh26dg My code is: library(plm) library(haven) pmales <- pdata.frame(males_part, index = c("NR", "YEAR")) random <- plm(WAGE ~ SCHOOL + EXPER + EXPER2 + BLACK + HISP + MAR + UNION + RUR + NE + NC + S + factor(YEAR), data = pmales, model = "random") The reason I included libary(haven) is that my original data set is a .dta file. When I run

Dynamically create value labels with haven::labelled

可紊 提交于 2020-01-24 23:42:07
问题 I am using haven::labelled to set value labels of a variable. The goal is to create a fully documented dataset I can export to SPSS. Now, say I have a df value_labels of values and their value labels. I also have i df df_data with variables to which I want allocate value labels. value_labels <- tibble( value = 1:6, labels = paste0("value", 1:6) ) df_data <- tibble( id = 1:10, var = floor(runif(10, 1, 6)) ) Manually, I would create value labels for df_data$var like so: df_data$var <- haven:

Variable labels in the R package Haven with SPSS

老子叫甜甜 提交于 2020-01-23 05:20:07
问题 I'm trying to access the variable labels (this is the description of the variable) from an SPSS por file with the haven package. I can do it just fine with the foreign package but I'd like to use haven. Any suggestions? # Using foreign I can get the variable labels with_foreign <- foreign::read.spss(mydata.por) attr(with_foreign, "variable.labels") # With haven I get null with_haven <- haven::read_spss(mydata.por) attr(with_haven, "variable.labels") # Some things I've experimented with