Code Monkey home page Code Monkey logo

statisticalcomputing's People

Contributors

wibeasley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statisticalcomputing's Issues

Styling knitr reports

@andkov, you may remember @genevamarshall. She's been getting into reports recently and created some neat ones with knitrBootstrap. I'm a little concerned that there hasn't been an real development since spring 2014. Do you know of anything similar that's still being developed? I'd hate for her to invest time into learning it, if it's not going to be maintained. Her preliminary stuff looks great so far.

Here are some links, if that helps jog your memory:

grep() versus grepl()

In reference to the example in issue #11:

  • R
pax <- c("asdgf2", "asd3", "bcdfs4", "zsdfs5", "asdfs6", "podf-podf-podf-podf-podf")

regex <- "(^\\D\\D\\D\\D)|-\\D\\D\\D\\D|(^\\D+)3"

  • grep returns terms that contain matches:
> grep(regex, pax, value=T)
[1] "asdgf2"                   "asd3"                     "bcdfs4"                   "zsdfs5"                  
[5] "asdfs6"                   "podf-podf-podf-podf-podf"
> 

  • grepl returns whether the "terms with matches" are TRUE or FALSE
> grepl(regex, pax)
[1] TRUE TRUE TRUE TRUE TRUE TRUE
> 

Thanks again for the review @wibeasley

strategy for notification when a live dataset is changed

To @OuhscBbmc/dhswaiverpushpull, @mand9472 and others,
@Maleeha recently asked "is there a possibility that a notification is sent to those who are responsible for the variables whenever they change on REDCap?". For context, we have making some necessary changes to the REDCap database where people are entering live data.

I don't have a good solution for this recurring scenario, and I would appreciate suggestions how we might do it better. I'm affected both as a producer (eg, the main person responsible for the DHS Waiver ferry) and as a consumer (eg, OSDH's ETO). Here are the strategies that we currently (try to) employ:

  1. Make changes to the data source in large, but infrequent batches. I think a slow trickle of changes is harder (for the ~7 analysts on our project) to monitor.

  2. Assign a questionnaire/instrument to as few analysts as possible, and encourage that analysts to feel ownership of that questionnaire and it's maintenance. That also reduces the number of people affected; for example.

  3. If only a few variables are changed, then grep the variable name and notify the analysts owning the files containing that variable name (eg $ grep -rl "iss_assigned_date" ~/Bbmc/DhsWaiver).

  4. If broad changes occur, then make a general announcement and request that everyone check their reports against the development version of the database/ferry (eg, the issue called "prospectively check your reports against the v1.1 ferry").

    Th recent change affected all most all the important variables (eg, the group assignment), so I assigned it to almost everyone. I didn't assume anyone's reports would be immune.

    image

  5. This transition from the old database to the new database is tough, and we avoid doing it when reports need to be run. I know the proper software engineering strategy is to branch the repo, and eventually merge it into the master after everything's tested. Although I do this for proper R packages, I've been reluctant to branch repos that mainly hold analysis code and reports.

spun off of #177 (cc: @andkov & @aggie-dba)

Another regular expression for Monday

I want to put comma in currency:

22300

The following regular expression with positive look ahead and negative look ahead, was working on regex 101

(\d)(?=(\d{3})+(?!\d))

You replace it with:

\1,

However its not working for me on R. Any suggestions?
@wibeasley

Thanks!

Another regular expression

You don't have to look at it yet since i have not really spend time on the rest of it on my own but if you do find time to look at it, i am trying to finish the rest of it @wibeasley

expression

Thanks!

Regular expression problem

I have the following regular expression to capture $, ,, . and digits after period.

^(\$)\d*(,)\d*(.)(\d*)

It is for the following character variable. I am giving one value here:

$34,000.00

I want to get rid of all the captured groups. What do i substitute it with in the following statement.

dplyr::mutate(
    income = as.numeric(sub(regex, "", annual_income))
  )

@wibeasley ... I am not able to tag anyone else.

Thanks!

Morning SCUG Question

@wibeasley

Here is the work on Regex101. Please forgive the amateur pattern of regex here:

Example on regex101

  • Each cell here has exactly one match except the last cell which has 5 matches.
  • In-addition, in each cell, matches have also been captured except the last cell where only one match (out of 5) has been captured.

I want to get it right:

  • Here is an example in R
pax <- c("asdgf2", "asd3", "bcdfs4", "zsdfs5", "asdfs6", "podf-podf-podf-podf-podf")

  • Here is the pattern:
regex <- "(^\\D\\D\\D\\D)|-\\D\\D\\D\\D|(^\\D+)3"
  • Here is the execution in R:
sub(regex, "PF",  pax)
gsub(regex, "PF",  pax)

  • Here are the results with sub:
[1] "PFf2"                   "PF"                     "PFs4"                   "PFs5"                  
[5] "PFs6"                   "PF-podf-podf-podf-podf"
  • Bottom-line: sub scans each cell and look at only the first match to replace it. Does not matter how much of the match was captured. Looks at matched and captured text the same way.

  • Here is an output with gsub

"PFf2"       "PF"         "PFs4"       "PFs5"       "PFs6"       "PFPFPFPFPF"
  • Bottom-line: gsub scans each cell and look at all the matches to replace them and then replace each match with substitution.

Thank you for your patience this morning

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.