Showing posts with label R language. Show all posts
Showing posts with label R language. Show all posts

Tuesday, March 30, 2021

Working with Data Objects in R

   

       

               Working with Data Objects in R


* Data Objects are the fundamental items that one can work with in R language

* Carrying out analysis on one's given data and making sense of the results are the most important reasons of using R . In this article methods of working over a given data set would be provided and along with that understanding the results associated with the data objects of R is the central idea for working over R

* One can learn to use the different forms of data that are associated with R and how to convert the data from one form to another form

* Over R , one would also learn the techniques of sorting and rearranging the data 

* Some of the processes involved with Data Objects manipulation in R are in following manner :

 

==========================

        Manipulating Data Objects in R

==========================


- When you collect the data the very forst step is to get the data over to the R console

 - After the data is imported over to the R console the very first step to perform over the data is to do summary statistics steps for finding out the requisite results from the data

 - One may try to find more of some analytical results from the data from the given summary statistics of R as one may want to manipulate the data that is present over the R software .

 - One may want to reorder the data into newer and more informative manner from the first version of the imported data otherwise one may also try to do a more informative manner of data reordering .

 - Data Manipulation exercises of the given manner could also be performed over the data like extraction of certain parts of complex form of data etc could also be done from the data .

 - As given there are multiple ways of manipulation of the data and thus understanding how to do this is the most important aspect of learning about R because the more one knows about the working of R language and the way R handles the objects , it is better to make use of R as an analytical tool

Saturday, February 27, 2021

Chi-Square Tests of Independence testing using R ( Chi - Square Tests for two-way table )

 

             Chi-Square Tests of Independence

   ( Chi - Square Tests for two-way table )

  ===========================


For effective execution and analysis of the Chi-square test in R language we are going to do the following steps :



1) Step no.1
- We will create a vector in the following format

 data <- c(40,25,19,37,39)

 This "data" vector holds the data for all the students who are registered for the different classes in a school . These are 40 students in class 1 , 25 students for class 2 , 19 students for class 3 , 37 students for class 4 and 39 students for the class 5 .

 

2) Step no. 2 - In R we are going to evaluate whether the values as have been specified in the data variable object "data" are same in value and this equality condition is going to be tested in the NULLHypothesis for the test for evaluation of the data object .

 The Null Hypothesis and the Alternative Hypothesis for checking the validity of both the conditions can be stated and represented in the given manner with the null hypothesis being represented by the symbol (H0) and Null Hypothesis being represented by the symbol (H1) .

 

# H0 is the null hypothesis

H0 : p1 = p2 = p3 = p4 = p5

 

The alternative Hypothesis can be given in the alternate manner i.e,

 

# H1 is the alternative hypothesis

H1 : p1 != p2 != p3 != p4 !=p5

 

3) In the 3rd step , we will run the chi - square test over the function by calling the appropriate function for the evaluation of the same

 

·         chisq.test(data)

 

On the console one can see that the entire data item which had been fed to the prompt has been registed as a memory object . And when one wants to run the Chi-squared test upon the data item object , the values that come as a result of execution of the test are in the given format :

 

X-squared = 11.125, df = 4 , p-value - 0.02519

 

# from the given evaluation one can analyse with the help of the Chi-square table that the critical value which is also acronymised as (T-crit) is found to be as 9.488 with a degree of freedom for the data as 4 and alpha ( degree of significance is found out to be as 0.05 )

which can be found out from the p-value obtained after running the test is that we are basically not wrong in our assumption while framing the null and alternative hypothesis which means that the p-value for the evaluation is less than 0.025 which is less than the alpha value set for the test which is 0.05 then we can reject the null hypothesis as again stating .. we found out the P-value to be lesser than that of the Alpha set for the test.

 


 But had it been the case that the value of the alpha level had also been set at 0.25 then we would not have been at a position to reject the null hypothesis .

 

Conclusion and Verification

 

For the sake of analysing the obtained values if we are again running the chi-square test upon another pair of data in the given format .

 

data1 <- c(35,31,38,27,29)


 And again , we are running the chi-square test on these numbers in the "data1" vector , then the following results would be obtained .

 

> chisq.test(data1)

 

X-squared statistic is 2.5 , degrees of freedom is 4 , p-value is obtained as 0.644 .This means that since one is looking at the alpha value of 0.05 and the p-value is lying towards the left of the normal distribution line then we can say that the Null Hypothesis for the given set of values within the vector "data1" cannot be rejected .. I repeat , for the data values presented in the second vector item , the null hypothesis cannot be rejected .

 



 Again drawing a general conclusion from the experiment .. if we obtain the value of the p-value to be greater than that of the alpha value , then the null hypothesis cannot be rejected .

 

 

Friday, February 19, 2021

Saving and Loading a DataFile in R Language

 


Manipulating Vector Objects in R Language

 


Manipulating Data Objects - A summary of involved steps in R

 


History Commands in R Language

 


Data Object Handling in R Language - Vectors , Dataframes ,Matrices and Lists

 


Commands for Finding Certain Data on a disk in R Language