Skip to content

Instantly share code, notes, and snippets.

@karthik
Created December 19, 2016 22:07
Show Gist options
  • Save karthik/07a2f852fefe8f72cf95f685f5da2ce0 to your computer and use it in GitHub Desktop.
Save karthik/07a2f852fefe8f72cf95f685f5da2ce0 to your computer and use it in GitHub Desktop.

Explore functions in a package

lsp <- function (package, pattern, all.names = FALSE)
{
  package <- deparse(substitute(package))
  ls(pos = paste("package", package, sep = ":"), all.names = all.names,
     pattern = pattern)
}

List all function in a package

lsp(ggplot2)

##   [1] "%+%"                       "%+replace%"               
##   [3] "aes"                       "aes_"                     
##   [5] "aes_all"                   "aes_auto"                 
##   [7] "aes_q"                     "aes_string"               
##   [9] "alpha"                     "annotate"                 
##  [11] "annotation_custom"         "annotation_logticks"      
##  [13] "annotation_map"            "annotation_raster"        
##  [15] "arrow"                     "as_labeller"              
##  [17] "autoplot"                  "AxisSecondary"            
##  [19] "benchplot"                 "borders"                  
##  [21] "calc_element"              "combine_vars"             
##  [23] "continuous_scale"          "Coord"                    
##  [25] "coord_cartesian"           "coord_equal"              
##  [27] "coord_fixed"               "coord_flip"               
##  [29] "coord_map"                 "coord_munch"              
##  [31] "coord_polar"               "coord_quickmap"           
##  [33] "coord_trans"               "CoordCartesian"           
##  [35] "CoordFixed"                "CoordFlip"                
##  [37] "CoordMap"                  "CoordPolar"               
##  [39] "CoordQuickmap"             "CoordTrans"               
##  [41] "cut_interval"              "cut_number"               
##  [43] "cut_width"                 "derive"                   
##  [45] "diamonds"                  "discrete_scale"           
##  [47] "draw_key_abline"           "draw_key_blank"           
##  [49] "draw_key_boxplot"          "draw_key_crossbar"        
##  [51] "draw_key_dotplot"          "draw_key_label"           
##  [53] "draw_key_path"             "draw_key_point"           
##  [55] "draw_key_pointrange"       "draw_key_polygon"         
##  [57] "draw_key_rect"             "draw_key_smooth"          
##  [59] "draw_key_text"             "draw_key_vline"           
##  [61] "draw_key_vpath"            "dup_axis"                 
##  [63] "economics"                 "economics_long"           
##  [65] "element_blank"             "element_grob"             
##  [67] "element_line"              "element_rect"             
##  [69] "element_text"              "expand_limits"            
##  [71] "Facet"                     "facet_grid"               
##  [73] "facet_null"                "facet_wrap"               
##  [75] "FacetGrid"                 "FacetNull"                
##  [77] "FacetWrap"                 "faithfuld"                
##  [79] "find_panel"                "fortify"                  
##  [81] "Geom"                      "geom_abline"              
##  [83] "geom_area"                 "geom_bar"                 
##  [85] "geom_bin2d"                "geom_blank"               
##  [87] "geom_boxplot"              "geom_col"                 
##  [89] "geom_contour"              "geom_count"               
##  [91] "geom_crossbar"             "geom_curve"               
##  [93] "geom_density"              "geom_density_2d"          
##  [95] "geom_density2d"            "geom_dotplot"             
##  [97] "geom_errorbar"             "geom_errorbarh"           
##  [99] "geom_freqpoly"             "geom_hex"                 
## [101] "geom_histogram"            "geom_hline"               
## [103] "geom_jitter"               "geom_label"               
## [105] "geom_line"                 "geom_linerange"           
## [107] "geom_map"                  "geom_path"                
## [109] "geom_point"                "geom_pointrange"          
## [111] "geom_polygon"              "geom_qq"                  
## [113] "geom_quantile"             "geom_raster"              
## [115] "geom_rect"                 "geom_ribbon"              
## [117] "geom_rug"                  "geom_segment"             
## [119] "geom_smooth"               "geom_spoke"               
## [121] "geom_step"                 "geom_text"                
## [123] "geom_tile"                 "geom_violin"              
## [125] "geom_vline"                "GeomAbline"               
## [127] "GeomAnnotationMap"         "GeomArea"                 
## [129] "GeomBar"                   "GeomBlank"                
## [131] "GeomBoxplot"               "GeomCol"                  
## [133] "GeomContour"               "GeomCrossbar"             
## [135] "GeomCurve"                 "GeomCustomAnn"            
## [137] "GeomDensity"               "GeomDensity2d"            
## [139] "GeomDotplot"               "GeomErrorbar"             
## [141] "GeomErrorbarh"             "GeomHex"                  
## [143] "GeomHline"                 "GeomLabel"                
## [145] "GeomLine"                  "GeomLinerange"            
## [147] "GeomLogticks"              "GeomMap"                  
## [149] "GeomPath"                  "GeomPoint"                
## [151] "GeomPointrange"            "GeomPolygon"              
## [153] "GeomQuantile"              "GeomRaster"               
## [155] "GeomRasterAnn"             "GeomRect"                 
## [157] "GeomRibbon"                "GeomRug"                  
## [159] "GeomSegment"               "GeomSmooth"               
## [161] "GeomSpoke"                 "GeomStep"                 
## [163] "GeomText"                  "GeomTile"                 
## [165] "GeomViolin"                "GeomVline"                
## [167] "gg_dep"                    "ggplot"                   
## [169] "ggplot_build"              "ggplot_gtable"            
## [171] "ggplotGrob"                "ggproto"                  
## [173] "ggproto_parent"            "ggsave"                   
## [175] "ggtitle"                   "guide_colorbar"           
## [177] "guide_colourbar"           "guide_legend"             
## [179] "guides"                    "is.Coord"                 
## [181] "is.facet"                  "is.ggplot"                
## [183] "is.ggproto"                "is.theme"                 
## [185] "label_both"                "label_bquote"             
## [187] "label_context"             "label_parsed"             
## [189] "label_value"               "label_wrap_gen"           
## [191] "labeller"                  "labs"                     
## [193] "last_plot"                 "layer"                    
## [195] "layer_data"                "layer_grob"               
## [197] "layer_scales"              "lims"                     
## [199] "luv_colours"               "map_data"                 
## [201] "margin"                    "max_height"               
## [203] "max_width"                 "mean_cl_boot"             
## [205] "mean_cl_normal"            "mean_sdl"                 
## [207] "mean_se"                   "median_hilow"             
## [209] "midwest"                   "mpg"                      
## [211] "msleep"                    "panel_cols"               
## [213] "panel_rows"                "Position"                 
## [215] "position_dodge"            "position_fill"            
## [217] "position_identity"         "position_jitter"          
## [219] "position_jitterdodge"      "position_nudge"           
## [221] "position_stack"            "PositionDodge"            
## [223] "PositionFill"              "PositionIdentity"         
## [225] "PositionJitter"            "PositionJitterdodge"      
## [227] "PositionNudge"             "PositionStack"            
## [229] "presidential"              "qplot"                    
## [231] "quickplot"                 "rel"                      
## [233] "remove_missing"            "render_axes"              
## [235] "render_strips"             "resolution"               
## [237] "Scale"                     "scale_alpha"              
## [239] "scale_alpha_continuous"    "scale_alpha_discrete"     
## [241] "scale_alpha_identity"      "scale_alpha_manual"       
## [243] "scale_color_brewer"        "scale_color_continuous"   
## [245] "scale_color_discrete"      "scale_color_distiller"    
## [247] "scale_color_gradient"      "scale_color_gradient2"    
## [249] "scale_color_gradientn"     "scale_color_grey"         
## [251] "scale_color_hue"           "scale_color_identity"     
## [253] "scale_color_manual"        "scale_colour_brewer"      
## [255] "scale_colour_continuous"   "scale_colour_date"        
## [257] "scale_colour_datetime"     "scale_colour_discrete"    
## [259] "scale_colour_distiller"    "scale_colour_gradient"    
## [261] "scale_colour_gradient2"    "scale_colour_gradientn"   
## [263] "scale_colour_grey"         "scale_colour_hue"         
## [265] "scale_colour_identity"     "scale_colour_manual"      
## [267] "scale_fill_brewer"         "scale_fill_continuous"    
## [269] "scale_fill_date"           "scale_fill_datetime"      
## [271] "scale_fill_discrete"       "scale_fill_distiller"     
## [273] "scale_fill_gradient"       "scale_fill_gradient2"     
## [275] "scale_fill_gradientn"      "scale_fill_grey"          
## [277] "scale_fill_hue"            "scale_fill_identity"      
## [279] "scale_fill_manual"         "scale_linetype"           
## [281] "scale_linetype_continuous" "scale_linetype_discrete"  
## [283] "scale_linetype_identity"   "scale_linetype_manual"    
## [285] "scale_radius"              "scale_shape"              
## [287] "scale_shape_continuous"    "scale_shape_discrete"     
## [289] "scale_shape_identity"      "scale_shape_manual"       
## [291] "scale_size"                "scale_size_area"          
## [293] "scale_size_continuous"     "scale_size_date"          
## [295] "scale_size_datetime"       "scale_size_discrete"      
## [297] "scale_size_identity"       "scale_size_manual"        
## [299] "scale_x_continuous"        "scale_x_date"             
## [301] "scale_x_datetime"          "scale_x_discrete"         
## [303] "scale_x_log10"             "scale_x_reverse"          
## [305] "scale_x_sqrt"              "scale_x_time"             
## [307] "scale_y_continuous"        "scale_y_date"             
## [309] "scale_y_datetime"          "scale_y_discrete"         
## [311] "scale_y_log10"             "scale_y_reverse"          
## [313] "scale_y_sqrt"              "scale_y_time"             
## [315] "ScaleContinuous"           "ScaleContinuousDate"      
## [317] "ScaleContinuousDatetime"   "ScaleContinuousIdentity"  
## [319] "ScaleContinuousPosition"   "ScaleDiscrete"            
## [321] "ScaleDiscreteIdentity"     "ScaleDiscretePosition"    
## [323] "seals"                     "sec_axis"                 
## [325] "should_stop"               "Stat"                     
## [327] "stat_bin"                  "stat_bin_2d"              
## [329] "stat_bin_hex"              "stat_bin2d"               
## [331] "stat_binhex"               "stat_boxplot"             
## [333] "stat_contour"              "stat_count"               
## [335] "stat_density"              "stat_density_2d"          
## [337] "stat_density2d"            "stat_ecdf"                
## [339] "stat_ellipse"              "stat_function"            
## [341] "stat_identity"             "stat_qq"                  
## [343] "stat_quantile"             "stat_smooth"              
## [345] "stat_spoke"                "stat_sum"                 
## [347] "stat_summary"              "stat_summary_2d"          
## [349] "stat_summary_bin"          "stat_summary_hex"         
## [351] "stat_summary2d"            "stat_unique"              
## [353] "stat_ydensity"             "StatBin"                  
## [355] "StatBin2d"                 "StatBindot"               
## [357] "StatBinhex"                "StatBoxplot"              
## [359] "StatContour"               "StatCount"                
## [361] "StatDensity"               "StatDensity2d"            
## [363] "StatEcdf"                  "StatEllipse"              
## [365] "StatFunction"              "StatIdentity"             
## [367] "StatQq"                    "StatQuantile"             
## [369] "StatSmooth"                "StatSum"                  
## [371] "StatSummary"               "StatSummary2d"            
## [373] "StatSummaryBin"            "StatSummaryHex"           
## [375] "StatUnique"                "StatYdensity"             
## [377] "theme"                     "theme_bw"                 
## [379] "theme_classic"             "theme_dark"               
## [381] "theme_get"                 "theme_gray"               
## [383] "theme_grey"                "theme_light"              
## [385] "theme_linedraw"            "theme_minimal"            
## [387] "theme_replace"             "theme_set"                
## [389] "theme_update"              "theme_void"               
## [391] "transform_position"        "txhousing"                
## [393] "unit"                      "update_geom_defaults"     
## [395] "update_labels"             "update_stat_defaults"     
## [397] "waiver"                    "wrap_dims"                
## [399] "xlab"                      "xlim"                     
## [401] "ylab"                      "ylim"                     
## [403] "zeroGrob"

lsp(ggplot2, "geom")

##  [1] "geom_abline"          "geom_area"            "geom_bar"            
##  [4] "geom_bin2d"           "geom_blank"           "geom_boxplot"        
##  [7] "geom_col"             "geom_contour"         "geom_count"          
## [10] "geom_crossbar"        "geom_curve"           "geom_density"        
## [13] "geom_density_2d"      "geom_density2d"       "geom_dotplot"        
## [16] "geom_errorbar"        "geom_errorbarh"       "geom_freqpoly"       
## [19] "geom_hex"             "geom_histogram"       "geom_hline"          
## [22] "geom_jitter"          "geom_label"           "geom_line"           
## [25] "geom_linerange"       "geom_map"             "geom_path"           
## [28] "geom_point"           "geom_pointrange"      "geom_polygon"        
## [31] "geom_qq"              "geom_quantile"        "geom_raster"         
## [34] "geom_rect"            "geom_ribbon"          "geom_rug"            
## [37] "geom_segment"         "geom_smooth"          "geom_spoke"          
## [40] "geom_step"            "geom_text"            "geom_tile"           
## [43] "geom_violin"          "geom_vline"           "update_geom_defaults"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment