Categories:
Cloud (204)
Entertainment (11)
Facebook (43)
General (50)
Life (31)
Programming (64)
Technology (430)
Testing (4)
Tools (488)
Twitter (5)
Wearable (26)
Web Design (44)
Collections:
Other Resources:
Build Graph Manually
How to build a graph manually using the built-in graphics package?
✍: FYIcenter.com
You can build a graph manually using low level functions provided
in built-in graphics package as show below:
> # get a sample of x-y coordinates > sample = stats::lowess(cars) > sample $x [1] 4 4 7 7 8 9 10 10 10 11 11 12 12 12 12 13 13 13 13 ... [32] 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25 $y [1] 4.965459 4.965459 13.124495 13.124495 15.858633 18.579691 ... [10] 24.129277 24.129277 27.119549 27.119549 27.119549 27.119549 ... [19] 30.027276 32.962506 32.962506 32.962506 32.962506 36.757728 ... [28] 40.435075 43.463492 43.463492 43.463492 46.885479 46.885479 ... [37] 50.793152 50.793152 56.491224 56.491224 56.491224 56.491224 ... [46] 78.643164 78.643164 78.643164 78.643164 84.328698 > typeof(sample) [1] "list" > # get data ranges in x-axix and y-axis > xrange = range(sample[1]) > xrange [1] 4 25 > yrange = range(sample[2]) > yrange [1] 4.965459 84.328698 > # open a new graph and set the window's range > plot.new() > plot.window(xrange, yrange) > # add x-axix and y-axis > axis(1) > axis(2) > # draw points on x-y coordinates > points(sample) > # draw lines connecting x-y coordinates > lines(sample) > # draw a box around the window > box() > # add a title > title(main="My Graph", sub="(First Test)") > # add labels on x-axix and y-axis > title(xlab="Speed", ylab="Distance")
Here is what the generated graph looks like:
⇒ R Software Environment - Frequently Asked Questions
2023-03-17, ∼1346🔥, 0💬
Popular Posts:
Should I sign in to Google account after installing Google Chrome 55? When you run Google Chrome 55 ...
How to connect FileZilla to an Anonymous FTP Server? If you know the server host name, you can conne...
How to install Mozilla Firefox 2.0 add-on: FireFTP? FireFTP is a Mozilla Firefox 2 add-on that provi...
How to create two columns in Microsoft Word documents? If you want to make a part of a Word document...
What is the port number used for the control connection in FileZilla Server? How to change control c...