replace

R - replace values in dataframe based on two matching conditions

喜夏-厌秋 提交于 2021-02-11 13:37:21
问题 I'm working with lists of spatial data for 20+ different sites (difficult to reproduce here; sorry in advance). I have three data frames associated with each site; each has a 'sample_ID' column and some other shared columns names. What I'm trying to do seems very simple: if the 'sample_ID' values match for two data frames and the column names match, replace the value in DF 1 with that of DF 2 and DF 3 three. Example: # DF 1: SAMPLE_ID CLASS_ID CLASS VALUE 1 0 0 5 2 0 0 5 3 0 0 3 4 0 0 6 5 0 0

Replace the same values in the consecutive rows and stop replacing once the value has changed in R

那年仲夏 提交于 2021-02-11 12:47:56
问题 I want to find a way to replace consecutive same values into 0 at the beginning of each trial, but once the value has changed it should stop replacing and keep the value. It should occur every trials per subject. For example, first subject has multiple trials (1, 2, etc). At the beginning of each trial, there may be some consecutive rows with the same value (e.g., 1, 1, 1). For these values, I would like to replace them to 0. However, once the value has changed from 1 to 0, I want to keep the

Replace the same values in the consecutive rows and stop replacing once the value has changed in R

╄→гoц情女王★ 提交于 2021-02-11 12:47:06
问题 I want to find a way to replace consecutive same values into 0 at the beginning of each trial, but once the value has changed it should stop replacing and keep the value. It should occur every trials per subject. For example, first subject has multiple trials (1, 2, etc). At the beginning of each trial, there may be some consecutive rows with the same value (e.g., 1, 1, 1). For these values, I would like to replace them to 0. However, once the value has changed from 1 to 0, I want to keep the

How to - Find and replace the first occurrence only

戏子无情 提交于 2021-02-11 12:34:47
问题 I have a script that seems to work correctly only it works to good. I have files that contain multiple lines with the string "PROCEDURE DIVISION.", with the period at the end. What I need to do... ONLY remove the [2nd occurrence] of the string "PROCEDURE DIVISION." if it's in the text file twice and bypass the file if it is only found once. I need to preserve the 1st occurrence and change/remove the 2nd occurrence. I can find and replace all the occurrences easily, I have no clue how to

replace path value of a variable in file with bash

一笑奈何 提交于 2021-02-11 07:42:43
问题 I have a namelist containing inputs for simulations. I have to change the path of some variables using bash. The text file has the following value that I would like to change: opt_path = '/home/gle/test_workflow', I would like to replace the value of opt_path with cat and sed, and I tried the following but it doesn't work: new_path=/my/new/path cat namelist.wps | sed "s/^opt_path.*/opt_path = '${new_path}'/g" it returns the following error: sed: -e expression #1, char 29: unknown option to `s

Word VBA: find line and replace font

半城伤御伤魂 提交于 2021-02-10 14:24:34
问题 I've written a VBA Word Macro that read a .txt File, copy it and paste it in a Word document setting a new font. All is working fine! Now I would like to highlight some specific lines with bold + italic font, but i cannot figure out a working solution. The specific lines begins with a specific word (for example Simulation Nr.xxx ) or they begin with some words but then they have a very long series of blank spaces (for example Turbine ). How can i solve the problem? P.s.: here the working code

Word VBA: find line and replace font

时光毁灭记忆、已成空白 提交于 2021-02-10 14:23:09
问题 I've written a VBA Word Macro that read a .txt File, copy it and paste it in a Word document setting a new font. All is working fine! Now I would like to highlight some specific lines with bold + italic font, but i cannot figure out a working solution. The specific lines begins with a specific word (for example Simulation Nr.xxx ) or they begin with some words but then they have a very long series of blank spaces (for example Turbine ). How can i solve the problem? P.s.: here the working code

Replacing a string using SQL Server Replace function - string has more than 4000 characters - what to do?

感情迁移 提交于 2021-02-10 13:45:12
问题 I have a table, where I need to replace some values in a column. The database is running on SQL Server 2005. The problem is that some of the rows contain more than 4000 characters, which is giving the REPLACE function some trouble, since it demands that I cast the first parameter to the datatype NVARCHAR , and therefore any characters exceeding 4000, is being truncated. Is there any workaround for this, other than writing an application that handles this issue? The query in question is:

How to use str.replace to replace multiple pairs at once? [duplicate]

独自空忆成欢 提交于 2021-02-10 09:31:15
问题 This question already has answers here : How to replace multiple substrings of a string? (23 answers) Replace multiple substrings in a Pandas series with a value (5 answers) Closed 8 months ago . Currently I am using the following code to make replacements which is a little cumbersome: df1['CompanyA'] = df1['CompanyA'].str.replace('.','') df1['CompanyA'] = df1['CompanyA'].str.replace('-','') df1['CompanyA'] = df1['CompanyA'].str.replace(',','') df1['CompanyA'] = df1['CompanyA'].str.replace(

Ruby - replace words in a string if instances do not match

送分小仙女□ 提交于 2021-02-10 06:14:20
问题 First time on Stackvoverflow so hope I am posting this correctly & as clear as possible. Please feel free to rip this apart and let me know how to post clearer questions in the future if need be. Newbie to Ruby here and practising where I can. I want to know how to replace instances in a string in ruby. for example: say I have: string = 'richard julie richard julie sam letty sam letty' How would I replace any instance in the string, that does not equal 'richard' or 'julie' & replace with the