There are three routes you can take:

1) Use a chip that measures the real and apparent power. You can probably get Vrms and Irms as well. SPI or I2C communications are likely necessary, but the chip will likely also generate a pulse for each unit of energy (example: 1 Watt x Sec) and a direction. Direction is which way power is flowing (to or from load). Increment or decrement the pulse sum depending on the direction. A highly reactive load will generate lots of energy pulses, but the direction will cause most of them to be averaged out. A resistive load will always have the same direction.

Divide Ptrue by Papparent to get Power Factor.

2) Write code to take lots of V and I measurements across a single cycle. Interleave the V and I measurements. Think >16 pairs of V and I measurements per cycle.
(This is a good point to measure frequency.)

2A) Compute the RMS values for V and I across a cycle. Here's how:
Square each V and I, add to sum for one second (Vsum, Isum).
At end of second, compute the square root of Vsum and Isum to get the RMS values Vrms and Irms.
Multiply Vrms anf Irms to get apparent power (Papparent).
(Vrms and Irms can be reported as the voltage and current measurements that a meter would indicate.)

2B) For each pair of V and I measurements, multiply them to get instantaneous power (I can be negative in reactive loads, so power may be negative). Sum instantanious powers across a cycle to get true power (Ptrue).

Divide Ptrue by Papparent to get Power Factor.

3) Hack a Kill-A-Watt. This may be very similar to #1 above.

P.S. I wrote "AN220 - Watt-Hour Meter using PIC16C923 and CS5460"