Marshall Feldman
2010-Apr-19 16:27 UTC
[R] Identifying names of matrix columns shared by many matrices
Greetings R-Geniuses, What is the most efficient way to handle the problem described below? Thanks Marsh Feldman Problem description: Each U.S. state has its own matrix. The rows are dates, the columns are industries, and each cell contains total statewide employment at the given time and industry. There is a similar matrix for the U.S. as a whole. Due to disclosure rules and other limitations, one or more industries may be missing from any given matrix (including the national one), but industries missing from one matrix are sometimes not missing from others. Industry numbers are treated as factors commonly used as column names. I want to do two things: 1. For any given set of states, find the set of industries present in all of them and use this to select this subset of industries from each state's matrix. 2. For any given set of states, find the set of industries present in any of the states. 3. Given that one or more cells in the table may be NA, identify those industries present in all states and have no values equal to NA. I can do this using for() statements and %in%, but is there is a more efficient way? Your thoughts? [[alternative HTML version deleted]]