 Welcome to dealing with materials data, we are going to look at the collection, analysis and interpretation of data and we are in the first module, the module is introduction to R and we have looked at how to enter data into R and do analysis with the data and plot the data and things like that. So we are going to continue, we have been using one dataset which is about certain elements, their crystal structures, densities and melting points. So we are going to continue with that and in one of the earlier sessions I showed one way of entering the data as a table and working with it and I also gave the problem or modification to what we did by adding the name of the element in the table as part of the data and that is what we are going to do in today's session. So let us look at, so we are going to look at tabulated data, the second version and just to remind you these are the information that is in the data. So we are going to consider some elements and we are going to consider their crystal structure whether they are FCC, BCC or HCP, their density that is given in kilograms per meter cube and melting point which is reported in degree Celsius and this data is taken from Raghavan's material science and engineering textbook. So for FCC we have chosen aluminum, nickel, gold, silver and copper and the two numbers are the densities and melting points respectively. So and for BCC we are going to consider iron, chromium, molybdenum, vanadium and tungsten and for HCP magnesium, beryllium, zinc, cadmium and titanium. So this is the data and we want to enter this data and work with it and plot it and so on and so forth. So this is a slight modification to the earlier version. In the earlier version the data of the melting points and densities along with the crystal structure was given and the rows were labeled according to the element and the columns were named as to whether it is the melting point or density or crystal structure etc. But what we want to do in this case is to remove the labeling of the rows instead make the name of the element as part of the data. So we will now have only columns to be labeled and the columns will be elements, crystal structure, density and melting point and rest of it would be data and we are going to enter the data in R and we are going to use a library called data dot table and we are going to store the matrix as data table and we are also going to use type convert command and there are also going to be some minor differences in the way in which we are going to do the plotting and so we are going to use the tilde symbol for doing the plotting and tilde symbol means that we are plotting a formula. So we are going to say that melting point as a function of density so it should be considered like a functional relationship and the plotting should be done. So that is what we are going to do. So let us do that, let us first look at the way to enter the data and here is the script that does that. So as we did earlier so we are going to say that elements is a matrix and these are the data that is entered into the matrix. So you can see that the name of the element, the crystal structure, the density and the melting point and then there is nickel FCC 8900, 1453, gold FCC 19320, 1063 and so on. So we have listed for all of them so there are 5 FCC and 5 BCC and 5 HCP. So number of columns is 4 so and the data is stored by row so what we mean by row equal to true is that the data is stored as aluminum FCC 2760 so that is one row and number of columns is 4 so it has to take 4 data points and next 4 data points will form the next row and so on and so forth. So this is how this matrix is stored, this matrix has 4 columns and it is stored by row and there are 15 rows. So we are going to give names for these columns so that is what column names does so for this matrix which is stored in the variable elements and we are going to give the column names and the column names are elements, crystal structure, density and melting point. And then we invoke the library data.table and so that library helps us store the elements matrix as a data table. And then we are going to use type.convert because as you can see there are strings and there are numbers and so this type conversion helps us make sure that the data is stored appropriately. So this is what this script does and so let us open R and run the script and see what happens. So as usual we open R and the first thing we have to check is that we have the right version so R version is 3.6.1 action of the toast so this is what we have been using and I have to know which directory I am in so that is done by the command getwd that works for get working directory so that is what it stands for and it says I am in home guru so I have to go to the working directory which is in desktop and it is called dealing with materials data I need to go to the scripts directory in there. So we set so now if you say get working directory you sorry get working directory and you get the answer that I am in home guru desktop dealing with materials data scripts and this script that I showed you is stored as elements 2.R there so we need to source the script so that is what we are going to do elements 2.R and when we source okay so there is some information that is given data.table is using two threads and so you can get information about it anyway so to know whether our data is stored properly let us just check the structure of elements and so we get and what is the class okay so list okay so let us source the elements 2.R so that is okay so there is a mistake so let us source the table okay so we have sourced it and we can check the data element so now we can see that the elements is stored as a data table and it has elements crystal structure density and melting point and the elements are named and the crystal structure is given density is given and melting point is given so we can also use the head which will give you the top six data points and tail which will give you the bottom data points and of course you can also find out the information so it is we have a data table and data frame and it consists of elements crystal structure density melting point and so on so you can also use the command class we already know that it is going to be data table and data frame so at this point I want to mention that we store things as table or we can also store as data frame which is what the next session we are going to do and it is sometimes favorable to store data as a table especially if it is a very large data that is related to the optimization of the R code and that is one aspect that we are not going to spend too much time in this course in fact we are going to do very little of code optimization so this is more of a tutorial version just to learn R and how to work with it but if you want to make more efficient code you may have to spend more time and learn some of these other aspects but we are not going to do it in these sessions. Now that we have the data so we can try to plot the data so to plot the data we are going to say I am going to say that x is so let us just say x is from the elements the density so you can see that x has chosen all the densities and let us say that y is nothing but the melting points so it is null because I have made a mistake so let us look at it now y has so we are going to say plot we are going to say y as a function of x is what it has to plot so you can do this then you will get a plot so we have got the plot of course we know how to label the x the x label should be density and y label should be melting point so well we have got density versus melting point. We also want to color let us say the points according to their castle structures because it is not clear now which is FCC which is BCC which is HCP so to do that I am going to use the common color and that is according to elements so that is now you can see that there are three different colors there are greens and then reds and then blacks and they correspond to the three different crystal structures. So this is similar to what we have been doing so you can load the data and in this case we loaded the data as data table in that sense also it is slightly different from what we have done earlier and then you can take individual columns and you can plot them and you can give the name to the x y axis of course there is one more thing that we did last time so we can do that here also we can give a name to the plot give a name and as you can see density versus melting point name is given so you can do all these things and we have also color coded the points in this scatter plot to show the different crystal structures so there are three different crystal structures so you see three different colors. So this is another way of doing it and of course there is one more way which is what we are going to do is to store the data as a data frame and work with it so that we will do in the next session. Thank you.