To load a spreadsheet into R, the easiest way is to save the spreadsheet as a CSV file and use the read.csv()
function. For example:
42 chars2 lines
To combine the first four rows and six columns into a matrix, you can use array indexing with the [rows, columns]
syntax. For example, assuming your data frame is called my_data
:
42 chars2 lines
To check for duplicate values in the matrix, you can use the duplicated()
function. For example:
27 chars2 lines
If this returns TRUE
, it means there are duplicate values in my_matrix
.
To randomize all rows if there are duplicates, you can use the sample()
function to generate a random permutation of the row indices, then use this permutation to index the rows of my_matrix
. For example:
113 chars5 lines
gistlibby LogSnag