Skip to main content

LearnR_Packages

_LearnR_UserGuide_Packages.knit

Packages

GPT-4 explains what an R package is:

“In R and RStudio, a”package” is a collection of functions, data sets, and documentation bundled together. A package provides a way to distribute and share R code and related material with others. They can be thought of as an extension or add-on to the base R system, allowing users to tap into specialized functionality for specific tasks or domains.

The R community has developed thousands of packages, which are available on the Comprehensive R Archive Network (CRAN) and other repositories. These packages cover a vast range of topics and methods, from statistical techniques and data manipulation to graphical display and interactive applications.

In RStudio, you can easily install and manage packages using the “Packages” pane, which provides a user-friendly interface for these tasks. Once a package is installed, you need to use the library() function to load it into your current R session to access its functions and datasets.”


Packages How To

To install a new package:

install.packages("")

To check which packages are installed:

installed.packages()

Darrell’s Most Used Packages (updated periodically)

To install a package:

install.packages()

The packages I’m using most these days:

Data Cleaning and Handling in R

# All Purpose Data
install.packages("tidyverse")

# Data Visualization 
install.packages("ggplot2") # Coursera Preferred Option
install.packages("Plotly")
install.packages("Lattice")
install.packages("RGL")
install.packages("Dygraphs")
install.packages("Leaflet")
install.packages("Highcharter")
install.packages("Patchwork")
install.packages("gganimate")
install.packages("ggridges")


#Database
install.packages("DBI")
install.packages("odbc")
install.packages("RODBC")


#SQL
install.packages("sqldf")

Example Use Case:
  sqldf("SELECT * FROM Orange ORDER BY age ASC, circumference DESC LIMIT 5")

SEE: 
  
  1.3. Importing from SQL Databases
  https://tomaztsql.wordpress.com/2020/04/27/essential-list-of-useful-r-packages-for-data-scientists/

AND:
    SQL in R
    https://dept.stat.lsa.umich.edu/~jerrick/courses/stat701/notes/sql.html

    
    
# HTML
install.packages("shiny")
install.packages("htmltools")



#TBD...

install.packages("")
install.packages("")
install.packages("")
install.packages("")

R & SQL Server Databases - Part 1 Writing R in RStudio, with a SQL Database

GPT-4: If you’re working with SQL Server in R, there are several R packages that can help you connect to, retrieve, and manipulate data. Here are some of the most widely-used ones:

  1. RODBC: This is one of the older and more established packages for ODBC database connections in R. As the name implies, it uses the ODBC (Open Database Connectivity) drivers to establish connections.
    install.packages("RODBC")
-   Usage:
    library(RODBC)
    connection <- odbcConnect("DSN_NAME", uid="YOUR_USER_ID", pwd="YOUR_PASSWORD")
    data <- sqlFetch(connection, "TABLE_NAME")
    close(connection)
  1. DBI and odbc: DBI is a modern database interface for R, and the odbc package, which builds on DBI, provides a way to establish ODBC connections.
    install.packages("DBI")
    install.packages("odbc")
-   Usage:
    library(DBI)
    library(odbc)
    connection <- dbConnect(odbc(), "DSN_NAME", UID="YOUR_USER_ID", PWD="YOUR_PASSWORD")
    data <- dbGetQuery(connection, "SELECT * FROM TABLE_NAME")
    dbDisconnect(connection)
  1. RSQLServer: This package is a DBI-compliant interface specifically for SQL Server. It might be more intuitive if you’re exclusively working with SQL Server.
    # Using devtools to install from GitHub
    devtools::install_github('imanbio/RSQLServer')
  • Usage:
    library(RSQLServer)
    connection <- dbConnect(RSQLServer::SQLServer(), url="jdbc:sqlserver://SERVER_NAME;databaseName=DB_NAME", user="YOUR_USER_ID", password="YOUR_PASSWORD")
    data <- dbGetQuery(connection, "SELECT * FROM TABLE_NAME")
    dbDisconnect(connection)
  1. pool: This is an auxiliary package that can be used in combination with the others. It allows you to manage and optimize your database connections using connection pooling, which can be particularly helpful when building Shiny apps that connect to databases.
    install.packages("pool")

