« first day (2354 days earlier)      last day (821 days later) » 

6:38 AM
What (R) paradigm benefits from this style?
0
A: On coursera R-programming course Assignment 2 Lexical Scoping

MisakiYou know that the goal of this task is to create a super matrix that can store it's content and it's inverse as well. So it has to have 2 variable x the matrix, and inv the inverse. Each variable has 2 functions set and get. So, set is a function that takes an argument and do something inside it,...

 
6:55 AM
-2
Q: Convert the SQL code to R

SHPstmt <- paste("INSERT INTO ", consolidated_output_table, " (unique_id, skills_in_cluster,bu, status, grade, region, city, parentcustomername) SELECT a.unique_id, a.primary_cluster_id, b.bu, b.status, b.grade, b.region, b.city, b.parentcustom...

^^^needs some attention...
 
 
2 hours later…
9:13 AM
@RomanLuštrik Memoization: stackoverflow.com/a/41323414/1412059
 
 
8 hours later…
5:39 PM
@Roland their approach seems unnecessarily obtuse, though. it's quite hard to determine where the values are, ls(env= environment(mat[[1]])) seems like the least clunky way
 
5:53 PM
@Frank That's basically what I show in the duplicate. Nothing difficult about it if you somewhat understand environments and closures.
 
6:28 PM
@Roland yeah, i use memoisation, i'm not saying it's inherently hard but rather that making a new set of functions for every object of this pseudo-class and hiding the object as an element of the functions' environment is ... overcomplicated. i'm sure there are more elegant ways with classes, but i'd do something like...
make.cm <- function(x = matrix()) as.environment(list(x = x, inv = matrix()))
get.cm <- function(cm) cm$x
getInverse.cm <- function(cm) cm$inv
setInverse.cm <- function(cm) assign("inv", solve(get.cm(cm)), cm)

my_cm <- make.cm(matrix(1:4, 2))
get.cm(my_cm)
setInverse.cm(my_cm)
getInverse.cm(my_cm)

mget(ls(env = my_cm), my_cm)
 
@Frank I think the semantics here line up pretty closely with oop languages (and RC). I don't necessarily think this is a good thing, but you have a self contained object with both values and functions. The cost of the multiple copies of the same functions is low, and there is the organizational benefit that the only thing in the workspace is the object. As to where the values are, the intention is that is abstracted and they should only be accessed via the get and set funs.
 
@BrodieG fair enough, i guess, though i'd probably insist on use of a proper class if i saw this sort of thing in a collaborator's code. so many ways it could go sideways...
 
@Frank Agreed, after all RC does exactly this.
 
6:44 PM
yeah, that's my (vague) understanding, having never used them
 
 
5 hours later…
11:41 PM
"To succeed as a data scientist, become fluent in the essentials. If you want to be a data scientist, here is my recommendation. ... Learn and drill the major techniques from the following R packages: ggplot2, dplyr, tidyr, lubridate, stringr, forcats, readr"
http://sharpsightlabs.com/blog/are-you-fluent-r/ courtesy of R-bloggers
I guess I'm not much of a data scientist.
 

« first day (2354 days earlier)      last day (821 days later) »