I have a data frame, wherein I've created new variables (which are 'cleaned' versions of the originals). When I subset the data frame, these new variables don't seem to be in the subsetted data frame. Do I need to create these new variables again? Or is there a way to ensure that they are in the subsetted data frame.
A little more detail: I have 'attach'-ed a data frame 'x'.
newdf <- subset (x, (income %in% c('<20000')))
(Income is cleaned version of another variable, and is a factor variable.) So the new data frame should contain only those with income less than 20000.
This seems to work, and does, indeed give me a new data frame with the correct number of observations.
However, when I try to do
freq (newdf$income)
I get:
Error in plot.window(xlim, ylim, log = log, ...) : need finite 'xlim' values In addition: Warning messages: 1: In min(w.l) : no non-missing arguments to min; returning Inf 2: In max(w.r) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf
Thanks!
dput(head(data, 20))
. And sample code, like this it's impossible for anyone to help you. – Rui Barradas