These questions use R. 1. Enter the following values into a data vector named te
ID: 3309845 • Letter: T
Question
These questions use R.
1. Enter the following values into a data vector named testdata: 45.4 44.2 36.8 35.1 39.0 60.0 47.4 41.1 45.8 35.6 Calculate the difference between the 2nd and 7th entries of this vector using only reference indices. 2. 3. Calculate the median of testdata. . Sort the values in this data vector from highest to lowest, and save the sorted version as a 5. 6. 7. vector named sortHL.testdata. What does sortHLtestdata[-4] do? What does testdatal-c(2,7,9)] do? Why do you think the c() function necessary in the previous question?Explanation / Answer
1] enter the data vector named in testdata
testdata=c(45.4,44.2,36.8,35.1,39.0,60.0,47.4,41.1,45.8,35.6)
testdata
2] diff=testdata[2]-testdata[7]
diff
[1] -3.2
we find the difference between the 2nd and 7th entries of the vector above is -3.2
3] in finding median in 2 methods
1st is we put in r
median(testdata)
[1] 42.65
and 2nd method is
just put in r
summary(testdata)
we get hole out put
> summary(testdata)
Min. 1st Qu. Median Mean 3rd Qu. Max.
35.10 37.35 42.65 43.04 45.70 60.00
so, we get median is 42.65
4] sorting the data in to higest to lowest
we pur in r commad
sorthHL.testdata=sort.list(testdata, partial = NULL, na.last = TRUE, decreasing = TRUE, method ="radix")
we get r out put is
> sorthHL.testdata
[1] 6 7 9 1 2 8 5 3 10 4
5] sorthHL.testdata[-4]
[1] 6 7 9 2 8 5 3 10 4
this command removing 4th entries in sorth.testdata
so we get ouput in r is, 6 7 9 2 8 5 3 10 4
6] sorthHL.testdata[-c(2,7,9)]
[1] 6 9 1 2 8 3 4
this command removing 2nd, 7th and 9th entries at one time
and we get out in r is, 6 9 1 2 8 3 4
7] yes,
"c" stands for "combine". You are combining items together into one vector
c() is necessary because c() function used in combing the values, so that's why this is needed.
------------------***---------------------------------------------***--------------------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.