This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read data | |
df <- readxl::read_excel("df.xlsx") | |
# Splitting the data.frame | |
newlist <- vocab %>% split((1:nrow(df))%/%50) # 50 - number of rows per sheet | |
# Writing to a workbook | |
writexl::write_xlsx(newlist, "new_df.xlsx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```r | |
library(tidyverse) | |
library(stringr) | |
library(Cairo) | |
library(scales) | |
library(showtext) | |
font_add_google(name = "Playfair Display", family = "playfair") | |
hike_data <- readr::read_rds(url('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-11-24/hike_data.rds')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function permutator(inputArr) { | |
var results = []; | |
function permute(arr, memo) { | |
var cur; | |
memo = memo || []; | |
for (var i = 0; i < arr.length; i++) { | |
cur = arr.splice(i, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function intersect_all(lists) { | |
if (lists.length === 0) return []; | |
else if (lists.length == 1) return lists[0]; | |
function intersection(array1, array2) { | |
return array1.filter(function(n) { | |
return array2.indexOf(n) != -1; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function telephoneCheck(str) { | |
// Good luck! | |
if (str.search(/1?\s?\(?[\d]{3}\)?-?\s?[\d]{3}-?\s?[\d]{4}/) === 0) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toTitleCase(str) { | |
return str.replace(/\w\S*/g, function(txt){ | |
return txt.charAt(0).toLowerCase() + txt.substr(1).toLowerCase(); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [2,5,9,5,2,6,9]; | |
var uniqueArray = arr.filter(function(item, pos) { | |
return arr.indexOf(item) == pos; | |
}) | |
console.log(uniqueArray); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sol 1 | |
function diff(arr1, arr2) { | |
var a=[], newArr=[]; | |
for(var i=0;i<arr1.length;i++) | |
a[arr1[i]]=true; | |
for(var i=0;i<arr2.length;i++) | |
if(a[arr2[i]]) delete a[arr2[i]]; | |
else a[arr2[i]]=true; | |
for(var k in a) | |
newArr.push(k); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function st(min) { | |
var totalSeconds = min * 60 + 1; | |
var minutes = 0; | |
var seconds = 0; | |
var content = document.getElementById('container'); | |
content.innerHTML = '25' + ' : ' + '00'; | |
return function timer() { | |
if (totalSeconds > 0) { | |
if (totalSeconds < 59) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.add = function () { | |
return this.reduce ( function (a, b){ return a.concat(b); }); | |
} | |
var total = [[0, 1],[2, 3]].add(); | |
document.write(total) |
NewerOlder