plyr


Error in Changing Factors with PLYR in R


for the purposes of GLM modeling, I am trying to change the qualitative values for a variable to quantitative "dummy" variables. For this exercise, I am using Plyr, which seems incredibly intuitive over base R.
str(data$Socks)
$ Socks : Factor w/ 4 levels "1+","2+","4+","8+" ..: 1 4 4 1 4 4 1 4 1 1 ...
levels(data$Socks)
[1] "1" "2+" "4+" "8+"
library(dplyr)
select(data, Socks)
2 8+
3 8+
4 1
5 8+
When I try to change the levels, every factor but 1 is changed to an "NA".
data <- data %>% mutate(Socks = factor(Socks, levels = c(1, 2, 4, 8)))
select(data, Socks)
990 1
991 <NA>
992 1
993 <NA>
I would like the values "1","2+","4+","8+" to change to "1", "2", "4", "8".
Any help would be appreciated. Thank you!

Related Links

Likelihood over subgroups
Error in Changing Factors with PLYR in R
Frequency table in R
Installation of plyr in R on Ubuntu does not work
Issue installing library(plyr) in R (Windows)

Categories

HOME
artificial-intelligence
android-espresso
class
generics
seedstack
bokeh
adobe
iverilog
ipv6
javafx-8
timber
roku
xamarin-zebble
rangy
jquery-select2-4
powermock
distributed-computing
uima
scala-ide
susy-sass
data-type-conversion
anova
kaggle
animated-gif
nurbs
morris.js
clipboard
uilocalnotification
react-bootstrap-table
guice
python-2.x
xcrun
serversocket
devtools
restful-architecture
java-stream
rails-postgresql
buildforge
assertions
xvfb
code-rally
mv
hidden-markov-models
jqgrid-asp.net
sendinput
type-inference
vesta
libreoffice-writer
supertest
scala-breeze
sonicmq
phppgadmin
winston
palindrome
yargs
java-2d
livereload
livecycle
gcloud-node
between
deferred-rendering
verisign
persistent-object-store
teamviewer
vimperator
flush
myfaces
boost-proto
msgpack
ibm-was
mixins
gql
textscan
tree-structure
quercus
scala-swing
findersync
mod-auth-openidc
createfile
flurry-analytics
qt5.4
oracle-adf-mobile
nidaqmx
libgcc
two.js
pageviews
spring-social-linkedin
cloo
illuminate-container
acceptance-testing
blobstorage
dibs
oembed
cyrillic
dojo-1.9
ip-geolocation
gitx
getproperty
arrow
thejit
memory-pool
django-apps
differentiation
qtextbrowser
getopts
fork-join
3des
multiple-users
pinax
google-translator-toolkit
rawcontacts
ppc
jquery-effects
ntruencrypt
webclient.uploaddata
parentid

Resources

Encrypt Message