[R] grep

Steven Yen @tyen @end|ng |rom ntu@edu@tw
Fri Jul 12 10:54:03 CEST 2024


Below is part a regression printout. How can I use "grep" to identify 
rows headed by variables (first column) with a certain label. In this 
case, I like to find variables containing "somewhath", 
"veryh", "somewhatm", "verym", "somewhatc", "veryc","somewhatl", 
"veryl". The result should be an index 6:13 or 6,7,8,9,10,11,12,13. Note 
that they all contain "somewhat" and "very". Thanks.

est se t p g sig x.1.age 0.0341 0.0138 2.4766 0.0133 -3.8835e-04 ** 
x.1.sleep -0.1108 0.0059 -18.6277 0.0000 -4.4572e-04 *** x.1.primary 
-0.0694 0.0289 -2.4002 0.0164 -9.9638e-06 ** x.1.middle -0.2909 0.0356 
-8.1657 0.0000 -1.4913e-05 *** x.1.high -0.4267 0.0463 -9.2118 0.0000 
-3.6246e-05 *** x.1.somewhath -0.6188 0.0256 -24.1971 0.0000 -3.1337e-05 
*** x.1.veryh -0.7580 0.0331 -22.8695 0.0000 -2.9558e-05 *** 
x.1.somewhatm -0.3413 0.0426 -8.0112 0.0000 -1.8920e-05 *** x.1.verym 
-0.3813 0.0446 -8.5413 0.0000 -4.4029e-05 *** x.1.somewhatc -0.3101 
0.0649 -4.7783 0.0000 -1.4353e-05 *** x.1.veryc -0.2977 0.0648 -4.5910 
0.0000 -4.8986e-05 *** x.1.somewhatl -0.6310 0.0424 -14.8846 0.0000 
-1.9543e-05 *** x.1.veryl -0.9132 0.0462 -19.7525 0.0000 -4.4603e-05 *** 
...

	[[alternative HTML version deleted]]



More information about the R-help mailing list