ncarchedi / swirl_OLD

We've moved! See README below for more info.
http://swirlstats.com
47 stars 28 forks source link

Dealing with spurious white space in Answer.Type #7

Closed WilCrofter closed 10 years ago

WilCrofter commented 11 years ago

In Data Analysis, module 2, line 12, Answer.Type is "exact " (with a trailing space):

> mod[12,"Answer.Type"] [1] "exact "

This causes line 23 of userInput.R, if(type=="exact") { to fail, hence no match is found, and the function exits without action.

The fix is removing leading and trailing spaces from type before comparison.

ncarchedi commented 11 years ago

Good catch, again.... You might know my code better than I do now!

If you have a fix in mind, go ahead and send it my way. Otherwise, I'm really hoping to have some time this weekend to knock out some bug repairs. You are correct in your other note - smack dab in the middle of midterms. Perhaps not the most strategic release date!

Nick

On Wed, Oct 2, 2013 at 4:49 PM, William R Bauer notifications@github.comwrote:

In Data Analysis, module 2, line 12, Answer.Type is "exact " (with a trailing space):

mod[12,"Answer.Type"] [1] "exact "

This causes line 23 of userInput.R, if(type=="exact") { to fail, hence no match is found, and the function exits without action.

The fix is removing leading and trailing spaces from type before comparison.

— Reply to this email directly or view it on GitHubhttps://github.com/ncarchedi/swirl/issues/7 .

Nicholas A. Carchedi ScM Student, Biostatistics Johns Hopkins Bloomberg School of Public Health 301.802.0573 | nick.carchedi@gmail.com

WilCrofter commented 11 years ago
Hi Nick,
  Wife, Gina, (reginaastri on github; she found the bug) and I
  talking this over thought a little "whiteout" function applied to
  certain arguments passed to userInput(), and wrapping the various
  readlines (str.ans <- readline("ANSWER: ") becomes str.ans
  <- whiteout(readline("ANSWER: ")) might be a good thing.  I
  mean something like whiteout <- function(x)gsub("[[:space:]],
  x) or a little more elaborate. We'll try it out in a branch and
  see how it goes. 
  Rodger Parker, my Bloomberg emeritus friend, suggested a central
  limit theorem module. CLT was generally his first topic when
  teaching. He and I will try to put a module together which
  demonstrates it.
  Best wishes for midterms. Our son Sasha, freshman at UMBC, is in
  similar straights. 
  Bill
  On 10/2/2013 8:30 PM, Nick Carchedi wrote:
Good catch, again.... You might know my code better
  than I do now!

  If you have a fix in mind, go ahead and send it my way. Otherwise,
  I'm

  really hoping to have some time this weekend to knock out some bug
  repairs.

  You are correct in your other note - smack dab in the middle of
  midterms.

  Perhaps not the most strategic release date!

  Nick

  On Wed, Oct 2, 2013 at 4:49 PM, William R Bauer
  <notifications@github.com>wrote:

  > In Data Analysis, module 2, line 12, Answer.Type is "exact "
  (with a

  > trailing space):

  >

  > > mod[12,"Answer.Type"]

  > [1] "exact "

  >

  > This causes line 23 of userInput.R,

  > if(type=="exact") {

  > to fail, hence no match is found, and the function exits
  without action.

  >

  > The fix is removing leading and trailing spaces from type
  before

  > comparison.

  >

  > —

  > Reply to this email directly or view it on
  GitHub<https://github.com/ncarchedi/swirl/issues/7>

  > .

  >

  -- 
  Nicholas A. Carchedi

  ScM Student, Biostatistics

  Johns Hopkins Bloomberg School of Public Health

  301.802.0573 | nick.carchedi@gmail.com
  —
    Reply to this email directly or view
      it on GitHub.
ncarchedi commented 11 years ago

Bill - This all sounds fantastic - both the whitespace fix and the module suggestion. Please keep me posted.