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
• 10,440 points
25 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
answered Oct 29, 2018 by Maverick
• 10,040 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,130 points
287 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 in Data Analytics by anonymous
• 32,260 points
119 views
0 votes
1 answer

R programming Web Scraping

Try something like this: library(rvest) library(rvest) library(tidy ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,040 points
120 views
0 votes
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,040 points
529 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
125 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
179 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
91 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
114 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,040 points
35 views
0 votes
2 answers

Error: could not find function - R Programming

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

answered Aug 22 in Data Analytics by anonymous
• 32,260 points
5,842 views