A positive correlation between productivity and export market participation has been well documented in producer micro data. Recent empirical studies and theoretical analyses have emphasized that this may reflect the producer's other investment activities, particularly investments in R&D or new technology, that both raise productivity and increase the payoff to exporting. In this paper we develop a dynamic structural model of a producer's decision to invest in R&D and participate in the export market. The investment decisions depend on the expected future profitability and the fixed and sunk costs incurred with each activity. We estimate the model using plant-level data from the Taiwanese electronics industry and find a complex set of interactions between R&D, exporting, and productivity. The self-selection of high productivity plants is the dominant channel driving participation in the export market and R&D investment. Both R&D and exporting have a positive direct effect on the plant's future productivity which reinforces the selection effect. When modeled as discrete decisions, the productivity effect of R&D is larger, but, because of its higher cost, is undertaken by fewer plants than exporting. The impact of each activity on the net returns to the other are quantitatively unimportant. In model simulations, the endogenous choice of R&D and exporting generates average productivity that is 22.0 percent higher after 10 years than an environment where productivity evolution is not affected by plant investments.