This is a good question. Among those three lines, one line has to be isolated. You only run two lines each time. Sorry that I can n't type those two lines since you post a pic and I can not copy paste from a pic.
Now you pick up twice-running case, and run commands inside it ONE-BY-ONE. Each time you watch the change of entire in your Global environment. Can you find which command line remove the storage of your new height data?
That particular line is the one the makes your data storage project failed-- since it removes your past storage and let you start with a new storage again.
You only need to remove ONE line in the twice-running case. And your code will work.
***
是第二次執行的第一行嗎?
***
是第二次執行的第一行嗎?
YES. Perfect.
***
entire = c()又再次清空了所儲存的值
***
That's right.
entire <- c()
is an initiator which functions as giving us a new empty bucket for data collection. We only need initiator to execute ONCE and AT THE BEGINNING.
***
***
OK 謝謝老師
***
The essence of computer programming is: Know how to layout your strategy in sentences and know how to translate them LINE-BY-LINE for computer to understand. You are welcome.
I am glad someone notice this subtlety, which I believe most students did not notice. Good job.
老師請問一下 我想要練習這個收集資料的方法 可是執行後的結果 似乎只會儲存一個值呢 這些是這段程式碼執行2次的結果
This is a good question. Among those three lines, one line has to be isolated. You only run two lines each time. Sorry that I can n't type those two lines since you post a pic and I can not copy paste from a pic.
老師這樣能copy了嗎? 轉成code的輸出了 ***
When you run it twice, it is like running
Now you pick up twice-running case, and run commands inside it ONE-BY-ONE. Each time you watch the change of entire in your Global environment. Can you find which command line remove the storage of your new height data?
That particular line is the one the makes your data storage project failed-- since it removes your past storage and let you start with a new storage again. You only need to remove ONE line in the twice-running case. And your code will work. *** 是第二次執行的第一行嗎? ***YES. Perfect.
*** entire = c()又再次清空了所儲存的值 *** That's right. is an initiator which functions as giving us a new empty bucket for data collection. We only need initiator to execute ONCE and AT THE BEGINNING. *** 所以應該像這樣分2行去執行嗎? 感謝老師! ***Our story line is:
prepare a bucket for my data
measure the height of a new student
record it
measure the height of second student
record it
measure the height of the third student
record it
Putting those sentences into computer codes:
record it
measure the height of second student
record it
measure the height of the third student
record it
Yes you're right.
*** OK 謝謝老師 *** The essence of computer programming is: Know how to layout your strategy in sentences and know how to translate them LINE-BY-LINE for computer to understand. You are welcome. I am glad someone notice this subtlety, which I believe most students did not notice. Good job.