[R] help using code

John Kane jrkrideau at inbox.com
Wed Jun 12 15:47:49 CEST 2013


Have a look at http://www.burns-stat.com/documents/tutorials/impatient-r/ . I think the section on blank screen syndrome may help.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: montana3946 at gmail.com
> Sent: Tue, 11 Jun 2013 16:59:34 -0700
> To: ruipbarradas at sapo.pt
> Subject: Re: [R] help using code
> 
> Hello,
> 
> Thanks for the help!
> 
> Your answer resolved my problem with the function I listed, but brought
> up
> a larger question. How is the output of the importdata function stored
> for
> use with other functions (as in, how do I call on that data for use with
> other functions)? As a simple example I have another function:
> 
> meanXY = function(xyzuvw) {
> 	xy = c(mean(xyzuvw$x), mean(xyzuvw$y))
> 	return(xy)
> }
> 
> I know that the xyzuvw portion is referring to the output of the
> importdata function, but I don't know how to call up the necessary data
> (hope this makes sense).
> 
> Thanks again for the help!
> 
> John
> 
> 
> 
> 
> On 6/11/13 3:05 PM, "Rui Barradas" <ruipbarradas at sapo.pt> wrote:
> 
> >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.
>>> 
> 
> ______________________________________________
> 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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!



More information about the R-help mailing list