Deloitte Interview Questions | What is the difference between subset() function and sample() function in R?

Question

R

in progress 0
TheDataMonk 55 years 3 Answers 980 views Grand Master 0

Answers ( 3 )

  1. Sample function in R, generates a sample of the specified size from the data set or elements, either with or without replacement.

    The subset function is available in base R and can be used to return subsets of a vector, martix, or data frame which meet a particular condition.

  2. Sample takes a sample of the specified size from the elements of the data using
    either with or without replacement.
    Subset returns subset of vectors, matrices or data frames which meet conditions
    you provide..

  3. sample( ) function to take a random sample of size n from a dataset.
    subset( ) function is the way to select variables and observations.

Leave an answer

Browse
Browse