Hi,
With 'expss' package code for your task looks like this:
library(haven)
library(expss) # it is important to load expss after haven
# CatsDogs = read_spss("path_to_file")
CatsDogs = structure(
list(
Animal = structure(
c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0),
Best of luck.
On Sat, 8 Feb 2020 at 10:36, Yawo Kokuvi wrote:
> Thanks again - I realized after posting that sjlabelled is indirectly
> referencing haven's read_sav function. For a moment I thought you were
> referring to the read.spss under the older foreign package. But then
> realized that
Thanks again - I realized after posting that sjlabelled is indirectly
referencing haven's read_sav function. For a moment I thought you were
referring to the read.spss under the older foreign package. But then
realized that read_sav and read_spss are equivalent. So that's clear now.
And I also r
"use a different function (read_spss) as John has suggested to import the
file. "
No! As far as I can see sjlabelled is simply using haven"s function "
read_sav()" to read in the data. It is just wrapped in the "read.spss()
function.There should be no difference between read_sav(sdata.sav) and
rea
Thanks so much for all your assistance. I admit R's learning curve is a
bit steep, but I am eager to learn ... and hopefully teach with it.
with regard to my problem, I can now see two options: either declare each
categorical variable as factors, specifying the needed levels and labels.
OR
use
Hi Yawo Kokuvi;
As an R newbie transitioning from SPSS to R expect culture shock and the
possible feeling that yor brain is twisting within your skull but it is
well worth.
Try something like this:
##+
dat1 <- structure(list(Animal =
Hello,
Try
aux_fun <- function(x){
levels <- attr(x, "labels")
factor(x, labels = names(levels), levels = levels)
}
newCatsDogs <- as.data.frame(lapply(CatsDogs, aux_fun))
str(newCatsDogs)
#'data.frame': 10 obs. of 3 variables:
# $ Animal : Factor w/ 2 levels "Cat","Dog": 1 1 1 1 1 1 1
Thanks for all. Here is output from dput. I used a different dataset
containing categorical variables since the previous one is on a different
computer.
In the following dataset, my interest is in getting frequencies and
barplots for the two variables: Training and Dance, with value labels
displa
Yes. Most attachments are stripped by the server.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Feb 7, 2020 at 5:34 PM John Kane wrote:
> Hi,
> Could y
Hi,
Could you upload some sample data in dput form? Something like
dput(head(Scratch, n=13)) will give us some real data to examine. Just copy
and paste the output of dput(head(Scratch, n=13))into the email. This is
the best way to ensure that R-help denizens are getting the data in the
exact form
Maybe it helps searching at https://rseek.org/ for "SPSS to R transition
value labels".
In particular
https://cran.r-project.org/web/packages/expss/vignettes/labels-support.html
seems useful, as well as
https://www.r-bloggers.com/migrating-from-spss-to-r-rstats/
best regards,
Heinz
Jim Lemon wro
Thanks Jim:
So one option is to go through the data, select all the categorical
variables I want and re-define them as factor variables ? As in the
following example for gender?
mydata$sex<- factor(mydata$sex, levels = c(1,2), labels = c("male",
"female"))
thanks - cY
On Fri, Feb 7, 2020 at 4:
Hi Yawo,
>From your recent post, you say you have coerced the variables to
factors. If so, perhaps:
as.character(x) is what you want.
If not, creating a new variable like this:
Scratch$new_race<-factor(as.character(Scratch$race),levels=c("WHITE","BLACK"))
may do it. Note the "levels" argument t
Thanks for all your assistance
Attached please is the Rdata scratch I have been using
-
> head(Scratch, n=13)
# A tibble: 13 x 6
ID maritalsex racepaeducspeduc
1 1 3 [DIVORCED] 1
What does your data look like after importing? -- see ?head and ?str to
tell us. Show us the code that failed to provide "labels." See the posting
guide below for how to post questions that are likely to elicit helpful
responses.
I know nothing about the haven package, but see ?factor or go throug
Hello,
I am just transitioning from SPSS to R.
I used the haven library to import some of my spss data files to R.
However, when I run procedures such as frequencies or crosstabs, value
labels for categorical variables such as gender (1=male, 2=female) are not
shown. The same applies to many oth
16 matches
Mail list logo