Hi Jeff,
Thanks for your reply. What do you exactly mean by "interactively"?
Would
you please give me an example?
Upananda
On Mon, Feb 6, 2023 at 1:27 AM Jeff Newmiller <jdnewmil at
dcn.davis.ca.us>
wrote:
> No, it means what it says: it is best used interactively rather than in
> functions. That is not saying you cannot use it... merely that you should
> probably use it interactively.
>
> The fact is, though, that integer indexing is much simpler and clearer for
> your particular example than subset is.
>
> q <- p[1:20]
> q2 <- subset( p, 1:100 <= 20) # 1:100 are positions
>
> On February 5, 2023 11:33:16 AM PST, Upananda Pani <
> upananda.pani at gmail.com> wrote:
> >Thank you. It means we can not use the subset function here.
> >
> >Regards
> >
> >On Mon, 6 Feb, 2023, 00:53 Andr?s Gonz?lez Carmona, <andresgc at
ugr.es>
> wrote:
> >
> >> From ?subset:
> >> Warning
> >>
> >> This is a convenience function intended for use interactively. For
> >> programming it is better to use the standard subsetting functions
like [
> >> <http://127.0.0.1:21786/library/base/help/%5B>, and in
particular the
> >> non-standard evaluation of argument subset can have unanticipated
> >> consequences.
> >>
> >> El 05/02/2023 a las 15:07, Upananda Pani escribi?:
> >>
> >> Dear All,
> >>
> >> I want to create a vector p and extract first 20 observations
using
> subset
> >> function based on logical condition.
> >>
> >> My code is below
> >>
> >> p <- 0:100
> >>
> >> I know i can extract the first 20 observations using the following
> command.
> >>
> >> q <- p[1:20]
> >>
> >> But I want to extract the first 20 observations using subset
function
> which
> >> requires a logical condition. I am not able to frame the logical
> condition.
> >>
> >> The code should be
> >>
> >> q <- subset(p, logical condition)
> >>
> >> I am not able to do it. Please let me know what you think.
> >>
> >> Best regards,
> >> Upananda
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________R-help at
r-project.org
> mailing list -- To UNSUBSCRIBE and more, seehttps://
>
urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!D9dNQwwGXtA!SLdwTGqSfhwUo4CfbUJFeL7hETw64hOG8MQ0FK_o5YdnvVHaOp9Qxs4D7d5e10hj3YQ8EuaFc8qbnkynoP5dEA$
> >> PLEASE do read the posting guide
>
https://urldefense.com/v3/__http://www.R-project.org/posting-guide.html__;!!D9dNQwwGXtA!SLdwTGqSfhwUo4CfbUJFeL7hETw64hOG8MQ0FK_o5YdnvVHaOp9Qxs4D7d5e10hj3YQ8EuaFc8qbnkwuss43hA$
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >> --
> >> * Andr?s Gonz?lez Carmona *
> >>
> >
> > [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >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.
>
> --
> Sent from my phone. Please excuse my brevity.
>
[[alternative HTML version deleted]]