[R] loading data from a specified directory
Sam McClatchie
s.mcclatchie at niwa.co.nz
Mon Sep 9 05:46:53 CEST 2002
System info:
Linux slackware
R Version 1.5.1 (2002-06-17)
ESS 5.1.21
Emacs 21.2.1
-------------------
Colleagues
I have some text files in a certain directory and want to process them
sequentially. So I want to pass the filename identifier into a function
and loop through the processing of each file in turn.I've called the
file identifier f in this code segment:
image.dvm <- function (horiz.slice.int=2, ping.int=3,
start.h=3, start.min=4,
max.z=800, f=350:372)
{
## Purpose: to display the whole echogram integrals for consecutive CREST
## files to illustrate patterns of diel vertical migration
## ----------------------------------------------------------------------
## Arguments:
## ----------------------------------------------------------------------
## Author: Sam McClatchie, Date: 6 Sep 2002, 12:02
for (i in 1:length(f))
paste("t.",f[1], sep="")
<-read.table(paste("/home/smc/manuscripts/mesopelagic_fish/biomass_spectrum/we0000",f[1],sep=""),
header=F)
-----------------
There is nothing wrong with the text files because I can read them
correctly with:
> t.350 <- read.table('we0000350', header=F)
> t.350[1:5,1:4]
V1 V2 V3 V4
1 0.00000e+00 0.0000e+00 0.0000e+00 0.00000e+00
2 0.00000e+00 0.0000e+00 0.0000e+00 0.00000e+00
3 0.00000e+00 0.0000e+00 0.0000e+00 0.00000e+00
4 0.00000e+00 0.0000e+00 0.0000e+00 0.00000e+00
5 8.71053e-05 4.2294e-05 3.6614e-05 6.68651e-05
>
However, running the code segment above gives an error that has me a
little bemused:
> image.dvm()
Error in image.dvm() : Target of assignment expands to non-language object
>
I guess I'm doing something illegal with the paste command?
paste("t.",f[1], sep="") <- read.table....
Can you help, please?
Sam
--
Sam McClatchie, Research scientist (fisheries acoustics))))))))))
NIWA (National Institute of Water & Atmospheric Research Ltd)
PO Box 14 901, Kilbirnie, Wellington, New Zealand
s.mcclatchie at niwa.cri.nz
Research home page <http://www.smcc.150m.com/>
/\
>><xX(&>
/// \\\
//// \\\\
/// <%)Xx><<
///// \\\\\\
><(((@>
><(((%> ..>><xX(?>O<?)Xx><<
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list