This repository contains the programs I developed during my 1st semester in R language. The lab questions were divided into 2 cycles.
- The file ’smoker.csv’ contains results of a survey conducted on 356 per-sons in a city. Each record contains the ID of the person, smoking habit(current-current smoker, former-former smoker, never-never a smoker)and his economic status(Low,middle,high). Write an R program toread the data and construct a two-way table of smoking status versuseconomic status. Also calculate the proportion of people belonging toeach category. You may use the functiontable()to accomplish this.Write the output to a text file.
- Simulate the outcome of tossing a fair die 10000 times and create theprobability distribution of the outcomes. You may use the built-infunctionsample()to do the simulation. Plot the probability functionand check whether the die is fair.
- write an R program to find the sum of the firstnterms of the Fourier series.
- File ’sales.txt’ contains data of price, discount factors and sales volume(number of units sold) of 3 items in three different Indian States. Readthe data and compute the total sales bill of each item in each state.write the output with details in an output file
- Simulate a random list of 1000 patients, each belonging to one of theage groups 40-45,45-0,50-55,50-55,55-60, and each having BP level oneof ”low”,”med”, or ”high” using the data prepare a table indicating thepercentage of people in each category.
- The data file ”price.txt” contains the price (in Rs.) of 3 items for 100consecutive days. Read the data into a data frame.
- Draw a scatter plot of month verses sales
- lm()function
- Construct a multiple regression mode
Note: To refer the complete questions, refer the pdf document in cycle 1.
- The file ’bulbs.dat’ contains life in years of a sample of 1000 bulbs ran-domly chosen from a total of 100000 bulbs produced by a company.Find an approximate probability distribution of the life of bulbs pro-duced by the company. Draw a density plot of the distribution. Checkyour model with a quantile-quantile plot. What percentage of bulbsproduced by the company will have life more than one year ?
- The file pois.dat contains data of no. of accidents in a city for 365 days.Fit a Poisson distribution and calculate the theoretical frequencies.Also compare the theoretical and computed frequencies using a barplot.
- Central limit theorem
- If U1 and U2 are two independent random variables uniformly dis-tributed between 0 and 1 find the density function of U1+U2 using simulation.
- binomial distribution
Note: To refer the complete questions, refer the pdf document in cycle 2.