Question

Hello, I would like to create a data set in R (I guess Matlab would work...

Hello, I would like to create a data set in R (I guess Matlab would work too) that looks as follows:

Market Product

1 AB
1 MC
1 BB
1 AB2
2 AB
2 MC
2 BB
2 AB2
3 AB
3 MC
3 BB
3 AB2
4 AB
4 MC
4 BB
4 AB2
5 AB
5 MC
5 BB
5 AB2
5 MC2
5 O
.
.|
.

25
So the first 4 markets have only 4 products, while starting with market 5 up to market 25 there are 6 products available.
Lastly, each product has a value attached:
AB =1
MC=2
BB = 3
AB2=4
MC2=5
O=6

I would appreciate if you explain your code a little. I am a beginner in coding and would really like to understand the reason for each step you take.
Thank you.

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

productList <- c("AB","MC","BB","AB2","MC2","O")
Market <- c(rep(c(1,2,3,4),each = 4),rep(seq(5,25,1) , each = 6))
product <- c(rep(productList[1:4],4) , rep(productList,25-5+1))
data <- cbind.data.frame(Market,product)

data
    Market product
1        1      AB
2        1      MC
3        1      BB
4        1     AB2
5        2      AB
6        2      MC
7        2      BB
8        2     AB2
9        3      AB
10       3      MC
11       3      BB
12       3     AB2
13       4      AB
14       4      MC
15       4      BB
16       4     AB2
17       5      AB
18       5      MC
19       5      BB
20       5     AB2
21       5     MC2
22       5       O
23       6      AB
24       6      MC
25       6      BB
26       6     AB2
27       6     MC2
28       6       O
29       7      AB
30       7      MC
31       7      BB
32       7     AB2
33       7     MC2
34       7       O
35       8      AB
36       8      MC
37       8      BB
38       8     AB2
39       8     MC2
40       8       O
41       9      AB
42       9      MC
43       9      BB
44       9     AB2
45       9     MC2
46       9       O
47      10      AB
48      10      MC
49      10      BB
50      10     AB2
51      10     MC2
52      10       O
53      11      AB
54      11      MC
55      11      BB
56      11     AB2
57      11     MC2
58      11       O
59      12      AB
60      12      MC
61      12      BB
62      12     AB2
63      12     MC2
64      12       O
65      13      AB
66      13      MC
67      13      BB
68      13     AB2
69      13     MC2
70      13       O
71      14      AB
72      14      MC
73      14      BB
74      14     AB2
75      14     MC2
76      14       O
77      15      AB
78      15      MC
79      15      BB
80      15     AB2
81      15     MC2
82      15       O
83      16      AB
84      16      MC
85      16      BB
86      16     AB2
87      16     MC2
88      16       O
89      17      AB
90      17      MC
91      17      BB
92      17     AB2
93      17     MC2
94      17       O
95      18      AB
96      18      MC
97      18      BB
98      18     AB2
99      18     MC2
100     18       O
101     19      AB
102     19      MC
103     19      BB
104     19     AB2
105     19     MC2
106     19       O
107     20      AB
108     20      MC
109     20      BB
110     20     AB2
111     20     MC2
112     20       O
113     21      AB
114     21      MC
115     21      BB
116     21     AB2
117     21     MC2
118     21       O
119     22      AB
120     22      MC
121     22      BB
122     22     AB2
123     22     MC2
124     22       O
125     23      AB
126     23      MC
127     23      BB
128     23     AB2
129     23     MC2
130     23       O
131     24      AB
132     24      MC
133     24      BB
134     24     AB2
135     24     MC2
136     24       O
137     25      AB
138     25      MC
139     25      BB
140     25     AB2
141     25     MC2
142     25       O

Please rate if helpful

Add a comment
Know the answer?
Add Answer to:
Hello, I would like to create a data set in R (I guess Matlab would work...
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
  • python beginner question! Hello, i am trying to allign the two variable below next to each...

    python beginner question! Hello, i am trying to allign the two variable below next to each other using a for loop, like this table below: 1 3 2 7 3 1 4 2 5 0 heres the code I use: balls = [1,2,3,4,5] count = [3,7,1,2,0] for j in numbers: print("{:}".format(j)) for i in count: print('{:10}'.format(i)) but the output looks like this: 1 2 3 4 5 3 7 1 2 0 i need my output to look like the...

  • Hello, I would like to work with 2 and 3 but step by step awy -...

    Hello, I would like to work with 2 and 3 but step by step awy - 2. We can define the line (R) as a product Zx (0,1), with the dictionary order. Show this is homeomorphic to R. 3. The long line (or Alexandrov line) is defined as the product of So, the minimal uncountable well-ordered set, with the interval (0,1) with the dictionary order with the smallest element deleted. Intuitively the long line consists of uncountably many copies of...

  • Hello, I would like to double check these if questions for True and Falses Questions are...

    Hello, I would like to double check these if questions for True and Falses Questions are correct for Microeconomics! Thank you T or F ___T___ 1. An inferior good can be demand inelastic but not demand elastic. ___T___ 2. Demand is elastic if price changes by a smaller percent than quantity demanded ___F___ 3. Total utility always decreases as marginal utility decreases. ___T___ 4. The law of diminishing marginal utility cannot be used to make interpersonal utility comparisons. ___F___ 5....

  • Hello I would like to verify that I have completed all the steps to solve the...

    Hello I would like to verify that I have completed all the steps to solve the following question: Weekly demand for a particular product averages 60 units, with a standard deviation of 5. This item is managed with a fixed-order-interval model. The order interval is 4 weeks, and this item has a certain lead time of 1 week. The desired service level is 97.5 percent. Assume that it is now time to place another order, and there are 23 units...

  • Hello! I am working on this genetics problem and was wondering if you could check my...

    Hello! I am working on this genetics problem and was wondering if you could check my letter d. I am not sure if this mRNA sequence is correct and would really appreciate the help. Thank you! 4. A segment of a polypeptide chain is Arg-Gly-Ser-Phe-Val-Asp-Arg. It is encoded by the following DNA: _3'_ CGCTAGCTGCTTCCTTGGGGA 5'_ coding strand/non-template ||||||||||||||||||| _5'_ GCGATCGACGAAGGAACCCCT _3'_ template strand/non-coding a) Which strand is the non-template strand? The top strand b) Which strand is a non-coding stand?...

  • Hello, I would very much appreciate if someone could work out #5 on this chemistry problem...

    Hello, I would very much appreciate if someone could work out #5 on this chemistry problem sheet. Thank you indeed. (am) 4. The density of iron is 7.50 g/cm2. What is the mass, in pounds, of a cube of iron that measures 5.00 cm, on a slide? 7.589 23 ts4g Cmz 5. Lead has a density of 10.5 g/cm3. What is the diameter of a lead ball that has a mass of 500.0 g? Report your answer in cm. 10.53...

  • In Java You’re going to make a Guess the Number game. The computer will "think" of...

    In Java You’re going to make a Guess the Number game. The computer will "think" of a secret number from 1 to 20 and ask the user to guess it. After each guess, the computer will tell the user whether the number is too high or too low. The user wins if they can guess the number within six tries. The program should look like this in the console, player input is in bold: Hello! What is your name? Abaddon...

  • Guess the number! You will create a program that will ask the user to guess a...

    Guess the number! You will create a program that will ask the user to guess a number between 1 and 10. The pseudocode is below. Be sure to import random at the beginning of your code and use a comment block explaining what your program does #Guess the number week 4 #Name: #Date: #Random number, loop while true #ask user for number. #if number is too high or too low, tell user, if they guessed it break out of loop...

  • Hello, I would like to work with these questions. 1.6 Decide whether or not D24 is...

    Hello, I would like to work with these questions. 1.6 Decide whether or not D24 is isomorphic to the group of rotations of a cube. Prove your answer. 1.7 Let V be an n-dimensional vector space over a field F with (a finite number) q elements. One writes GL(n, q) to denote GL(V). Show that IGL(n,q)= (q" - 1)(q" - q)(q" - q?)... (q" - q-!).

  • Hello, I would like to discuss with someone the work that i've done on my own...

    Hello, I would like to discuss with someone the work that i've done on my own regarding part d). So we have d unique eigenvalues and d < n. if d=n, then we only have a trivial solution (by the rank nullity theorem), but this is a contradiction because v is a non-zero eigen vector. hence the determinant (A- \lambda*I) =0. where this determinant is equal to the characteristic polynomial equation. The polynomial equation p(A)= \prod (A- \lambda_i * I)...

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