Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:29:28+00:00 2026-06-16T11:29:28+00:00

I have a matrix with two columns some of the numbers are the same

  • 0

I have a matrix with two columns some of the numbers are the same in both columns, but column 2 also contains some numbers which are not in column 1.

I would like to select those values in column2 that are not in column1 and insert them in column1 in increasing order.

As a start I was thinking of using some matrix operation like matrix[matrix[,1]%in%matrix[,2]

just instead of %in% using something for “not in”.

Here’s the datafile:

https://dl.dropbox.com/u/22681355/example.csv

example<-read.csv("example.csv")

example[,2] contains some numbers which example[,1] does not.

I would like to:

  1. search for these numbers using something equivalent to %not in %

Following the answer below I can do the following:

values<-setdiff(example[,2],example[,1]

order<-sort(values)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:29:29+00:00Added an answer on June 16, 2026 at 11:29 am

    Like this?

    Rgames> foo
         [,1] [,2] [,3] [,4] [,5]
    [1,]    1    5    9   13   17
    [2,]    2    6   10   14   18
    [3,]    3    7    1   15   19
    [4,]    4    8    3   16   20
    Rgames> foo[,1]%in%foo[,3]
    [1]  TRUE FALSE  TRUE FALSE
    Rgames> foo[,1]*!foo[,1]%in%foo[,3]
    [1] 0 2 0 4
    

    I’m sure there’s a cleaner way. Heck, just do this:

    Rgames> setdiff(foo[,1],foo[,3])
    [1] 2 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two matrix with the same number of columns, but with different number
I have some large matrices of data, and a a two column matrix containing
Assume I have one matrix with two columns. Every column has thousands of values.
I have a code base, in which for Matrix class, these two definitions are
I have a matrix with two columns. I want to calculate running 60-day correlation
I have table in SQL Server 2005 that contains two columns Fruit and Colour
I have two arrays containing the same elements, but in different orders, and I
I have two matrices of different sizes. Let's just define matrix {a} as a(1:10)
In short: I have two matrices (or arrays): import numpy block_1 = numpy.matrix([[ 0,
I have matrix (a) with (1:10),<10 x 1> double. I would like to copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.