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
- Renaming column names in Pandas
- t-stat for feature selection
- Could not find function “%<>%” with dplyr loaded
- Interpreting “condition has length > 1” warning from `if` function
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Get statistics for each group (such as count, mean, etc) using pandas GroupBy?
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- Error: could not find function “%>%”
- Adding new column to existing DataFrame in Python pandas
- How to change the order of DataFrame columns?
- R: Using equation with natural logarithm in nls
- How do I select rows from a DataFrame based on column values?
- Error in Confusion Matrix : the data and reference factors must have the same number of levels
- How do I generate random integers within a specific range in Java?
- How do I get the row count of a Pandas DataFrame?
- How can I randomly select an item from a list?
- Convert pandas dataframe to NumPy array
- Having trouble setting working directory
- Add color to boxplot – “Continuous value supplied to discrete scale” error
- case_when in mutate pipe
- How do I get the row count of a Pandas DataFrame?
- Error in plot.window(…) : need finite ‘xlim’ valuescc
- Longer object length is not a multiple of shorter object length?
- dim(X) must have a positive length when applying function in data frame
- Persistent invalid graphics state error when using ggplot2
- ‘DataFrame’ object has no attribute ‘sort’
- Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : NA/NaN/Inf in ‘y’, tried every possible way
- Rename Pandas DataFrame Index
- Convert DataFrame column type from string to datetime, dd/mm/yyyy format
- Subscript out of bounds – general definition and solution?
- Get a list from Pandas DataFrame column headers
- Plot a line graph, error in xy.coords(x, y, xlabel, ylabel, log) : ‘x’ and ‘y’ lengths differ
- Sum rows in data.frame or matrix
- R: “Unary operator error” from multiline ggplot2 command
- invalid type (list) for variable
- not a Stata version 5-12 .dta file
- How to subset a Data frame column wise using column names?
- Shuffle DataFrame rows
- Random float number generation
- How to move or position a legend in ggplot2
- Nested ifelse statement
- Plot multiple lines (data series) each with unique color in R
- Selecting/excluding sets of columns in pandas
- How to overcome error:”attempt to set ‘colnames’ on an object with less than two dimension” in xts object
- How to avoid “Error in stripchart.default(x1, …) : invalid plotting method” error?
- Data type conversion error: ValueError: Cannot convert non-finite values (NA or inf) to integer
- What’s the difference between facet_wrap() and facet_grid() in ggplot2?
- Error in file(filename, “r”, encoding = encoding) : cannot open the connection
- How do I convert a factor into date format?
- Write lines of text to a file in R
- Error:attempt to apply non-function
- Efficiently sum across multiple columns in R
- “no function to return from, jumping to top level”
- Is there a simple way to make a random selection from an array in JavaScript or any other programming language?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- Error in x[[i]] : recursive indexing failed at level 2
- Merge error : negative length vectors are not allowed
- Fastest way to generate a random boolean
- Getting the IP address of the current machine using Java
- How to avoid “operations are possible only for numeric, logical or complex types” when computing top 3 elements in each group
- What does is.na() applied to non-(list or vector) of type ‘NULL’ mean?
- error r: invalid subscript type “closure” in a simple regression
- why nrow(dataframe) and length(dataframe) in r give different results?
- Meaning of objects being masked by the global environment
- Difference between as.POSIXct/as.POSIXlt and strptime for converting character vectors to POSIXct/POSIXlt
- cbind warnings : row names were found from a short variable and have been discarded
- Error: x must be atomic for ‘sort.list’
- Transposing in dplyr
- How to calculate combination and permutation in R?
- Java: Variable is already defined in method