Skip to content

Instantly share code, notes, and snippets.

@selva86
Created March 1, 2020 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selva86/29a8cf379c27fe9556c756624072c233 to your computer and use it in GitHub Desktop.
Save selva86/29a8cf379c27fe9556c756624072c233 to your computer and use it in GitHub Desktop.
set.seed(100)
M <- matrix(round(runif(100*100), 2), nrow=100, ncol=100)
df <- as.data.frame(M)
df[1:5, 1:5]
# 1. Replace the diagonal of dataframe `df` to the respective row number
# using the set function.
# 2. Set the values of column V1 to values of column V2, for all rows where V2 is
# less than 0.5. using set function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment