[R] grep fixed (?) in 2.14

2011-11-03 Thread Stephen Sefick
#This is probably due to my incomplete understanding of grep, but the 
below code has been working for some time to
#search for .R with anything in front of it and return a list of scripts 
to source.  Likely, the syntax for the

#grep statement has been wrong all along.

scripts2source - (c(/home/ssefick/R_scripts/Convert_package.R, 
/home/ssefick/R_scripts/Convert_R_CODE,

/home/ssefick/R_scripts/CV.R, /home/ssefick/R_scripts/cvs.out.R,
/home/ssefick/R_scripts/database_connect, 
/home/ssefick/R_scripts/database_connect_package.R,

/home/ssefick/R_scripts/exit_db.R, /home/ssefick/R_scripts/exit.R,
/home/ssefick/R_scripts/hourly_zoo.R, 
/home/ssefick/R_scripts/model_diag.R,
/home/ssefick/R_scripts/not_numeric.R, 
/home/ssefick/R_scripts/num_ecol_package.R,
/home/ssefick/R_scripts/NumEcolR_scripts, 
/home/ssefick/R_scripts/old_scripts_DELETE_AFTER_DECEMBER,
/home/ssefick/R_scripts/only_numeric_dataframe.R, 
/home/ssefick/R_scripts/only_numeric.R,
/home/ssefick/R_scripts/PCA.ve.R, 
/home/ssefick/R_scripts/poster_ggplot2_theme.R,
/home/ssefick/R_scripts/pressure_transducer_package.R, 
/home/ssefick/R_scripts/Pressure_Transducer_R_CODE,
/home/ssefick/R_scripts/publication_ggplot2_theme.R, 
/home/ssefick/R_scripts/r2test.R,
/home/ssefick/R_scripts/recession_constant_package.R, 
/home/ssefick/R_scripts/recession_constant_R_CODE,
/home/ssefick/R_scripts/serdp_name_split.R, 
/home/ssefick/R_scripts/setup_R.R,

/home/ssefick/R_scripts/USGS.R))

scripts2source[grep(*.R, scripts2source)]

#here is my problem;  I would like these to be removed.
scripts2source[c(2,5,13,14,20,24)]

#Thanks for all of your help in advance
#kindest regards,

#Stephen Sefick

__
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.


Re: [R] grep fixed (?) in 2.14

2011-11-03 Thread Sarah Goslee
Hi,

. and * both mean something different in regular expressions than in
command-line wildcards. You need:

grep(.*\\.R$, scripts2source)

which parses to
.- any character
*- any number of times
\\.  - an actual . escaped as R requires
R  - the R denoting a script
$  - at the end of the string

 grep(.*\\.R$, scripts2source)
 [1]  1  3  4  6  7  8  9 10 11 12 15 16 17 18 19 21 22 23 25 26 27

Sarah

On Thu, Nov 3, 2011 at 8:54 AM, Stephen Sefick sas0...@auburn.edu wrote:
 #This is probably due to my incomplete understanding of grep, but the below
 code has been working for some time to
 #search for .R with anything in front of it and return a list of scripts to
 source.  Likely, the syntax for the
 #grep statement has been wrong all along.

 scripts2source - (c(/home/ssefick/R_scripts/Convert_package.R,
 /home/ssefick/R_scripts/Convert_R_CODE,
 /home/ssefick/R_scripts/CV.R, /home/ssefick/R_scripts/cvs.out.R,
 /home/ssefick/R_scripts/database_connect,
 /home/ssefick/R_scripts/database_connect_package.R,
 /home/ssefick/R_scripts/exit_db.R, /home/ssefick/R_scripts/exit.R,
 /home/ssefick/R_scripts/hourly_zoo.R,
 /home/ssefick/R_scripts/model_diag.R,
 /home/ssefick/R_scripts/not_numeric.R,
 /home/ssefick/R_scripts/num_ecol_package.R,
 /home/ssefick/R_scripts/NumEcolR_scripts,
 /home/ssefick/R_scripts/old_scripts_DELETE_AFTER_DECEMBER,
 /home/ssefick/R_scripts/only_numeric_dataframe.R,
 /home/ssefick/R_scripts/only_numeric.R,
 /home/ssefick/R_scripts/PCA.ve.R,
 /home/ssefick/R_scripts/poster_ggplot2_theme.R,
 /home/ssefick/R_scripts/pressure_transducer_package.R,
 /home/ssefick/R_scripts/Pressure_Transducer_R_CODE,
 /home/ssefick/R_scripts/publication_ggplot2_theme.R,
 /home/ssefick/R_scripts/r2test.R,
 /home/ssefick/R_scripts/recession_constant_package.R,
 /home/ssefick/R_scripts/recession_constant_R_CODE,
 /home/ssefick/R_scripts/serdp_name_split.R,
 /home/ssefick/R_scripts/setup_R.R,
 /home/ssefick/R_scripts/USGS.R))

 scripts2source[grep(*.R, scripts2source)]

 #here is my problem;  I would like these to be removed.
 scripts2source[c(2,5,13,14,20,24)]

 #Thanks for all of your help in advance
 #kindest regards,

 #Stephen Sefick

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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.


Re: [R] grep fixed (?) in 2.14

2011-11-03 Thread jim holtman
your syntax is wrong, you need:

 scripts2source[grep(*\\.R$, scripts2source)]

