Giter VIP home page Giter VIP logo

rtutor's Introduction

RTutor.ai - Chat with your data via AI

Hosted demo at RTutor.ai.

RTutor is an AI-based Shiny App that can quickly generate and test R code. Powered by API calls to OpenAI, natural languages are translated into R scripts, which are then executed within the Shiny platform. An R Markdown source file and HTML report can be generated.

Installation

library(remotes)
install_github("gexijin/RTutor")

Obtain an API key from OpenAI

  1. Create a personal account at OpenAI.
  2. After logging in, click on Personal from top left.
  3. Click Manage Account and then Billing, where you can add Payment methods and set Usage limits. $3-$5 per month is more than enough for most people.
  4. Click on API keys to create a new key, which can be copied.

Use the API key with RTutor

There are several ways to do this.

  • After the app is started, you can click on Settings and paste the API key.
  • You can also save this key as a text file called api_key.txt in the working directory.
  • Finally, you can create an environment variable called OPEN_API_KEY. Instructions for Windows, Mac, and Linux.

To start RTutor

library(RTutor)
run_app()

License

(CC BY-NC 3.0) Non-commercial use.

Examples

See this report generated by RTutor after in a typical session.

"Use the mpg data frame. Use ggplot2 to create a boxplot of hwy vs. class. Color by class."

library(ggplot2)
ggplot(mpg, aes(x=class, y=hwy, fill=class)) +
  geom_boxplot()

"Use the mpg data frame. Conduct ANOVA of log-transformed hwy by class and drv."

#Load necessary libraries
library(tidyverse)
#Create log-transformed hwy variable
data <- mpg %>% 
  mutate(hwyLog = log(hwy))
#Perform ANOVA
modelResults <- aov(hwyLog ~ class * drv, data = data)
#View output
summary(modelResults)

"Use the mpg data frame. Create a correlation map of all the columns that contain numbers."

cor_data <- cor(select_if(mpg, is.numeric))
library(corrplot) 
corrplot(cor_data)

"Use the mpg data frame. hwy and cty represent miles per gallon (MPG) on the highway and in the city, respectively. Only keep cars more efficient than 15 MPG, but less than 40, on the highway. Add 0.5 to city MPG for correction. Perform log transformation on city MPG. Raise highway MPG to the second power. Calculate correlation coefficient of the two transformed variables."

# filter for cars more efficient than 15 on the highway, but less than 40
mpg_filtered <- mpg %>% 
    filter(hwy > 15 & hwy < 40)
# add 0.5 to city MPG
mpg_filtered$cty <- mpg_filtered$cty + 0.5
# perform log transformation on city MPG
mpg_filtered$cty <- log(mpg_filtered$cty)
# raise highway MPG to the second power
mpg_filtered$hwy2 <- mpg_filtered$hwy^2
# calculate correlation coefficient
cor(mpg_filtered$hwy2, mpg_filtered$cty)

Alternative solution:

library(tidyverse)
mpg %>%
  filter(hwy > 15 & hwy < 40) %>%
  mutate(cty = cty + 0.5,
         cty = log(cty),
         hwy = hwy^2) %>%
  summarise(corr = cor(cty, hwy))

rtutor's People

Contributors

gexijin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.