Dear R Forum I have a data frame as
beta_results = data.frame(instrument = c("ABC", "DEF", "JKL", "LMN", "PQR", "STU", "UVW", "XYZ"), beta_values = c(1.27, -0.22, 0.529, 0.011, 2.31, -1.08, -2.7, 0.42)) > beta_results instrument beta_values 1 ABC 1.270 2 DEF -0.220 3 JKL 0.529 4 LMN 0.011 5 PQR 2.310 6 STU -1.080 7 UVW -2.700 8 XYZ 0.420 Through some other process, I am getting instrument names as say (which may change each time I run this process and hence I can't hard code it). instru = c("JKL", "STU", "XYZ") Now I want the subset of beta_results, (say beta_results_A) pertaining to only instru i.e beta_results_A = instrument beta_values 3 JKL 0.529 6 STU -1.080 8 XYZ 0.420 I did try beta_results_A = beta_results[instru] or beta_results_A = subset(beta_results, beta_results$instrument = instru] but I guess it's failing. Kindly guide Regards Katherine [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.