
Every now and then, some students ask me about the reason why their programs (e.g. R) cannot be executed and errors show up one after another.
They’ll be angry just because R doesn’t know how to compute 9x if x=2 (of course 9x equals to 18), R doesn’t understand inequations like a<x<b, and an error will occur in R when they use conditions like if (x=a), etc.
Indeed they are frustrated. They cannot imagine that these clever computers cannot understand so simple words. They are amazed, somehow.
However, there ARE differences between languages of human beings and computers, which is unavoidable. When we are learning a computer language, I think the teacher should emphasize this point.
Consequently, there are rules to guide us. Usually we call these “rules” SYNTAX. When you understand the syntax of a computer language, you’d get to know why errors occur: 9x doesn’t mean 9*x; a<x<b doesn’t stands for a<x & x<b; in if (x=a), the expression “x=a” won’t generate a boolean value (but here “(x=a)” might return a boolean value using R, you may consider about the reason yourself).
There are too many cases to show the misunderstandings toward computer languages. The other day, two classmates of mine asked me whether **R **can draw a plot for Pareto distribution. For me, this is an interesting question, because when they raise this question, I’m clear that they still don’t understand a general principle: how does a program draw a plot? If they do, their problem would be just an apple pie because they’ve already know the pdf/cdf of Pareto distribution. Apparently what they want is just type a command (such as “plot pareto(a)”), then the program will generate a graph for them.
I don’t want write too much on this specified problem. In my opinion, there are some basic facts that we should know clearly about; for example:
Your program will never generate a real continuous object (variable, graph, etc) even though it seems to be continuous. Therefore you may only generate a discrete sequence like seq(1, 10, 0.01), but to generate a continuous variable x on the interval [1, 10] is impossible.
Appendix:
> x=2
> 9x
Error: syntax error in "9x"
> 1<x<3
Error: syntax error in "1<x<"
> if(x=2){print("hello")}
Error: syntax error in "if(x="
> 9*x
[1] 18
> 1<x & x<3
[1] TRUE
> if(x==2){print("hello")}
[1] "hello"
赞赏
作为一名没有固定工作的自由职业者,我非常感谢您通过捐赠的方式来支持我的写作和开源软件开发。当然,捐赠纯属自愿。无论金额多少,都是一片诚挚的心意。支付方式如下:
| 微信 | ← 奋力支开它俩 → | 支付宝 |
|---|---|---|
![]() |
其它爱心通道 ↓ Venmo: @yihui_xie Zelle: xie@yihui.name PayPal: xie@yihui.name |
![]() |
若使用 Venmo/Zelle/Paypal,请添加备注“gift”或“donation”,以免捐赠被视为我的可税收入。若使用 Paypal,支付类型请选 Family and Friends,而不要选 Goods and Services。
在不影响生活的前提下,我会将收到的捐赠以尽量大的比例回馈给开源社区和慈善机构。作为参考,2024-25 年间我共收到约三万美元捐赠,完税后我转手捐出了一万五千美元。

