diff options
author | Akshat Gadhwal <akshatgadhwal1@gmail.com> | 2020-10-06 20:16:49 +0530 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-10-09 23:18:53 +0200 |
commit | e7a3f34959f9c20344c44469581488784d3153b3 (patch) | |
tree | 5fc7326d174a711089ad20f544c370f9b015157b /tests | |
parent | 06d0c8f0565f8ad9bd4d78df1a33500e1178abf4 (diff) |
ADDED test file for R
Diffstat (limited to 'tests')
-rw-r--r-- | tests/syntax-tests/highlighted/R/test.r | 170 | ||||
-rw-r--r-- | tests/syntax-tests/source/R/test.r | 170 |
2 files changed, 340 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/R/test.r b/tests/syntax-tests/highlighted/R/test.r new file mode 100644 index 00000000..16209b47 --- /dev/null +++ b/tests/syntax-tests/highlighted/R/test.r @@ -0,0 +1,170 @@ +[38;2;117;113;94m#[0m[38;2;117;113;94m take input from the user[0m +[38;2;248;248;242mnum [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mas.integer[0m[38;2;248;248;242m([0m[38;2;102;217;239mreadline[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mprompt[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter a number: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mfactorial [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m check is the number is negative, positive or zero[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m([0m[38;2;248;248;242mnum [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mSorry, factorial does not exist for negative numbers[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m([0m[38;2;248;248;242mnum [0m[38;2;249;38;114m=[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mThe factorial of 0 is 1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mfor[0m[38;2;248;248;242m([0m[38;2;248;248;242mi [0m[38;2;249;38;114min[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;249;38;114m:[0m[38;2;248;248;242mnum[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;248;248;242mfactorial [0m[38;2;249;38;114m=[0m[38;2;248;248;242m factorial [0m[38;2;249;38;114m*[0m[38;2;248;248;242m i[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;102;217;239mpaste[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mThe factorial of[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m num [0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mis[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242mfactorial[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mNegative number[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mPositive number[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mZero[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;249;38;114m:[0m[38;2;190;132;255m5[0m[38;2;248;248;242m[0m +[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mval [0m[38;2;249;38;114min[0m[38;2;248;248;242m x[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mval [0m[38;2;249;38;114m=[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m3[0m[38;2;248;248;242m)[0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mnext[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mval[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m[0m +[38;2;249;38;114mrepeat[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;248;248;242m x[0m[38;2;249;38;114m+[0m[38;2;190;132;255m1[0m[38;2;248;248;242m[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m6[0m[38;2;248;248;242m)[0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mbreak[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;166;226;46m`%divisible%`[0m[38;2;248;248;242m [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;249;38;114mfunction[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31my[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;249;38;114m%%[0m[38;2;248;248;242my [0m[38;2;249;38;114m=[0m[38;2;249;38;114m=[0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255mTRUE[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255mFALSE[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;102;217;239mswitch[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mlength[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcolor[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mred[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mshape[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msquare[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mlength[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;190;132;255m5[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;166;226;46mrecursive.factorial[0m[38;2;248;248;242m [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;249;38;114mfunction[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx [0m[38;2;249;38;114m=[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mx [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mrecursive.factorial[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;166;226;46mpow[0m[38;2;248;248;242m [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;249;38;114mfunction[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mx[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31my[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m function to print x raised to the power y[0m +[38;2;248;248;242mresult [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m x[0m[38;2;249;38;114m^[0m[38;2;248;248;242my[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;102;217;239mpaste[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mraised to the power[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m y[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mis[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m result[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mA [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mread.table[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mx.data[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31msep[0m[38;2;249;38;114m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116m,[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;248;248;242m [0m[3;38;2;253;151;31mcol.names[0m[38;2;249;38;114m=[0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116myear[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mmy1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mmy2[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mnrow[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Count the rows in A[0m +[38;2;248;248;242m[0m +[38;2;102;217;239msummary[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;249;38;114m$[0m[38;2;248;248;242myear[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;248;248;242m[0m +[38;2;248;248;242mA[0m[38;2;249;38;114m$[0m[38;2;248;248;242mnewcol [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m A[0m[38;2;249;38;114m$[0m[38;2;248;248;242mmy1 [0m[38;2;249;38;114m+[0m[38;2;248;248;242m A[0m[38;2;249;38;114m$[0m[38;2;248;248;242mmy2 [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Makes a new[0m +[38;2;248;248;242mnewvar [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m A[0m[38;2;249;38;114m$[0m[38;2;248;248;242mmy1 [0m[38;2;249;38;114m-[0m[38;2;248;248;242m A[0m[38;2;249;38;114m$[0m[38;2;248;248;242mmy2 [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Makes a [0m +[38;2;248;248;242mA[0m[38;2;249;38;114m$[0m[38;2;248;248;242mmy1 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;190;132;255mNULL[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Removes [0m +[38;2;102;217;239mstr[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239msummary[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mlibrary[0m[38;2;248;248;242m([0m[38;2;248;248;242mHmisc[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;248;248;242mcontents[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mdescribe[0m[38;2;248;248;242m([0m[38;2;248;248;242mA[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;102;217;239mset.seed[0m[38;2;248;248;242m([0m[38;2;190;132;255m102[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m This yields a good illustration.[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239msample[0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;249;38;114m:[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m15[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mreplace[0m[38;2;249;38;114m=[0m[38;2;190;132;255mTRUE[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242meducation [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mfactor[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mlabels[0m[38;2;249;38;114m=[0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mNone[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSchool[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mCollege[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239msample[0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;249;38;114m:[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m15[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mreplace[0m[38;2;249;38;114m=[0m[38;2;190;132;255mTRUE[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mgender [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mfactor[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mlabels[0m[38;2;249;38;114m=[0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mMale[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mFemale[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mage [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mrunif[0m[38;2;248;248;242m([0m[38;2;190;132;255m15[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mmin[0m[38;2;249;38;114m=[0m[38;2;190;132;255m20[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mmax[0m[38;2;249;38;114m=[0m[38;2;190;132;255m60[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mD [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mdata.frame[0m[38;2;248;248;242m([0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242m gender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m education[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mrm[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;248;248;242m,[0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Table about education[0m +[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Table about education and gender --[0m +[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Joint distribution of education and gender --[0m +[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;249;38;114m/[0m[38;2;102;217;239mnrow[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Add in the marginal distributions also[0m +[38;2;102;217;239maddmargins[0m[38;2;248;248;242m([0m[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239maddmargins[0m[38;2;248;248;242m([0m[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;249;38;114m/[0m[38;2;102;217;239mnrow[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Generate a good LaTeX table out of it --[0m +[38;2;102;217;239mlibrary[0m[38;2;248;248;242m([0m[38;2;248;248;242mxtable[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mxtable[0m[38;2;248;248;242m([0m[38;2;102;217;239maddmargins[0m[38;2;248;248;242m([0m[38;2;102;217;239mtable[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;249;38;114m/[0m[38;2;102;217;239mnrow[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;248;248;242m [0m[3;38;2;253;151;31mdigits[0m[38;2;249;38;114m=[0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m0[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;248;248;242m[0m +[38;2;102;217;239mby[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m mean[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mby[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m sd[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mby[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m summary[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242ma [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mmatrix[0m[38;2;248;248;242m([0m[38;2;102;217;239mby[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mage[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mlist[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m,[0m[38;2;248;248;242m D[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m mean[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mnrow[0m[38;2;249;38;114m=[0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mrownames[0m[38;2;248;248;242m([0m[38;2;248;248;242ma[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mlevels[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242mgender[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mcolnames[0m[38;2;248;248;242m([0m[38;2;248;248;242ma[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mlevels[0m[38;2;248;248;242m([0m[38;2;248;248;242mD[0m[38;2;249;38;114m$[0m[38;2;248;248;242meducation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242ma[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mxtable[0m[38;2;248;248;242m([0m[38;2;248;248;242ma[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mdat [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mread.csv[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mfile[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mfiles/dataset-2013-01.csv[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mheader[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mTRUE[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242minterim_object [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mdata.frame[0m[38;2;248;248;242m([0m[38;2;102;217;239mrep[0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;249;38;114m:[0m[38;2;190;132;255m100[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m10[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;248;248;242m [0m[38;2;102;217;239mrep[0m[38;2;248;248;242m([0m[38;2;190;132;255m101[0m[38;2;249;38;114m:[0m[38;2;190;132;255m200[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m10[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;248;248;242m [0m[38;2;102;217;239mrep[0m[38;2;248;248;242m([0m[38;2;190;132;255m201[0m[38;2;249;38;114m:[0m[38;2;190;132;255m300[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m10[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mobject.size[0m[38;2;248;248;242m([0m[38;2;248;248;242minterim_object[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;102;217;239mrm[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116minterim_object[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;102;217;239mls[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m +[38;2;102;217;239mrm[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mlist[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mls[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mvector1 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m5[0m[38;2;248;248;242m,[0m[38;2;190;132;255m9[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mvector2 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m10[0m[38;2;248;248;242m,[0m[38;2;190;132;255m11[0m[38;2;248;248;242m,[0m[38;2;190;132;255m12[0m[38;2;248;248;242m,[0m[38;2;190;132;255m13[0m[38;2;248;248;242m,[0m[38;2;190;132;255m14[0m[38;2;248;248;242m,[0m[38;2;190;132;255m15[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242marray1 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239marray[0m[38;2;248;248;242m([0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;248;248;242mvector1[0m[38;2;248;248;242m,[0m[38;2;248;248;242mvector2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mdim[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mvector3 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m9[0m[38;2;248;248;242m,[0m[38;2;190;132;255m1[0m[38;2;248;248;242m,[0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mvector4 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m6[0m[38;2;248;248;242m,[0m[38;2;190;132;255m0[0m[38;2;248;248;242m,[0m[38;2;190;132;255m11[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m14[0m[38;2;248;248;242m,[0m[38;2;190;132;255m1[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;190;132;255m6[0m[38;2;248;248;242m,[0m[38;2;190;132;255m9[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242marray2 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239marray[0m[38;2;248;248;242m([0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;248;248;242mvector1[0m[38;2;248;248;242m,[0m[38;2;248;248;242mvector2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mdim[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mmatrix1 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m array1[0m[38;2;248;248;242m[[0m[38;2;248;248;242m,[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m][0m[38;2;248;248;242m[0m +[38;2;248;248;242mmatrix2 [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m array2[0m[38;2;248;248;242m[[0m[38;2;248;248;242m,[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m][0m[38;2;248;248;242m[0m +[38;2;248;248;242mresult [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m matrix1[0m[38;2;249;38;114m+[0m[38;2;248;248;242mmatrix2[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mresult[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mcolumn.names [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mCOL1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mCOL2[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mCOL3[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mrow.names [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mROW1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mROW2[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mROW3[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mmatrix.names [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mMatrix1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mMatrix2[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mresult [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239marray[0m[38;2;248;248;242m([0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;248;248;242mvector1[0m[38;2;248;248;242m,[0m[38;2;248;248;242mvector2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mdim[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mdimnames[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mlist[0m[38;2;248;248;242m([0m[38;2;248;248;242mrow.names[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;248;248;242m column.names[0m[38;2;248;248;242m,[0m[38;2;248;248;242m matrix.names[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mresult[0m[38;2;248;248;242m[[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mresult[0m[38;2;248;248;242m[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mresult[0m[38;2;248;248;242m[[0m[38;2;248;248;242m,[0m[38;2;248;248;242m,[0m[38;2;190;132;255m2[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Load the package required to read JSON files.[0m +[38;2;102;217;239mlibrary[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mrjson[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mresult [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;248;248;242mfromJSON[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mfile[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116minput.json[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mresult[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mx [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m151[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m174[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m138[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m186[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m128[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m136[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m179[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m163[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m152[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m131[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242my [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m63[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m81[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m56[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m91[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m47[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m57[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m76[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m72[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m62[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m48[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mrelation [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mlm[0m[38;2;248;248;242m([0m[38;2;248;248;242my[0m[38;2;249;38;114m~[0m[38;2;248;248;242mx[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mrelation[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mrelation [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mlm[0m[38;2;248;248;242m([0m[38;2;248;248;242my[0m[38;2;249;38;114m~[0m[38;2;248;248;242mx[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mpng[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mfile[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mlinearregression.png[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mplot[0m[38;2;248;248;242m([0m[38;2;248;248;242my[0m[38;2;248;248;242m,[0m[38;2;248;248;242mx[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mcol[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mblue[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mmain[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHeight & Weight Regression[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m[0m +[38;2;102;217;239mabline[0m[38;2;248;248;242m([0m[38;2;102;217;239mlm[0m[38;2;248;248;242m([0m[38;2;248;248;242mx[0m[38;2;249;38;114m~[0m[38;2;248;248;242my[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mcex[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m1.3[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mpch[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m16[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mxlab[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mWeight in Kg[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mylab[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHeight in cm[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mdev.off[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mdata [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mEast[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mWest[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mEast[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mNorth[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mNorth[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mEast[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mWest[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mWest[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mWest[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mEast[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;230;219;116m"[0m[38;2;230;219;116mNorth[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mdata[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;102;217;239mis.factor[0m[38;2;248;248;242m([0m[38;2;248;248;242mdata[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242mfactor_data [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mfactor[0m[38;2;248;248;242m([0m[38;2;248;248;242mdata[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;248;248;242mfactor_data[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mprint[0m[38;2;248;248;242m([0m[38;2;102;217;239mis.factor[0m[38;2;248;248;242m([0m[38;2;248;248;242mfactor_data[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;248;248;242mv [0m[38;2;249;38;114m<-[0m[38;2;248;248;242m [0m[38;2;102;217;239mc[0m[38;2;248;248;242m([0m[38;2;190;132;255m7[0m[38;2;248;248;242m,[0m[38;2;190;132;255m12[0m[38;2;248;248;242m,[0m[38;2;190;132;255m28[0m[38;2;248;248;242m,[0m[38;2;190;132;255m3[0m[38;2;248;248;242m,[0m[38;2;190;132;255m41[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;248;248;242m[0m +[38;2;117;113;94m#[0m[38;2;117;113;94m Give the chart file a name.[0m +[38;2;102;217;239mpng[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mfile[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mline_chart_label_colored.jpg[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m +[38;2;102;217;239mplot[0m[38;2;248;248;242m([0m[38;2;248;248;242mv[0m[38;2;248;248;242m,[0m[3;38;2;253;151;31mtype[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mo[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mcol[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mred[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mxlab[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mMonth[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mylab[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mRain fall[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mmain[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mRain fall chart[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m[0m diff --git a/tests/syntax-tests/source/R/test.r b/tests/syntax-tests/source/R/test.r new file mode 100644 index 00000000..2d67992b --- /dev/null +++ b/tests/syntax-tests/source/R/test.r @@ -0,0 +1,170 @@ +# take input from the user +num = as.integer(readline(prompt="Enter a number: ")) +factorial = 1 +# check is the number is negative, positive or zero +if(num < 0) { +print("Sorry, factorial does not exist for negative numbers") +} else if(num == 0) { +print("The factorial of 0 is 1") +} else { +for(i in 1:num) { +factorial = factorial * i +} +print(paste("The factorial of", num ,"is",factorial)) +} + +x <- 0 +if (x < 0) { +print("Negative number") +} else if (x > 0) { +print("Positive number") +} else +print("Zero") + +x <- 1:5 +for (val in x) { +if (val == 3){ +next +} +print(val) +} + +x <- 1 +repeat { +print(x) +x = x+1 +if (x == 6){ +break +} +} + +`%divisible%` <- function(x,y) +{ +if (x%%y ==0) return (TRUE) +else return (FALSE) +} + +switch("length", "color" = "red", "shape" = "square", "length" = 5) +[1] 5 + +recursive.factorial <- function(x) { +if (x == 0) return (1) +else return (x * recursive.factorial(x-1)) +} + +pow <- function(x, y) { +# function to print x raised to the power y +result <- x^y +print(paste(x,"raised to the power", y, "is", result)) +} + +A <- read.table("x.data", sep=",", + col.names=c("year", "my1", "my2")) +nrow(A) # Count the rows in A + +summary(A$year) + +A$newcol <- A$my1 + A$my2 # Makes a new +newvar <- A$my1 - A$my2 # Makes a +A$my1 <- NULL # Removes +str(A) +summary(A) +library(Hmisc) +contents(A) +describe(A) + +set.seed(102) # This yields a good illustration. +x <- sample(1:3, 15, replace=TRUE) +education <- factor(x, labels=c("None", "School", "College")) +x <- sample(1:2, 15, replace=TRUE) +gender <- factor(x, labels=c("Male", "Female")) +age <- runif(15, min=20,max=60) + +D <- data.frame(age, gender, education) +rm(x,age,gender,education) +print(D) + +# Table about education +table(D$education) + +# Table about education and gender -- +table(D$gender, D$education) +# Joint distribution of education and gender -- +table(D$gender, D$education)/nrow(D) + +# Add in the marginal distributions also +addmargins(table(D$gender, D$education)) +addmargins(table(D$gender, D$education))/nrow(D) + +# Generate a good LaTeX table out of it -- +library(xtable) +xtable(addmargins(table(D$gender, D$education))/nrow(D), + digits=c(0,2,2,2,2)) + +by(D$age, D$gender, mean) +by(D$age, D$gender, sd) +by(D$age, D$gender, summary) + +a <- matrix(by(D$age, list(D$gender, D$education), mean), nrow=2) +rownames(a) <- levels(D$gender) +colnames(a) <- levels(D$education) +print(a) +print(xtable(a)) + +dat <- read.csv(file = "files/dataset-2013-01.csv", header = TRUE) +interim_object <- data.frame(rep(1:100, 10), + rep(101:200, 10), + rep(201:300, 10)) +object.size(interim_object) +rm("interim_object") +ls() +rm(list = ls()) + +vector1 <- c(5,9,3) +vector2 <- c(10,11,12,13,14,15) +array1 <- array(c(vector1,vector2),dim = c(3,3,2)) +vector3 <- c(9,1,0) +vector4 <- c(6,0,11,3,14,1,2,6,9) +array2 <- array(c(vector1,vector2),dim = c(3,3,2)) +matrix1 <- array1[,,2] +matrix2 <- array2[,,2] +result <- matrix1+matrix2 +print(result) + +column.names <- c("COL1","COL2","COL3") +row.names <- c("ROW1","ROW2","ROW3") +matrix.names <- c("Matrix1","Matrix2") +result <- array(c(vector1,vector2),dim = c(3,3,2),dimnames = list(row.names, + column.names, matrix.names)) +print(result[3,,2]) +print(result[1,3,1]) +print(result[,,2]) + +# Load the package required to read JSON files. +library("rjson") +result <- fromJSON(file = "input.json") +print(result) + +x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131) +y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) +relation <- lm(y~x) +print(relation) + +relation <- lm(y~x) +png(file = "linearregression.png") +plot(y,x,col = "blue",main = "Height & Weight Regression", +abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm") +dev.off() + +data <- c("East","West","East","North","North","East","West","West","West","East","North") +print(data) +print(is.factor(data)) +factor_data <- factor(data) +print(factor_data) +print(is.factor(factor_data)) + +v <- c(7,12,28,3,41) + +# Give the chart file a name. +png(file = "line_chart_label_colored.jpg") +plot(v,type = "o", col = "red", xlab = "Month", ylab = "Rain fall", main = "Rain fall chart") |