Skip to content

Commit 4023d49

Browse files
authored
Re-adding snippets folder via upload
1 parent c2135c9 commit 4023d49

16 files changed

+16
-0
lines changed

snippets/carbon_emissions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"carbon_emissions","description":"Total carbon dioxide, in gigatonnes, by region, over time","language":"R","code":["co2_regions <- nations %>%"," filter(year <= 2014) %>%"," mutate(co2 = co2_percap * population / 10^9) %>%"," group_by(region, year) %>%"," summarize(total_co2 = sum(co2, na.rm = TRUE))"],"id":14,"tags":["Countries Project"]}

snippets/filter_income.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"filter_income","description":"Find the ten high income countries with the shortest life expectancy from country data.","language":"R","code":["high_income_short_life <- longevity %>%"," filter(income == \"High income\") %>%"," arrange(life_expect) %>%"," head(10)"],"id":7,"tags":["Countries Project"]}

snippets/gdp_calculator.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"gdp_calculator","description":"Calculate total GDP, in trillions of dollars, by region, over time","language":"R","code":["gdp_regions <- nations %>%"," mutate(gdp = gdp_percap * population,"," gdp_tn = gdp/1000000000000) %>%"," group_by(region, year) %>%"," summarize(total_gdp_tn = sum(gdp_tn, na.rm = TRUE))",""],"id":11,"tags":["Countries Project"]}

snippets/generate_hundred.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"generate_hundred","description":"Scala program to print numbers from 1 to 100 using for loop with until to determine loop range.","language":"Scala","code":["object ExampleForLoop2 {"," def main(args: Array[String]) {"," var counter: Int=0;"," "," for(counter <- 1 until 101)"," print(counter + \" \");"," "," // to print new line"," println();"," }","}"],"id":13,"tags":["math"]}

snippets/import_cleaning.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"import_cleaning","description":"Import statements for cleaning.","language":"Python","code":["# Importing the necessary libraries.","import pandas as pd","import numpy as np"],"id":4,"tags":["import statements"]}

snippets/import_matlib.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"import_matlib","description":"import statements for matlib","language":"Python","code":["import matplotlib as mpl","import matplotlib.pyplot as plt"],"id":0,"tags":["import statements"]}

snippets/life_exp_eur_asia.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"life_exp_eur_asia","description":"Find countries in North America or Europe and Central Asia with a life expectancy in 2016 of 75 to 80.","language":"R","code":["eur_na_75_80 <- longevity %>%"," filter(life_expect > 75 & life_expect < 80 & (region == \"Europe & Central Asia\" | region == \"North America\")) %>%"," arrange(desc(life_expect))"],"id":9,"tags":["Countries Project"]}

snippets/lorenz_deriv.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"lorenz_deriv","description":"Math equation for lorenz.","language":"Python","code":[" def lorenz_deriv(x_y_z, t0, sigma=sigma, beta=beta, rho=rho):"," \"\"\"Compute the time-derivative of a Lorenz system.\"\"\""," x, y, z = x_y_z"," return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]"],"id":3,"tags":["custom","math","lorenz"]}

snippets/matplotlib_import.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"matplotlib_import","description":"Import statements to start plotting with matplotlib.","language":"Python","code":["import matplotlib as mpl","import matplotlib.pyplot as plt"],"id":2,"tags":["import statements"]}

snippets/matrix_lstsqr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"matrix_lstsqr","description":"Math equation for least squares","language":"Python","code":["import numpy as np","","def matrix_lstsqr(x, y):"," \"\"\" Computes the least-squares solution to a linear matrix equation. \"\"\""," X = np.vstack([x, np.ones(len(x))]).T"," return (np.linalg.inv(X.T.dot(X)).dot(X.T)).dot(y)"],"id":1,"tags":["math"]}

0 commit comments

Comments
 (0)