Question

Create a list in R named hw_list containing the quantities 'homework quantities',v; w; z; A and...

Create a list in R named hw_list containing the quantities 'homework quantities',v; w; z; A and name these quantities comp_1, comp_2, comp_3, comp_4 and comp_5 respectively

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The above problem can be solved in the following steps-

There are two ways in which we can create a list with certain items and name those items. I will explain both the ways here-

FIRST WAY-

STEP 1- First we will declare the list and initialize the hw_list with the items mentioned in ques.

STEP 2- Then using the names function in R, we will name all the items as comp_1, comp_2, comp_3 etc.

R CODE-

#initialize the list with all the items mentioned in question
hw_list <- list('homework quantities','v', 'w', 'z', 'A')
#use the names function with parameter as hw_list created above
#give the names of all items
names(hw_list) <- c('comp_1', 'comp_2','comp_3','comp_4','comp_5')
#print the list
print(hw_list)

IMAGE OF CODE-

e non hanno semp e 1 #initialize the list with all the items mentioned in question 2 hw_list <- list(homework quantities,

OUTPUT-

$comp_1 [1] homework quantities $comp_2 [1] $comp_3 [1] W $comp_4 [1] Z $comp_5 [1] A

SECOND WAY-

Now we will discuss the second approach.

STEP 1- In this approach, we can directly give the name and item while initializing the list in the list function.

While inserting items, just add the name and item as a key-value pair in the list function as shown in below syntax.

R CODE-

#create and intialize the list
#in the initialization itself,give the name of item and item value as key-value pair
hw_list <- list("comp_1"='homework quantities', "comp_2"='v',"comp_3"='w',"comp_4"='z',"comp_5"= 'A')
#print the list
print(hw_list)

IMAGE OF CODE-

1 #create and intialize the list 2 #in the initialization itself, give the name of item and item value as key-value pair 3 hw

OUTPUT-

$comp_1 [1] homework quantities $comp_2 [1] V $comp_3 [1] W $comp_4 [1] Z $comp_5 [1] A

If this answer helps, please give an up vote and feel free to comment for any query.

Add a comment
Know the answer?
Add Answer to:
Create a list in R named hw_list containing the quantities 'homework quantities',v; w; z; A and...
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
  • Create a java program that reads an input file named Friends.txt containing a list 4 names...

    Create a java program that reads an input file named Friends.txt containing a list 4 names (create this file using Notepad) and builds an ArrayList with them. Use sout<tab> to display a menu asking the user what they want to do:   1. Add a new name   2. Change a name 3. Delete a name 4. Print the list   or 5. Quit    When the user selects Quit your app creates a new friends.txt output file. Use methods: main( ) shouldn’t do...

  • let U= {q,r,s,t,u,v,w,x,y,z}; A= {q,s,u,w,y};and C={v,w,x,y,z,}; list the members of the indicated set , using set braces A'u B A

    4.let U= {q,r,s,t,u,v,w,x,y,z}; A= {q,s,u,w,y};and C={v,w,x,y,z,}; list the members of the indicated set , using set braces A'u B A.{Q,R,S,T,V,X,Y,Z} B.{S,U,W} C.{R,S,T,U,V,W,X,Z} D.{Q,S,T,U,V,W,X,Y}

  • Create a list named alpha containing 10 components of type int. Output the value of the...

    Create a list named alpha containing 10 components of type int. Output the value of the first component of the list alpha. Set the value of the fifth component of the list alpha to 62. Set the value of the tenth component of the list to three times the value of the fifth component of alpha. Use a for loop to output the value of a component of alpha if its index is a multiple of 3. in python

  • Use R language pls • Create a list containing 3 vectors: your favorite food (at least...

    Use R language pls • Create a list containing 3 vectors: your favorite food (at least 4), your expected grade at the two midterms and the final exam (1 to 100), your date of birth (feel free to lie). • name the vectors: food, grades, DOB • Create a new list just with the grades and the DOB. . Using the previous list, create a new list just with the grades and the food. • Compute the median and the...

  • 1. Provide code to create a selection list named orderDay containing the values and option text...

    1. Provide code to create a selection list named orderDay containing the values and option text SAT and SUN placed in the Weekend option group, and the option text MON, TUE, WED, THU, and FRI placed in the Weekday option group. 2. Provide code to create two radio buttons for the compType field with the values PC and Mac. Make PC the default value. 3. Kelsey has written the following code to create a data field for users to select...

  • Create a python file named FQ2 to do the following: - Create a list L. L...

    Create a python file named FQ2 to do the following: - Create a list L. L = [{'name': 'Sami', 'children': ['Fahad', 'Salwa', 'Khaled']}, {'name': 'Ahmed', 'children': ['Adel', 'Abeer']}, {'name': 'Samia', 'children': []}, {'name': 'Jameela', 'children': ['Najla', 'Salwa', 'Jamal']}] - Create a function called Populate that takes a list as a parameter. - The function will add each parent along with his children to the Database.   

  • With a single query create a new table named QBITEM containing the ITEMNAME, AND ITEMTYPE of...

    With a single query create a new table named QBITEM containing the ITEMNAME, AND ITEMTYPE of items in the ITEM table that have a color beginning with the letter B (e.g Brown, Black,…….) and COLOR. These columns should be called PRODUCT NAME , PRODUCT TYPE AND PRODUCT COLOR in the new table. Answer PRODUCT NAME PRODUCT TYPE PRODUCT COLOR Map Case E Brown Pocket Knife - Avon E Brown Pocket Knife - Nile E Brown Camel Saddle R Brown Stetson...

  • Question 2 Let U = {q, r, s, t, u, v, w, x, y, z} C...

    Question 2 Let U = {q, r, s, t, u, v, w, x, y, z} C = {v, w, x, y, z}. List the elements in the set. CU

  • If you have W(V,R) = R * V and V:=V(T,R) and R:=R(X,Y,Z), how would you get,...

    If you have W(V,R) = R * V and V:=V(T,R) and R:=R(X,Y,Z), how would you get, from this W(V,R) = R * V, Vtt and Vrr please explain. P.S My problem here is im confused on how to derive a PDE that's dependent on T,R with respect to T and R if it is equal to another function that is dependant on two other variables.

  • Please give me the R code for the following questions. Create a variable named x1 which...

    Please give me the R code for the following questions. Create a variable named x1 which contains five equally spaced numbers. You may NOT use the c() function to do this. Find the mean of all elements of x1 except the second. Create a list My.List where the first list element is a two-column data frame containing x1 and the vector [2, 1, 4, 7, 8], and the second list element is the logical vector [T, F, NA, T, F]....

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