R programming basics

0 votes

I've written the below code, I was wondering if there is a simpler implementation for this

value = c(0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,0)
first = matrix(value, nrow=6)
second = matrix(rev(first),nrow=6) #reverse vector "value"
output10 = cbind(first,second)
output10    

Jan 18, 2019 in Data Analytics by Sophie may
• 10,100 points
93 views

1 answer to this question.

0 votes

There's a small change you can make, you can directly create the result matrix after the concatenation:

value <- c(0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,0)
output10 <- matrix(c(value, rev(value)), nrow=6)
answered Jan 18, 2019 by Tyrion anex
• 8,560 points

Related Questions In Data Analytics

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
• 32,490 points
2,004 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,820 points
86 views
+3 votes
2 answers

Error: could not find function - R Programming

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

answered Aug 22, 2019 in Data Analytics by anonymous
• 32,490 points
19,510 views
+1 vote
1 answer

R programming Web Scraping

Try something like this: library(rvest) library(rvest) library(tidyverse) urls <- read_html("http://dk.farnell.com/c/office-computer-networking-products/prl/results/") pag <- ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,820 points
300 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Abhi
• 3,680 points
210 views
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,820 points
73 views
0 votes
1 answer
+1 vote
1 answer

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,560 points
84 views
0 votes
1 answer

Check if a matrix is diagonalizable in R Programming Language

On a given matrix, a, the first way ...READ MORE

answered Dec 24, 2018 in Data Analytics by Tyrion anex
• 8,560 points
181 views