Hello! I'm a new learner of R, and I have a question about a piece of code I was learning about:
>X<-data.frame("var1"=sample(1:5), "var2"=sample(6:10), "var3"=sample(11:15))
> X<-X[sample(1:5),]; X$var2[C(1:3)]= NA
what would be the function of the semi-colon next to X[sample(1:5),]
?
Thanks for your answers in advance!
Hi!
If you have two valid R expressions, say expr1
and expr2
, then these two are equivalent:
expr1
expr2
&
expr1; expr2
So, basically it acts as a line separator so that R evaluates two expressions one after another. It itself adds not much value.
If I may suggest, don't use it.
2 Likes
system
Closed
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.