[R] help using code

Rui Barradas ruipbarradas at sapo.pt
Wed Jun 12 00:05:26 CEST 2013


Hello,

I believe you are making a confusion on how to call a function in R. You 
don't replace the argument in the function declaration. what you do is 
to call the function like this:

importdata("~/path to/filename.xyzuvwrgb")

leaving the function definition alone.

Hope this helps,

Rui Barradas

Em 11-06-2013 19:52, John McDermott escreveu:
> Hi R-helpers,
>
> I inherited some code that I'm trying to use. As a very new R user I'm
> having some confusion.
>
> I have some input files in the form: filename.xyzuvwrgb which I'm trying to
> import using:
>
> importdata = function(filename) {
>
>      p = scan(filename,what=list(x = double(), y = double(), z = double(), u
> = double(),v=double(),w=double()),skip=1,flush=TRUE,sep=" ")
>
>      return(data.frame(x=p$x, y=p$y, z=p$z, u=p$u, v=p$v, w=p$w))
>
> }
>
>
>
> For the filename I replaced both with "~/path to/filename.xyzuvwrgb" and I
> get the following errors:
>
>
>
> Error: unexpected string constant in "importdata =
> function("~/Desktop/thrustScarp1.xyzuvw""
>
>
>
> Error: no function to return from, jumping to top level
>
>
>
> Error: unexpected '}' in "}"
>
>
>
> I'm assuming it has to do with how I am using/formatted the
> function(filename) portion. How can I get this to work?
>
>
>
> Thanks for the help!
>
>
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list