Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3609308
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:36:39+00:00 2026-05-18T21:36:39+00:00

As usual, I got some SPSS file that I’ve imported into R with spss.get

  • 0

As usual, I got some SPSS file that I’ve imported into R with spss.get function from Hmisc package. I’m bothered with labelled class that Hmisc::spss.get adds to all variables in data.frame, hence want to remove it.

labelled class gives me headaches when I try to run ggplot or even when I want to do some menial analysis! One solution would be to remove labelled class from each variable in data.frame. How can I do that? Is that possible at all? If not, what are my other options?

I really want to bypass reediting variables “from scratch” with as.data.frame(lapply(x, as.numeric)) and as.character where applicable… And I certainly don’t want to run SPSS and remove labels manually (don’t like SPSS, nor care to install it)!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:36:40+00:00Added an answer on May 18, 2026 at 9:36 pm

    A belated note/warning regarding class membership in R objects. The correct method for identification of "labelled" is not to test for with an is function or equality {==) but rather with inherits. Methods that test for a specific location will not pick up cases where the order of existing classes are not the ones assumed.

    You can avoid creating "labelled" variables in spss.get with the argument: , use.value.labels=FALSE.

    w <- spss.get('/tmp/my.sav', use.value.labels=FALSE, datevars=c('birthdate','deathdate'))
    

    The code from Bhattacharya could fail if the class of the labelled vector were simply "labelled" rather than c("labelled", "factor") in which case it should have been:

    class(x[[i]]) <- NULL  # no error from assignment of empty vector
    

    The error you report can be reproduced with this code:

    > b <- 4:6
    > label(b) <- 'B Label'
    > str(b)
    Class 'labelled'  atomic [1:3] 4 5 6
      ..- attr(*, "label")= chr "B Label"
    > class(b) <- class(b)[-1]
    Error in class(b) <- class(b)[-1] : 
      invalid replacement object to be a class string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IE6+ got some problems with transition as usual but i know ways to get
We've got a new server with TFS installed. The current environment is very usual,
The usual way to resolve lnk involve using WShell.WshShortcut or IShellLink that way :
as usual I'm working with my messed up database and I found that there
I've got a custom CalloutButton component in a package called uiComponents. This custom CallOutButton
hey there - I'm trying to use asp.net mvc for some things as usual,
I've got a table and it's looking alike that: First I don't know how
Actually i got a Gallery that shows my drawables and shows the item selected
Blast from the past... Got tasked to mange an aging Access 2000 adp used
I'm having some trouble, as usual, with making my html and jquery work on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.