Notice the '\\.' to escape the special meaning of '.', and the $ to
anchor to the end of the line.


On Thu, Nov 3, 2011 at 8:54 AM, Stephen Sefick sas0...@auburn.edu wrote:
 #This is probably due to my incomplete understanding of grep, but the below
 code has been working for some time to
 #search for .R with anything in front of it and return a list of scripts to
 source.  Likely, the syntax for the
 #grep statement has been wrong all along.

 scripts2source - (c(/home/ssefick/R_scripts/Convert_package.R,
 /home/ssefick/R_scripts/Convert_R_CODE,
 /home/ssefick/R_scripts/CV.R, /home/ssefick/R_scripts/cvs.out.R,
 /home/ssefick/R_scripts/database_connect,
 /home/ssefick/R_scripts/database_connect_package.R,
 /home/ssefick/R_scripts/exit_db.R, /home/ssefick/R_scripts/exit.R,
 /home/ssefick/R_scripts/hourly_zoo.R,
 /home/ssefick/R_scripts/model_diag.R,
 /home/ssefick/R_scripts/not_numeric.R,
 /home/ssefick/R_scripts/num_ecol_package.R,
 /home/ssefick/R_scripts/NumEcolR_scripts,
 /home/ssefick/R_scripts/old_scripts_DELETE_AFTER_DECEMBER,
 /home/ssefick/R_scripts/only_numeric_dataframe.R,
 /home/ssefick/R_scripts/only_numeric.R,
 /home/ssefick/R_scripts/PCA.ve.R,
 /home/ssefick/R_scripts/poster_ggplot2_theme.R,
 /home/ssefick/R_scripts/pressure_transducer_package.R,
 /home/ssefick/R_scripts/Pressure_Transducer_R_CODE,
 /home/ssefick/R_scripts/publication_ggplot2_theme.R,
 /home/ssefick/R_scripts/r2test.R,
 /home/ssefick/R_scripts/recession_constant_package.R,
 /home/ssefick/R_scripts/recession_constant_R_CODE,
 /home/ssefick/R_scripts/serdp_name_split.R,
 /home/ssefick/R_scripts/setup_R.R,
 /home/ssefick/R_scripts/USGS.R))

 scripts2source[grep(*.R, scripts2source)]

 #here is my problem;  I would like these to be removed.
 scripts2source[c(2,5,13,14,20,24)]

 #Thanks for all of your help in advance
 #kindest regards,

 #Stephen Sefick

 __
 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.




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
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.


Re: [R] grep fixed (?) in 2.14

2011-11-03 Thread Stephen Sefick
That did the trick.  I have read about regular expressions often, and 
sometimes I get them right and sometimes I don't.  Is there a good 
reference resource that anyone could suggest?  Thanks for all of the help.


Stephen Sefick



On 11/03/2011 08:03 AM, jim holtman wrote:

your syntax is wrong, you need:

  scripts2source[grep(*\\.R$, scripts2source)]

Notice the '\\.' to escape the special meaning of '.', and the $ to
anchor to the end of the line.


On Thu, Nov 3, 2011 at 8:54 AM, Stephen Seficksas0...@auburn.edu  wrote:

#This is probably due to my incomplete understanding of grep, but the below
code has been working for some time to
#search for .R with anything in front of it and return a list of scripts to
source.  Likely, the syntax for the
#grep statement has been wrong all along.

scripts2source- (c(/home/ssefick/R_scripts/Convert_package.R,
/home/ssefick/R_scripts/Convert_R_CODE,
/home/ssefick/R_scripts/CV.R, /home/ssefick/R_scripts/cvs.out.R,
/home/ssefick/R_scripts/database_connect,
/home/ssefick/R_scripts/database_connect_package.R,
/home/ssefick/R_scripts/exit_db.R, /home/ssefick/R_scripts/exit.R,
/home/ssefick/R_scripts/hourly_zoo.R,
/home/ssefick/R_scripts/model_diag.R,
/home/ssefick/R_scripts/not_numeric.R,
/home/ssefick/R_scripts/num_ecol_package.R,
/home/ssefick/R_scripts/NumEcolR_scripts,
/home/ssefick/R_scripts/old_scripts_DELETE_AFTER_DECEMBER,
/home/ssefick/R_scripts/only_numeric_dataframe.R,
/home/ssefick/R_scripts/only_numeric.R,
/home/ssefick/R_scripts/PCA.ve.R,
/home/ssefick/R_scripts/poster_ggplot2_theme.R,
/home/ssefick/R_scripts/pressure_transducer_package.R,
/home/ssefick/R_scripts/Pressure_Transducer_R_CODE,
/home/ssefick/R_scripts/publication_ggplot2_theme.R,
/home/ssefick/R_scripts/r2test.R,
/home/ssefick/R_scripts/recession_constant_package.R,
/home/ssefick/R_scripts/recession_constant_R_CODE,
/home/ssefick/R_scripts/serdp_name_split.R,
/home/ssefick/R_scripts/setup_R.R,
/home/ssefick/R_scripts/USGS.R))

scripts2source[grep(*.R, scripts2source)]

#here is my problem;  I would like these to be removed.
scripts2source[c(2,5,13,14,20,24)]

#Thanks for all of your help in advance
#kindest regards,

#Stephen Sefick

__
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.






__
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.