Joining 2 vectors into 1 variable - R

0 votes
How to join 2 vector variables with each element in 2nd vector?. In other words, I want to have a cross join of both vectors into a new variable.
Jul 2, 2019 in Data Analytics by riti
468 views

1 answer to this question.

0 votes

A small trick that you can do is to create a matrix of either of those 2 vectors and then paste the matrices like below.

Just a small trick, 

Suppose the matrices where letters = c ("a","b","c","d") and  numbers = c (1,2,3,4,5).

Now create a matrix of any 1 vector and then paste matrix with the vector this will fetch you combined vector as you wanted.

Pasting 2 vectors directly will give result as below

answered Jul 4, 2019 by anonymous
• 33,030 points

Related Questions In Data Analytics

0 votes
1 answer

Error in source("myfunction.R") : myfunction.R:2:3: unexpected symbol 1: 2: R version

Try formatting your code like this: myfunction <- ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,840 points
2,113 views
0 votes
1 answer

R programming: Finding the difference between 2 vectors

Try this function, it worked for me: f ...READ MORE

answered Dec 28, 2018 in Data Analytics by Sophie may
• 10,610 points
1,031 views
0 votes
0 answers

how does 1=1 helps when joining 2 tables in sql?

Mar 29, 2019 in Data Analytics by anonymous
281 views
0 votes
1 answer

Difference between list(1:5) and list(1,2 ...5) in R.

It's very simple. list(1:4) creates a single element(vector) whereas ...READ MORE

answered Oct 14, 2019 in Data Analytics by rajeev
433 views
0 votes
1 answer

Appending values to a vector - R

This is actually quite easy, all you ...READ MORE

answered May 15, 2018 in Data Analytics by Bharani
• 4,660 points
559 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
1,994 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,605 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 892 views
+4 votes
3 answers

How to sum a variable by group in R?

You can also try this way, x_new = ...READ MORE

answered Aug 1, 2019 in Data Analytics by Cherukuri
• 33,030 points
77,237 views
+1 vote
2 answers

Splitting the data into training and testing sets - R

Hi, Try like this. train = sample(x = ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
5,695 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