Question

10 Vectors Exercise 2.3. Create the following vectors in R using seq) and/or rep(). A of noititiionl nA drim2 M.a8 201deeV M.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Following code snippet for Above Question :



# Variable A is for first part of Question
A = c(seq(1, 12, by=0.5))
print("Output of first part of Question is")
print(A)

print("----------------------------")


# Variable B is for second part of Question
B = c(seq(1:10)^3)
print("Output of second part of Question is")
print(B)

print("----------------------------")


# Variable C is for third part of Question
C = c(seq(1,49))

#Iterating the elements of Vector C
for(i in C)
{
#Condition to check for Even Number
if(i%%2 == 0)
{
#Replacing even number with zero
C[C==i] <- 0
}
  
}
print("Output of third part of Question is")
print(C)


[1] Ouput of first part of Question is [1] [16] 8.5 [1] [1] Ouput of second part of Question is [1] [1] [1] Ouput of thi

Add a comment
Know the answer?
Add Answer to:
10 Vectors Exercise 2.3. Create the following vectors in R using seq) and/or rep(). A of...
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
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