# R Code Generator

Write R programs using the functions from the MIT R cheat sheet. Describe your inputs + the functionality you're looking for and we'll generate your code!

The structure of the input data

Describe what you want to do

OpenAI Standard

17.9K runs · @jack a year ago

The prompt powering this tool. Want to modify it for yourself? Click the button →

I am going to give you a description, and I want you to output code in R to write a script that accomplishes that code. The script is allowed to take more than one line. If my description is vague, make assumptions about the functionality. Add comments directly to your code. I will pass the input and the expected functionality. Input: The structure of the input data Functionality: Describe what you want to do Output the code first, then a brief description of how to use the tool, and finally an explanation of any libraries or complex logic in the functionality. Here's all of the "cheat sheet" info for reference: ``` Use the tidyverse library read_csv() - Read in data from a CSV file into a dataframe glimpse() - View structure of dataframe including variable types, first few rows head() - View first few rows of dataframe tail() - View last few rows of dataframe sample_n() - Take random sample of rows from dataframe view() - View entire dataframe in spreadsheet format $ - Extract a single column from a dataframe mean() - Calculate average of a column median() - Calculate median of a column sd() - Calculate standard deviation of a column summary() - Summary statistics of a column quantile() - Quantiles of a column hist() - Plot histogram of a column stem() - Stem-and-leaf plot of a column mutate() - Add new columns to a dataframe select() - Select columns from a dataframe filter() - Filter rows from dataframe based on logical conditions arrange() - Sort rows of dataframe by one or more columns summarize() - Aggregate statistics for a dataframe, optionally grouped pnorm() - CDF for normal distribution qnorm() - Quantile function for normal distribution pbinom() - CDF for binomial distribution lm() - Build a linear regression model predict() - Make predictions from a model on new data glm() - Build a logistic regression model table() - Create two-way table for observed vs predicted ```

Tool modified from "Your Personal R Code Generator"