Skip to content

Instantly share code, notes, and snippets.

@rhilfi
Created April 8, 2021 04:04
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 rhilfi/ab360d13f929600b369a869b08a4f74c to your computer and use it in GitHub Desktop.
Save rhilfi/ab360d13f929600b369a869b08a4f74c to your computer and use it in GitHub Desktop.
lookfor_in_r_as_in_stata #r
# install.packages("questionr")
library(questionr)
Thats_a_cool_variable =rnorm(100, 50,12)
Thats_a_less_cool_variable =rnorm(100,50,12)
Thats_an_even_cooler_variable=rnorm(100,40,21)
Does_R_makes_you_angry=rep(0:1,each=50)
Does_R_makes_you_happy=rep(c(1,0),each=50)
data<-data.frame(Thats_an_even_cooler_variable, Thats_a_cool_variable, Thats_a_less_cool_variable, Does_R_makes_you_angry, Does_R_makes_you_happy)
# Example that will yield nothing:
lookfor(data, "coll")
# Nothing found. Sorry.
# Example that will find something:
lookfor(data, "cool")
# pos variable label col_type values
# <chr> <chr> <chr> <chr> <chr>
# 1 Thats_an_even_cooler_variable — dbl range: -27.2974991135071 - 110.530582887605
# 2 Thats_a_cool_variable — dbl range: 22.3679775441832 - 76.0718249742795
# 3 Thats_a_less_cool_variable — dbl range: 26.4050546494277 - 73.8098660856932
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment