[R] is it possible to use R to edit an EXCEL spreadsheet so I can create a searchable EXCEL database of R packages?
John Fox
jfox at mcmaster.ca
Tue Dec 6 02:53:46 CET 2005
Dear Bob,
In my copy of the R FAQ (from the Rgui for Windows), these is no space
between entries which, when copied to a text file, look like:
AMORE
A MORE flexible neural network package, providing the TAO robust neural
network algorithm.
AlgDesign
Algorithmic experimental designs. Calculates exact and approximate
theory experimental designs for D, A, and I criteria.
etc.
For this, the following works:
packages <- readLines("c:/temp/Packages.txt")
packages <- gsub("^\ *", "", gsub("\ *$", "", packages)) # get rid of
leading and trailing blanks
packages <- matrix(packages, ncol=2, byrow=TRUE)
write.table(packages, "c:/temp/Packages2.txt", sep=",",
row.names=FALSE, col.names=FALSE)
Producing a comma-separated text file that can be imported into Excel, and
that looks like:
"AMORE","A MORE flexible neural network package, providing the TAO robust
neural network algorithm."
"AlgDesign","Algorithmic experimental designs. Calculates exact and
approximate theory experimental designs for D, A, and I criteria."
etc.
If you started with blank lines between packages, then (making sure that
there is a blank line after the last package in the input file) you could
adapt this as:
packages <- readLines("c:/temp/Packages.txt")
packages <- gsub("^\ *", "", gsub("\ *$", "", packages))
packages <- matrix(packages, ncol=3, byrow=TRUE)
write.table(packages[,1:2], "c:/temp/Packages2.txt", sep=",",
row.names=FALSE, col.names=FALSE)
I hope this helps,
John
--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Bob Green
> Sent: Monday, December 05, 2005 6:58 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] is it possible to use R to edit an EXCEL
> spreadsheet so I can create a searchable EXCEL database of R packages?
>
> I have copied the R FAQ pertaining to available packages into
> an EXCEL file. They take the following form -
>
> Design
> Regression modeling, testing, estimation, validation,
> graphics, prediction, and typesetting by storing enhanced
> model design attributes in the fit.
> Design is a etc.
>
> Devore5
> Data sets and sample analyses from "Probability and
> Statistics for Engineering and the Sciences (5th ed)" by Jay
> L. Devore, 2000, Duxbury.
>
>
>
> Presently the above format can be represented as:
>
> package name
> package description
> space
>
> I want to change the format so that file name and description are in
> adjacent columns and the space is removed
>
> package name package description
> package name package description
>
>
> Is this possible in R so I can create a searchable EXCEL
> database of R
> packages. I imagine this would be easily carried out using
> PERL though was
> interested to know R's capacity to work on textual data?
>
>
> Any assistance regarding this is appreciated,
>
>
> Bob Green
>
More information about the R-help
mailing list