0

I have an FFDF object that I'd like to create dummy variables in. Specifically, I have a separate vector of names and I want to make dummy variables if a name in that vector matches a name I have in a column vector in my FFDF.

As an example, suppose I had this vector and this FFDF object:

Name
1. Blow, Joe
2. Smith, John
3. Jones, Tom 
etc....

DonorName     CandidateName DonationAmount CandidateParty
1   blow joe Bush, George W          3,000     Republican
2   guy some  Obama, Barack          5,000       Democrat
3 smith john    Reid, Harry          4,000       Democrat

What I'd like to do is create a separate column in the FFDF file and make it a 1 if a name in "Name" matches a name in "DonorName." Normally, I could use an ifelse() command, but the ff version, (ffifelse) is giving me this error: "test needs to be a logical/boolean ff vector." I should also add that I've coerced the first vector into an ffdf object using the as.ffdf() command.

EDIT:

I think I may finally have it working. This line of code seemed to do the trick.

    ffdfobject$colname <- ffifelse(ffdfobject$DonorName %in% otherffdfobj$name, 1,0)
pnuts
  • 58,317
  • 11
  • 87
  • 139
ModalBro
  • 544
  • 5
  • 25
  • 1
    What is an `ffdf` object/file? – MrFlick May 28 '14 at 20:54
  • A dataframe imported using the ff package. It's good for large files that would otherwise be too big to load normally. Here's the documentation: http://cran.r-project.org/web/packages/ff/index.html – ModalBro May 28 '14 at 22:23
  • IMHO out-of-ram contact is much better managed via `SQL` type. These database formats are also fully compatible with `dplyr` manipulations such as: `keepers <- gsub(", "," ",tolower(first$Name),fixed=TRUE)` and `second %>% mutate(flag = as.integer(DonorName %in% keepers))` – npjc May 29 '14 at 00:20
  • Can you edit the question to include the `ffifelse()` statement you tried to run? – MrFlick May 29 '14 at 00:24

0 Answers0