Question

Consider the following R expressions: string1 = c("A", "B", "C") and string2 = str_c("A", "B","C") What...

Consider the following R expressions:

string1 = c("A", "B", "C")

and

string2 = str_c("A", "B","C")

What is the value of the expression below?

length(string1)*length(string2) + str_length(string2)

answer: 6

But I don't know why the answer is 6.

I don't understand how c function and str_c function work.

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

Answers:

>= a = c("A","B","C")

output- "A" "B" "C"

len(a) = 3

>= b = str_c("A","B","C")

output- "ABC"

len(b)= 1

In c() function the output print as without comma as well as separate string.

In str_c() function the output print as in only one string, without comma as well as Removing space.

Here,

len (a) * len (b) + len(b) = 3 * 1 + 1 = 4

Here the answer is 4 not 6.

Add a comment
Know the answer?
Add Answer to:
Consider the following R expressions: string1 = c("A", "B", "C") and string2 = str_c("A", "B","C") What...
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