Comments (5)
PS: I corrected a typo in my post. With the typo there was no error. Now, there is the error.
from memisc.
This is not a bug, but a feature. Values equal to 0
are translated into NA
by as.character()
because 0
is marked as a missing value. Such an automatic translation into NA
is the whole point of the "item"
class, because otherwise there is no way in R to distinguish between "non-NA" missing values and NA
.
If you want to retain "PNR" as a valid factor level, you have to declare 0
as valid.
E.g. by
missing.values(foo) <- NULL
bar <- as.factor(foo)
bar <- relevel(bar, 'PNR')
or
valid.values(foo) <- -1:1
bar <- as.factor(foo)
bar <- relevel(bar, 'PNR')
or
bar <- as.factor(include.missings(foo))
bar <- relevel(bar, 'PNR')
If in earlier versions of memisc as.character()
did not take into account the missingness status of certain values then that was a bug.
from memisc.
Well, this is a pity because this "bug" was really convenient: it allowed me to run regressions without dropping data ('PNR' were considered as a response category, which it is) while allowing me to treat these 'PNR' as missing in the analysis (i.e. have
a special status for descriptive stats, graphs...).
So I'll keep using memisc 0.99.22 which does exactly what I need.
from memisc.
I think
bar <- as.factor(as.character(include.missings(foo)))
or
bar <- as.factor(as.character(foo,include.missings=TRUE))
will do what you want it to do with newer versions of memisc.
from memisc.
In this particular case, yes, because I convert the variable in a factor anyway. But I noticed other parts of the code where the update causes issues, namely regressions. I'd need to transform each item variable to a factor in my regressions with the new memisc version. Easier (and more compact code) to keep the old one.
from memisc.
Related Issues (20)
- summary.stats.default is unused HOT 1
- Fails to import variable with duplicate labels HOT 13
- Measure info and Custom Attributes HOT 2
- Probable issue with record length HOT 16
- Saving files to XLSX HOT 2
- Exhibit odds ration in the regression estimates table [question] HOT 2
- library(memisc) causes functions to print NAMESPACE cache information HOT 9
- Issue with new version of spss.system.file HOT 9
- Error when generating codebook HOT 8
- write_html error HOT 1
- deduplicate_labels() is painfully slow on large datasets HOT 2
- mtable() summary.stats not showing R-squared HOT 1
- unable to read spss HOT 1
- `cases` function won't recognize conditions involving `is.na()` HOT 1
- spss.fixed.file() dropping final observation HOT 4
- CRAN Update Request HOT 1
- Can you send me /memisc.0.99.22? HOT 2
- Error when missing.values="" HOT 7
- GPL-3 licensed code mixed with GPL-2 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memisc.