Thank you so much, I'm humbled by the response from such great authors and
scholars. I thought I would share the final version that worked perfectly
in my illustrative example, as well as the real one.
My main confusion was this part:
db1$olditems[db1$olditems=='']
[1]
Levels: nuts soup
I
# Just when I thought I had the basic stuff mastered
# This has been quite perplexing, thanks for any help
## Here's the example:
db1=data.frame(
olditems=c('soup','','','','nuts'),
prices=c(4.45, 3.25, 4.42, 2.25, 3.98))
db2=data.frame(
On Tue, Jul 21, 2009 at 7:39 PM, Gene Leynesgleyne...@gmail.com wrote:
# Just when I thought I had the basic stuff mastered
# This has been quite perplexing, thanks for any help
## Here's the example:
db1=data.frame(
olditems=c('soup','','','','nuts'),
prices=c(4.45, 3.25, 4.42,
Notice that three items are returned where you thought one was:
[1] FALSE TRUE TRUE TRUE FALSE
db1$olditems[db1$olditems==''] #wait, only one item is returned?
[1]
Levels: nuts soup
db1[db1$olditems=='',] #somehow this works!
olditems prices
23.25
34.42
4
Couple of points:
1. if you are going to be replacing entries in factors with updated levels,
it's probably easier if you start with your strings remaining as strings as
they go into the data frames. So here is how I would start your example
db1 - data.frame(
olditems =
On 22/07/2009, at 1:21 PM, jim holtman wrote:
Notice that three items are returned where you thought one was:
[1] FALSE TRUE TRUE TRUE FALSE
db1$olditems[db1$olditems==''] #wait, only one item is returned?
[1]
Levels: nuts soup
db1[db1$olditems=='',] #somehow this works!
olditems
6 matches
Mail list logo