[R] Readxl Question

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Sat Dec 21 07:26:26 CET 2019


Hi Thomas,
Perhaps this is what you are seeking:

my_read_excel<-function(filename) {
 serials<-read_excel(filename,sheet="Flow Data",range=("c6"))
 flow.data<-read_excel(filename,sheet="Flow Data",range=("c22:c70"))
 dates<-read_excel(filename,sheet="Flow Data",range=("h14"))
 return(data.frame(Serial=rep(serials,49),Date=rep(dates,49),
  Flow=flow.data),stringsAsFactors=FALSE)
}
lapply(files,my_read_excel)

Should return a list of data frames in the format you want. If you
want just one big data frame, rbind the results. You should also be
able to convert the dates from character to date type without striking
the factor problem.

Jim

On Sat, Dec 21, 2019 at 4:16 AM Thomas Subia <tsubia using imgprecision.com> wrote:
>
> Colleagues,
>
> The objective is to create a text file having this format:
>
> Serial  Date    Flow
>



More information about the R-help mailing list