Expression Computation - R programming

0 votes

How to solve the following expression:

8 x 8
8 x 88
8 x 888
8 x 8888
8 x 88888

I am to use R programming to do the computation. But is there a way I can use R code for this computation with a single R expression that has no commas and braces (i.e. the use of , and {}).

Anyway to do this via vectorization, without using condition statements (if, while, for)?

Oct 29, 2018 in Data Analytics by Ali
• 11,360 points
522 views

1 answer to this question.

0 votes

The sequence of ones:

cumsum(10^(0:4))
## [1]     1    11   111  1111 11111

Eights:

8 * cumsum(10^(0:4))
## [1]     8    88   888  8888 88888

Times eight:

 8 * 8 * cumsum(10^(0:4))
## [1]     64    704   7104  71104 711104


Hope it helps!

To learn more about R, enroll with data science with R programming course today.

Thanks.

answered Oct 29, 2018 by Maverick
• 10,840 points

Related Questions In Data Analytics

0 votes
1 answer

How to evaluate expression given as a string in R?

The eval() function evaluates an expression, but "5+5" is a string, ...READ MORE

answered Jun 7, 2018 in Data Analytics by DataKing99
• 8,250 points
4,773 views
0 votes
2 answers

What are the rules to define a variable name in R programming language?

The same rules almost follow for all ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 33,030 points
15,179 views
+1 vote
1 answer

R programming Web Scraping

Try something like this: library(rvest) library(rvest) library(tidyverse) urls <- read_html("https://www.edureka.co/aws-certification-training") pag <- ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,840 points
1,006 views
+1 vote
1 answer

Difference between factor and as.factor in R programming

Hey @Ali, as.factor is a wrapper for ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,840 points
4,899 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
2,266 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,963 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by Gitika 1,201 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,396 views
0 votes
1 answer

Why should I adopt R programming

R Programming is the best mechanism for ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,840 points
848 views
+3 votes
2 answers

Error: could not find function - R Programming

Yes, Just like @Maverik said, It happens ...READ MORE

answered Aug 23, 2019 in Data Analytics by anonymous
• 33,030 points
33,771 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP