Trying to merge data frames but I get ""No data available in the table."

I have two dataframes, formatted as follows:

County    RUCC_2013
Alameda   1
Alpine    8
Amador    6

and

County   Year    RUCC
Alameda  2000    1
Alameda  2001    1
Alameda  2002    1
Alpine   2000    8
Alpine   2001    8
Alpine   2002    8
Amador   2000    6
Amador   2001    6
Amador   2002    6

I originally tried to merge them using
df <- merge(df1, df2, by = 'County')
but I get the aforementioned No data available in the table. I then tried to hand code it by:
df[df$County==c("Alameda", "Amador", "Alpine), RUCC] <- 1
but then I got Error in x[[jj]] :
attempt to select less than one element in get1index
In addition: Warning message:
In ca1$County == c("Alameda", "Contra Costa", "El Dorado", "Los Angeles", :
longer object length is not a multiple of shorter object length

Is there an alternative that is better?

First, the initial command should work (though I suspect it won't do what you want it to do)

Second,

No data available in the table.

is not, to the best of my knowledge, an error message the merge() function (or any other function in R) throws. In fact, a Google search for the terms,

"no data available in the table" merge

yielded 7 results (including this question).

Lastly, your second attempt will definitely fail for a few reasons.

  1. You are trying to subset a df object before creating it.
  2. Even if df existed, you are trying to access a column RUCC, but you didn't put it in quotes, so unless you have an object in your environment named RUCC, you'd get an error about it not being found.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.