Plot option
Title
Question
When we type plot(Captaincy$y, ratio) in Console window we obtained the graph between year and victory in File & Plots window but when we type plot(Captaincy$names, Captaincy$played), it shows error exclaiming plot function not found. Why it is so?
R Introduction-to-Data-Frames-in-R 02-03 min 10-20 sec
Answers:
Ideally, it should work. You might want to revisit your code. Alternatively, you should follow the approach given on https://forums.spoken-tutorial.org/question/2767/data-frame-plot/
I think many are facing this problem.
<span style="color: rgb(31, 31, 31); font-family: "Google Sans", "Helvetica Neue", sans-serif; font-size: 16px; white-space-collapse: preserve;">R treats characters for categorical data. To plot characters on the x-axis, you need to convert them into a factor variable. The factor() </span><span style="color: rgb(31, 31, 31); font-family: "Google Sans", "Helvetica Neue", sans-serif; font-size: 16px; white-space-collapse: preserve;">function achieves this. </span><span class="GNVWDDMDE4B ace_keyword" style="font-family: "Lucida Console", monospace; font-size: 13.3333px; white-space: pre; color: blue; user-select: text;">> </span><span class="GNVWDDMDD3B ace_keyword" style="font-family: "Lucida Console", monospace; font-size: 13.3333px; white-space-collapse: preserve; color: blue;">x_factor <- factor(names) </span><span class="GNVWDDMDE4B ace_keyword" style="font-family: "Lucida Console", monospace; font-size: 13.3333px; white-space: pre; color: blue; user-select: text;">> </span><span class="GNVWDDMDD3B ace_keyword" style="font-family: "Lucida Console", monospace; font-size: 13.3333px; white-space-collapse: preserve; color: blue;">plot(x_factor, y). This should Work.</span>
Login to add comment