First make some data:
> df = data.frame(matrix(rnorm(20), nrow=10)) > df X1 X2 1 0.7091409 -1.4061361 2 -1.1334614 -0.1973846 3 2.3343391 -0.4385071 4 -0.9040278 -0.6593677 5 0.4180331 -1.2592415 6 0.7572246 -0.5463655 7 -0.8996483 0.4231117 8 -1.0356774 -0.1640883 9 -0.3983045 0.7157506 10 -0.9060305 2.3234110
Then select some rows at random:
> df[sample(nrow(df), 3), ] X1 X2 9 -0.3983045 0.7157506 2 -1.1334614 -0.1973846 10 -0.9060305 2.3234110
Related Posts:
- Counting the number of elements with the values of x in a vector
- Replace all 0 values to NA
- How can I change the name of a data frame
- R Hex to RGB converter
- Reasons for using the set.seed function
- Non-numeric Argument to Binary Operator Error in R
- Error in ggplot.data.frame : Mapping should be created with aes or aes_string
- Error in file(file, “rt”) : invalid ‘description’ argument in complete.cases program
- SummarySE (Rmisc package) to produce a barplot with error bars (ggplot2)
- Editing legend (text) labels in ggplot
- Logistic Regression on factor: Error in eval(family$initialize) : y values must be 0 <= y <= 1
- R – longer object length is not a multiple of shorter object length
- Error: attempt to use zero-length variable name
- “non-numeric argument to binary operator” error in R
- Replace all particular values in a data frame
- What does “The following object is masked from ‘package:xxx'” mean?
- How can I convert Json to data frame in R
- Error in xj[i] : invalid subscript type ‘list’
- How do you specifically order ggplot2 x axis instead of alphabetical order?
- Error in
: target of assignment expands to non-language object - R error: “New Column would leave holes after existing columns”
- Error: Invalid number of ‘breaks’ in R
- Batch convert columns to numeric type
- Deleting rows that are duplicated in one column based on the conditions of another column
- What is the difference between require() and library()?
- What is the meaning of the dollar sign “$” in R function()?
- Use of ~ (tilde) in R programming Language
- Convert data.frame column to a vector?
- Converting from a character to a numeric data frame
- In R, dealing with Error: ggplot2 doesn’t know how to deal with data of class numeric
- How do I select the first row in an R data frame that meets certain criteria?
- Generate unique random numbers between 1 and 100
- how to sort pandas dataframe from one column
- Poker hand range chart visualization in R
- Poker hand range chart visualization in R
- Renaming column names in Pandas
- How to reset index in a pandas dataframe? [duplicate]
- how to reset index pandas dataframe after dropna() pandas dataframe
- Getting random numbers in Java [duplicate]
- Delete a column from a Pandas DataFrame
- Emulate ggplot2 default color palette
- ggplot wrong color assignment
- How do I generate a random int number?
- How to deal with SettingWithCopyWarning in Pandas
- How to deal with SettingWithCopyWarning in Pandas
- Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”
- How to iterate over rows in a DataFrame in Pandas
- How to iterate over rows in a DataFrame in Pandas
- How to rename a single column in a data.frame?
- Critical t values in R
- Error in plot.new() : figure margins too large, Scatter plot
- Error in file(file, “rt”) : cannot open the connection [duplicate]
- Writing a pandas DataFrame to CSV file
- Error in
: object of type ‘closure’ is not subsettable - What does %>% function mean in R?
- t-stat for feature selection
- Selecting multiple columns in a Pandas dataframe
- Could not find function “%<>%” with dplyr loaded
- How to join (merge) data frames (inner, outer, left, right)
- Interpreting “condition has length > 1” warning from `if` function
- How to generate a random number in C++?
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- rbind error: “names do not match previous names”
- Get statistics for each group (such as count, mean, etc) using pandas GroupBy?
- rbind error: “names do not match previous names”
- How to coerce a list object to type ‘double’
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Writing a pandas DataFrame to CSV file
- R Error in x$ed : $ operator is invalid for atomic vectors
- $ operator is invalid for atomic vectors for dataframe R
- Python random function
- Plotting with ggplot2: “Error: Discrete value supplied to continuous scale” on categorical y-axis
- ggplot2 error : Discrete value supplied to continuous scale
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- How to open CSV file in R when R says “no such file or directory”?
- Error: could not find function “%>%”
- Adding new column to existing DataFrame in Python pandas
- How to change the order of DataFrame columns?
- R on MacOS Error: vector memory exhausted (limit reached?)
- R programming: How do I get Euler’s number?
- What does na.rm=TRUE actually means?
- How to change the order of DataFrame columns?
- Remove legend ggplot 2.2
- What does random.sample() method in python do?
- Error in if/while (condition) {: missing Value where TRUE/FALSE needed
- adding x and y axis labels in ggplot2
- Pandas DataFrame Groupby two columns and get counts
- How do I replace NA values with zeros in an R dataframe?
- How to change legend title in ggplot
- Changing column names of a data frame
- How can I use the apply() function for a single column?
- How to show all columns’ names on a large pandas dataframe?
- How to groupby based on two columns in pandas?
- Set NA to 0 in R
- R: Using equation with natural logarithm in nls
- How to change legend title in ggplot
- Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
- Random string generation with upper case letters and digits
- rand() between 0 and 1