By R: > mean(dataset$money)
> summary (dataset)
year money shopping
F: 10 Min. : 0.00 NO : 9
S: 11 1st Qu.: 50.00 SOMEWHAT: 3
Median : 100.00 YES : 9
Mean : 93.81
3rd Qu.: 140.00
Max. : 200.00
a) The command should be: table(dataset$shopping)
This is because shopping is not a quantitative variable and it is impossible to calculate the mean of a categorical variable.
b) The command should be: summary(dataset)
This is because R is case sensitive so DATASET is different from dataset.
c) The command should be: barplot(table(dataset$shopping),
main=”Responses to the question, Do you like to shop?”,
xlab=”shopping preference”, ylab=”Number of students”)
This is because the variable is categorical, we can only tally it up, hence we are using the table function. Other than that, (dataset$shopping) must be written exactly like that because we already put the variable in data table to make our task easier.
To get the random numbers by R Studio, we can use the sample function. In this situation, the council president wants 30 randomly chosen signatures to determine the proportion of the students of that university that signed the petition. By using the dollar sign ($) method, we will type the data set we want to use along with the name of the variable. Save the data that contain the 500 signatures with their names (one of the variables) as ‘SIGNATURE’ in .cvs file. Next, type in the sample function in R Studio:
Run the function and we can name the result. For example: