Question

Exercise 2.2. Type the following code in your terminal. v <- factor(c(2, 3, 5, 7, 11)) a. Convert v to character wi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

> #######Solution#############
> v<-factor(c("2","3","5","7","11"))
> v
[1] 2 3 5 7 11
Levels: 11 2 3 5 7
> ######(a)-solution#####
> character_V<-as.character(v)
> character_V   
[1] "2" "3" "5" "7" "11"
> #### Explaination #########
> #When I convert v by using as.character() function, every factor with level 2,3,5,7 and 11 convert into a character .
>   
> ######(b)-solution##############
> numeric_v<-as.numeric(v)
> numeric_v
[1] 2 3 4 5 1
> ####Explaination#########
> ##Basically as.numeric() function is a generic function.
> ##when I covert a v(factor) with level 2,3,5,7 and 11 to quantitative variable,
> ##by using as.numeric() function ,every number is converted into a ranking, and the original values are lost.
> ######(c)-solution#############
> integer_v<-as.numeric(as.character(v))
> integer_v
[1] 2 3 5 7 11
> ####Explaination#########
> ##we can convert values of v into integer by combining two functions as.numeric() and as.character().

Add a comment
Know the answer?
Add Answer to:
Exercise 2.2. Type the following code in your terminal. v <- factor(c("2", "3", "5", "7", "11"))...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Exercise 2.2. Type the following code in your terminal. v <- factor(c("2", "3", "5", "7", "11"))...

    Exercise 2.2. Type the following code in your terminal. v <- factor(c("2", "3", "5", "7", "11")) a. Convert v to character with as.character. Explain what just happened. b. Convert v to numeric with as. numeric. Explain what just happened. c. How would you convert the values of v to integers?

  • u =<4, -5 > v=<3, 2 > | 2u – vl = ? Whole number. <7,...

    u =<4, -5 > v=<3, 2 > | 2u – vl = ? Whole number. <7, -1, 5 >.< 2, 3, 1>=? whole number

  • Exercise 8 . Let n = 5-11-12 = 660. (A) Find i < y < n...

    Exercise 8 . Let n = 5-11-12 = 660. (A) Find i < y < n such that 1 mod(5), 3 mod(11), y 11 mod(12). (B) Suppose r E Z such that 4 mod(5) and 8 mod ( (11) Briefly explain why 55 divides +y, where y is the number from Part Show that, for all nEN, Exercise 9. 13 (29" -3")

  • 1) Convert the following C code into MIPS assembly For (b-0; b<N, ++b) C-Z[b] If (Z[b]>W)...

    1) Convert the following C code into MIPS assembly For (b-0; b<N, ++b) C-Z[b] If (Z[b]>W) W-Z[b] note: assign array Z, integers C and integer W to registers $SO, $S1, $S2 respectively. Put comments for each assembly line to explain its purpose.

  • Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1;...

    Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...

  • The following are three questions on a practice examination for Computer Science 102. I need help...

    The following are three questions on a practice examination for Computer Science 102. I need help not only getting the answer but i need careful explanations and work shown for each of the three problems because some of these are "trick" questions: SHOW YOUR WORK AND LOGIC ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 point What is printed to the screen with the code below? int main double a -5/2; cout << a; Type your answer... 23 1 point Given the following code...

  • 7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions....

    7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a,b, i and j are in registers Ss0, Ss1, St0, and St1, respectively. Also, assume that register SS2 holds the base address of the array D. for(i-0; i<a; i++) for(j=0 ; j<b; j++)

  • Exercise 11-23 Algo Find the value x for which: (Round your answers to 2 decimal places....

    Exercise 11-23 Algo Find the value x for which: (Round your answers to 2 decimal places. You may find it useful to reference the appropriate table: chi square table or F table) a. P(F (8,29) 2 x) - .50 b. P(F(8,29x.025 c. P(F(8,29) < x) - .ese d. P(F(8,29)x-025

  • 5 3 1 Let ū = < 2,-3> V = <-2,0 > w = <3,3 >...

    5 3 1 Let ū = < 2,-3> V = <-2,0 > w = <3,3 > Graph vectors ū, ū, and w in standard position with corresponding terminal points, A, B, and C, respectively. (72 point) What is the length of the altitude of AABC from vertex A? (72 point) -5 -3 -1 -1 0 1 3 5 -3 -5

  • Please explain answer :D Question 5 (5 marks] Consider the syntactically correct C code below, which...

    Please explain answer :D Question 5 (5 marks] Consider the syntactically correct C code below, which is missing a function print_diagonal include <stdio.h> • typedef int Table(100) (100); */• print diagonal (T, n) . Given a Table T, which will have n rows and n columns, print all of the 1 entries on the main diagonal of T (that is, entries whose row number and column number are equal). Remember to print a newline at the end. / ► /...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT