[R] unique function works funny
Rolf Turner
r.turner at auckland.ac.nz
Fri Feb 5 04:46:22 CET 2010
FAQ 7.31
cheers,
Rolf Turner
On 5/02/2010, at 4:23 PM, Guochen Song wrote:
> I have 3 nested functions, the core function goes like this:
> listx<-function(x,tox)
> {
> xt=table(x)
> wa=sort(unique(x,fromLast=FALSE))
> print(xt)
> print(wa)
> ......
> return(kk)
>
> }
>
> listx get called in functionB, and functionB get called in functionC.
>
> When I test functionB, the listx function works just fine. When I call
> functionB from functionC, strange thing happened:
> My result for xt:
> 0.07 0.17 0.2
> 1 1 6
> My result for wa:
> 0.07 0.17 0.20 0.20
>
> (my data obviously is 0.2 repeated 8 times, 1 0.17 and 1 0.07). I thought
> it has something to do with the fromLast option, but that does not do a
> thing.
>
> I'm new to R and using R2.10. Any suggestion/idea?
>
> What I want is a vector has the value c(0.07,0.17.0.20). Or is there any
> other way to get that?
>
> I
>
> Thanks in advance,
> GS
>
> [[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.
######################################################################
Attention:
This e-mail message is privileged and confidential. If you are not the
intended recipient please delete the message and notify the sender.
Any views or opinions presented are solely those of the author.
This e-mail has been scanned and cleared by MailMarshal
www.marshalsoftware.com
######################################################################
More information about the R-help
mailing list