pearselab / r-intro-jenessalemon

r-intro-jenessalemon created by GitHub Classroom
0 stars 1 forks source link

lesson_2 #10 #6

Open jenessalemon opened 7 years ago

jenessalemon commented 7 years ago

@marleyhaupt1 (did that work? I don't know how to "tag" people) In my textbox function, the box part is working but the text isn't showing up. I'm sure we will talk about this again when we meet tomorrow, but I'd appreciate ideas!

marleyhaupt1 commented 7 years ago

ok. Lets go over it tomorrow sometime

willpearse commented 7 years ago

...I think I can help...

Two things: firstly, on line 157, you ask why something stops an infinite loop. I'll let Marley explain that, but in general you shouldn't be using a while loop. The same thing - looping over the width of the box and printing either one or two characters - can be achieved in exactly the same way with a for loop, and then you wouldn't need that extra line anyway. Using a while loop is one way to do one of the more advanced exercises, I suppose, but I'll leave that to you...

Secondly, your function isn't printing out the text because it only prints out if the (i==1 || i==len || j==1 || j==wid) == FALSE and (i==ceiling(length/2) & j==ceiling(width/2)-floor(nchar(string)/2)) == TRUE. I don't know exactly what you're trying to do with all of that, but I do know that there's likely something wrong in there.

Here's my advice: you use ceiling(length/2) twice in the above express. Store that as a variable and give it a sensible name. That should help you track exactly what's going on with that like there, and I'm sure it'll make more sense then.

Does that help?