Thanks Jim, that's worked

On 24 January 2012 00:49, jholtman [via R] <
ml-node+s789695n4320727...@n4.nabble.com> wrote:

> If 'idh' is the set of indices resulting from the 'split', then your
> function would probably have to look like this:
>
> myfun <- function(x){
> H.scv <- Hscv(data[x, ], pilot = "unconstr")
> KDE <- kde(data[x, ], H=H.scv, approx.cont=TRUE)
> }
>
> This is based on your original example where 'data' was the object
> name of your data.  You want to use the indices to access the relavent
> rows in your data.  Not sure what your function is supposed to be
> returning; right now it return the last value which would be the
> result of the call to 'kde'.  If you want both results returned, then
> the last statement should possibly be:
>
> list(H.scv, KDE)
>
> which will return the values in a list that you can then extract from.
>
> On Mon, Jan 23, 2012 at 1:14 AM, kalee <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4320727&i=0>>
> wrote:
>
> > Thanks Jim for your reply. I've split the dataset into indices but am
> now
> > having problem with my function. The function I need to use is in two
> parts:
> >
> >> H.scv <- Hscv(idh, pilot = "unconstr") ## commands from the ks package
> >>
> >> KDE <- kde(idh, H=H.scv, approx.cont=TRUE)
> >
> > I've tried to write these as a function separately to be applied within
> the
> > sapply():
> >
> > myfun <- function(x){
> > H.scv <- Hscv(idh, pilot = "unconstr")
> > KDE <- kde(idh, H=H.scv, approx.cont=TRUE)
> > }
> >
> > HR <- sapply(idh, myfun)
> >
> > However, the first part of my function (H.scv) doesn't recognise the idh
> > (when applied within the sappily or on its own). Is there anyway to
> write
> > the code so that it would recognise each indices? I.e ID = 1, day =1,
> hour
> > =0 so indices number is 1.1.0 and then H.scv would be Hscv(1.1.0, pilot
> =
> > "unconstr")?
> >
> > Basically I need to be able to use the Hscv and kde test for each hour
> of
> > each day for each ID that I have and can't get the tests (functions) to
> > recognise the input at the moment (Hscv input must be a vector or
> matrix).
> >
> > Thanks,
> > Kate
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/converting-a-for-loop-into-a-foreach-loop-tp4309646p4319971.html
>
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > [hidden email] 
> > <http://user/SendEmail.jtp?type=node&node=4320727&i=1>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.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4320727&i=2>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.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/converting-a-for-loop-into-a-foreach-loop-tp4309646p4320727.html
>  To unsubscribe from converting a for loop into a foreach loop, click 
> here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4309646&code=a2F0aHJ5bi5sZWUxQHN0dWRlbnRzLm1xLmVkdS5hdXw0MzA5NjQ2fDEyNjgzMDQ0NjY=>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Kate Lee
PhD candidate
Marine Mammal Research Group
Graduate School of Environment
MACQUARIE UNIVERSITY NSW 2109

Phone: +61 (0)2 9850 7980
www.mq.edu.au

CRICOS Provider No 00002J

This message is intended for the addressee named and may...{{dropped:13}}

______________________________________________
R-help@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.

Reply via email to