When selecting a package, consider the specific features you need, as well as any dependencies. For example, RODBC might require configuration of an ODBC Data Source Name (DSN), while RSQLServer uses JDBC. In general, the DBI and odbc combination is widely adopted and offers a good mix of features and ease of use.

### R & SQL Server Databases - Part 2 Writing SQL in RStudio
#### See Images paired with these instructions:
Connections Native Server Database
Connections R Console
Connections Opens in Console Editor
Console Editor results can be seen below editor

HTML in RStudio

GPT-4 on RStudio tools for HTML:

Shiny: It’s an R package that allows for the creation of interactive web apps. While it primarily uses its own system of UI components, you can integrate raw HTML and CSS if needed.

R Markdown with HTML Output: When you create an R Markdown document in RStudio, you can knit the document to produce an HTML output. Within the R Markdown document, you can mix Markdown, R code, and even raw HTML.

htmltools: This R package provides functions and tools for working with HTML. It can be particularly useful when you want to generate dynamic HTML content based on data analysis in R.

install.packages("shiny")

install.packages("htmltools")

END

END for Now…

# UNDER CONSTRUCTION………….

### Title
### Title
TEXT
r install.packages("")
END

Title

TEXT

install.packages("")

END

### Title
### Title
TEXT
r install.packages("")
END

Title

TEXT

install.packages("")

END

Popular posts from this blog

Learning Coding Fundamentals with Python and SQL

Learning Coding Fundamentals with Python and SQL Learning Coding Fundamentals with Python and SQL Darrell Wolfe ————————————————————— Disclaimers First It is not my intention to steal anyone’s thunder or copyrighted material. I do not believe these seven fundamentals are specific to Dr Hill (below), who was the initial inspiration to start this note file. That beings said, she has a particularly unique method of teaching, and I strongly recommend that if you are someone who needs a good teacher, she’s the one! This is my own process of learning. I take information from as many sources and teachers as possible, synthesis that material, and then practice it until I get good at it. Further, I like to take detailed notes so I can refer back to them when a particular tool starts getting rusty or dusty in my brain after disuse for a time. When I learned .rmd through my Google Data Analytics Certification, I

Becoming a Business Intelligene and Data Analyst

In order to learn SQL, here are the steps I'm using: I'm working through: W3 Schools SQL Tutorials   Coursera: Google Data Analytics Professional Certificate   YouTube's Alex the Analyst FREE " Data Analyst Bootcamp!! "  Google Searching to reference as many articles as I can find on various aspects. Using ChatGPT  to check my syntax and explain concepts to me, answering my questions like a tutor.  I've also joined/downloaded/am using: GitHub My Repository:  https://github.com/darrellwolfe/toposcreative SQL Quick Reference notes Trello SQL Server  Express: SQL Server 2022 Express is a free edition of SQL Server, ideal for development and production for desktop, web, and small server applications. Visual Studio 2022 Power BI Tableau &  Tableau Public TBC... Shalom  שָׁלוֹם : Live Long and Prosper! Darrell Wolfe Storyteller | Writer | Thinker | Consultant | Freelancer

Using INDIRECT to obtain a VLookup with a variable array reference

Case Study for using INDIRECT to obtain a VLookup with a variable array reference *For reference: I did not build this workbook, it came this way and I'm stuck with it until I can rebuild it correctly next year.* The Problem: I have a legacy workbook that I have to rebuild for next year, but his year I'm stuck with.  This workbook has at or near 100 tabs that need to be referenced on a Totals and Subtotals set of pages. There are a thousand better ways to do that, especially using Power Query and Power Pivot, but here we are. These sub-totals pages were for specific sub-sets of the data that could be found on any given page (Ex: One sub-totals page looks for all properties with a PC Code "548"). On the sub-totals pages, the previous builder had simply linked the cells to the various pages; resulting in over a thousand rows of data that looked like this: //='2001'!$A$20// However, when the end-user filtered the data on the origin pages, the data on the sub-tota