Connect with us

Hi, what are you looking for?

Data Science

Data Visualization Practice

Data Visualization In R
Data Visualization In R

In this practice, we going to data visualization practice for game data. we will try to visualize the data in the game, what you need to know before starting this training is stated under this paragraph.

You Need to Know
  1. Data Visualization In R
  2. Data Analyze In R
  3. Creating Dataset In R
  4. Control Structures In R
Creating Score Dataset

We need a basic high score for pulling score data, we can create this dataset in r with data.frame function if you read the previous article you know creating datasets if you don’t know please read Creating Dataset In R.

Player_Name = c("Player1" , "Player2" , "Player3" , "Player4" , "Player5" , "Player6")
Game_Score = c(100 , 200 , 300 , 200 , 350 , 1200)

Game_Table = data.frame(Player_Name , Game_Score)
Comparing Scores On a Chart

The easiest way to read our data is to analyze it in a chart first, because this dataset is small, let’s examine the data in the chart in the other example, we will follow a different path for the large dataset.

Player_Index = c(1 , 2 , 3 , 4 , 5 , 6)
barplot(Player_Index , Game_Score)

The chart we create is simple but useful now let’s sort them by value and then make them more useful with labels and styles. When we start working with large data sets, we’ll see why more complex graphs are important.

past = 0
list = c()
count = 0

for(i in Game_Score)
   count = count + 1
   if(i > past)
      list[count] = i
   past = i

It is more accurate to leave the style phase and label insertion operations to the end of your projects while we have a new dataset ready, and we will create a chart using this dataset. You will understand why we use these described concepts when we move to large data sets.

barplot(list , Game_Score)

To use sorted data, we use the list data type, add labels, and install them from this standard chart.

barplot(list , Game_Score , xlab = "Player Index" , ylab = "Score",
col = "red" , density = 10 , border = "black" , main = "Game Score Char")

# density = determines the color ratio inside the column.
# border = Determines the color of the edges

We’ve finished the basic editing, we haven’t learned a few of these arguments, so you can find the list below, it would be good to learn these arguments before moving on to the next project.

Comparing Large Datasets on Graphic

Creating graphics with big data can be more complicated, you can download the dataset we will use in this example from here, this graphic gives us the important values of the movies.

film <- read.csv2("film.csv") # Reading dataset
str(film) # Detail this dataset

After getting the details, we can start to create the chart, in this example we will examine the movie times by years.

barplot(strtoi(film$Length[2:20]) , strtoi(film$Year[2:20]))

The arguments here may have confused you, after looking we can see why we made such a graph. The strtoi function converts string data to int data type, [2:20] the reason for specifying indexes is that the initial value is NA.

This graph gives the duration of the movie by years and shows the duration of the movie by comparing it and shows how long the audience watched at what time.

plot(strtoi(film$Year[1:50]) , strtoi(film$Popularity[1:50]) , 
xlab = "Year" , ylab = "Popularity") # Popularity and Year
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like


This article is prepared to explain concepts that will be important for programming beginners such as data types, variables, heap and stack, and operators....


This article was created for those who want to use functional programming in their career or who are learning new programming paradigms. We will...


Functions are pieces of code that combine the integrity of the code used to perform a task into a single structure. If you are...


Computers can solve an event in different ways, we call these ways algorithms, each algorithm works differently from the others and has different processing...