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 8985421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:19:35+00:00 2026-06-15T21:19:35+00:00

I have a matrix: https://dl.dropbox.com/u/22681355/mat.csv mat<-read.csv(mat.csv) sub<-c(123,132) I would like to change the value

  • 0

I have a matrix: https://dl.dropbox.com/u/22681355/mat.csv

mat<-read.csv("mat.csv")
sub<-c(123,132)

I would like to change the value in the 7th column of mat for those rows where mat$V2=sub

I can select this subset using:

set<- subset(mat, mat$V2 %in% sub)
set[,7]<-set[,7]+1

and then somehow match the ‘set’ with the same rows in ‘mat’.

But is there an easier way to do this?

  • 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-15T21:19:36+00:00Added an answer on June 15, 2026 at 9:19 pm

    you should watch some twotorials

    # download and read in your file from dropbox
    tf <- tempfile()
    library(httr)
    csvpage <- GET( "https://dl.dropbox.com/u/22681355/mat.csv" )
    writeBin(content(csvpage, "raw"), tf )
    
    # import the data into R
    mat <- read.csv( tf )
    
    # note read.csv creates a data frame not a matrix
    class( mat )
    
    # create your sub object
    sub <- c(123,132)
    
    # subset the matrix..
    
    # show all rows where V2 is equal to any of the contents of sub
    mat[ mat$V2 %in% sub , ]
    
    # access only the V7 column for rows where V2 is equal to the contents of sub
    mat[ mat$V2 %in% sub , 'V7' ]
    
    # overwrite the V7 column with MISSING
    # for rows where V2 is equal to the contents of sub
    mat[ mat$V2 %in% sub , 'V7' ] <- NA
    
    # OR
    
    # overwrite the V7 column with the value of V2 (which matched something in sub)
    # for rows where V2 is equal to the contents of sub
    mat[ mat$V2 %in% sub , 'V7' ] <- mat[ mat$V2 %in% sub , 'V2' ]
    
    # OR
    
    # overwrite the V7 column with itself plus one
    # for rows where V2 is equal to the contents of sub
    mat[ mat$V2 %in% sub , 'V7' ] <- mat[ mat$V2 %in% sub , 'V7' ] + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have matrix (a) with (1:10),<10 x 1> double. I would like to copy
I have a matrix in the type of a Numpy array. How would I
I have a string like the following rotate(32) translate(0,-284.35468),translate(8545,84) matrix(d,f,g,s,g) translate(-58,88) Each function can
According to: http://intendance.com/2011/03/31/enterprise-content-management-open-source-squiz-matrix/ They have stated: Most other open source content management systems options
We have an existing Traceability Matrix in Excel that has columns like: Project Business
I am modifying the TouchImageView ( https://github.com/MikeOrtiz/TouchImageView/issues ) to have zoom in and out
I have an AS3 bitmap image that I would like to skew like so:
I have a matrix like the following (arbitrary cols/rows): 1 0 0 0 0
Have a matrix report now that has Position, Hours and Wages for a location
I have a matrix of data (the columns represent time, and the rows spectrum

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.