[R] List of tables needed
David Winsemius
dw|n@em|u@ @end|ng |rom comc@@t@net
Sun Jul 21 04:47:42 CEST 2019
On 7/20/19 5:17 PM, Jackson Rodrigues wrote:
> Dear all,
>
>
> My name is Jackson and I need a help in applying functions to a list of
> tables.
>
>
> Could anyone help me to use loop/array on a list of tables ?
>
> I need to apply a group of functions (listed below) to a list of tables
>
> I am not that good with loops or arrays or multiple functions.
>
> So, could some of you help me ?
I'm not accepting the task of writing out your full project for you, but
instead will offer a game plan:
Steps to take:
-initialize empty lists for each type of input dataset named `in.r`,
`cl` , etc.
#e.g.
in.r <- list()
1) start for loop indexed by: f_n = seq_along(mylist)
2) put your read.table lines inside the for-loop body with the LHS of
the assignment having the list name indexed by the for-loop variable.
#e.g.:
in.r[f_n]=read.table(mylist[f_n], sep="", skip=7, header=F)
# and do learn to use spaces liberally in code
3) terminate the for-loop.
4) in the future use `library()` calls to load whatever packages have
non-base functions (eg, `raster`)
Best of luck;
David
>
>
> mylist <- list.files(full.names = F, pattern =".asc$")
>
> mylist
>
> [1] table1.asc" " table2.asc"
> [3] " table3.asc" " table4.asc "
> [5] " table5.asc "
>
> The <https://www.facebook.com/hashtag/the?source=feed_text&epa=HASHTAG>
> following
> functions should be applied to each table from mylist
>
> ######
>
> in.r=read.table(mylist,sep="",skip=7,header=F)
>
> cl=read.table(mylist,sep="",nrows=1,header=F)
>
> rw=read.table(mylist,sep="",nrows=1,skip=1,header=F)
>
> xll=read.table(mylist,sep="",nrows=1,skip=2,header=F)
>
> yll=read.table(mylist,sep="",nrows=1,skip=3,header=F)
>
> xdim=read.table(mylist,sep="",nrows=1,skip=4,header=F)
>
> ydim=read.table(mylist,sep="",nrows=1,skip=5,header=F)
>
> nd=read.table(mylist,sep="",nrows=1,skip=6,header=F)
>
>
> #Convert
> <https://www.facebook.com/hashtag/convert?source=feed_text&epa=HASHTAG> to
> Raster
>
> in.rr=raster(as.matrix(in.r))
>
> in.rr[in.rr == -9999]=NA
>
> x.max=xll$V2+(xdim$V2*cl$V2)
>
> y.max=yll$V2+(ydim$V2*rw$V2)
>
> extent(in.rr)=c(xll$V2,x.max,yll$V2,y.max)
>
> #################
>
>
> Thank you all in advance.
>
>
> Jackson Rodrigues
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
More information about the R-help
mailing list