Changing factor data

This topic contains 2 replies, has 2 voices, and was last updated by  Barbara Pavliakova Walters 2 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9671

    Barbara Pavliakova Walters
    Participant

    My Achievements

    Section completed! IconAnswered a post IconPost published! IconExercise done! IconConcept review passed! IconQuiz completed Icon

    So I did as.numeric(as.factor(data)) on my data, but it didn’t come out right – help!

    #9712

    siddhu25
    Participant

    My Achievements

    Concept review passed! IconExercise set done! IconExercise set done! IconConcept review passed! IconAnswered a post IconPost published! IconExercise done! IconConcept review passed! IconQuiz completed Icon

    Hi Barbara,

    Could you please try below and let me know this is working for you.

    indx <- sapply(data, is.factor)
    data[indx] <- ldply(data[indx], function(x) as.numeric(as.character(x)))

    #10052

    Barbara Pavliakova Walters
    Participant

    My Achievements

    Section completed! IconAnswered a post IconPost published! IconExercise done! IconConcept review passed! IconQuiz completed Icon

    Thank you! That works 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.