paste

Paste multiple columns together

久未见 提交于 2019-11-26 00:53:48
问题 I have a bunch of columns in a dataframe which I want to paste together (seperated by \"-\") as follows: data <- data.frame(\'a\' = 1:3, \'b\' = c(\'a\',\'b\',\'c\'), \'c\' = c(\'d\', \'e\', \'f\'), \'d\' = c(\'g\', \'h\', \'i\')) i.e. a b c d 1 a d g 2 b e h 3 c f i Which I want to become: a x 1 a-d-g 2 b-e-h 3 c-f-i I could normally do this with: within(data, x <- paste(b,c,d,sep=\'-\')) and then removing the old columns, but unfortunately I do not know the names of the columns specifically

Get current clipboard content? [closed]

不问归期 提交于 2019-11-26 00:37:50
问题 I\'d like to know a way to make my script detect the content of the clipboard and paste it into a text field when the page is opened, with no input from the user. How can it be done? 回答1: window.clipboardData.getData('Text') will work in some browsers. However, many browsers where it does work will prompt the user as to whether or not they wish the web page to have access to the clipboard. 回答2: Depending on when you read this, the new clipboard API may be available, via navigator.clipboard .

Looping over pairs of values in bash

社会主义新天地 提交于 2019-11-25 22:35:47
问题 I have 10 text files and I want to paste each file with its pair, such that I have 5 total files. I tried the following: for i in 4_1 5_1 6_1 7_1 8_1 do for j in 4_2 5_2 6_2 7_2 8_2 do paste ${i}.txt ${j}.txt > ${i}.${j}.txt done done However, this code combines every possible combination instead of just combining the matching pairs. So I would like file 4_1.txt to be paired with 4_2.txt , 5_1.txt with 5_2.txt , etc. 回答1: If you want to use one variable and perform and action with it, you

Paste multiple columns together

99封情书 提交于 2019-11-25 19:12:10
I have a bunch of columns in a dataframe which I want to paste together (seperated by "-") as follows: data <- data.frame('a' = 1:3, 'b' = c('a','b','c'), 'c' = c('d', 'e', 'f'), 'd' = c('g', 'h', 'i')) i.e. a b c d 1 a d g 2 b e h 3 c f i Which I want to become: a x 1 a-d-g 2 b-e-h 3 c-f-i I could normally do this with: within(data, x <- paste(b,c,d,sep='-')) and then removing the old columns, but unfortunately I do not know the names of the columns specifically, only a collective name for all of the columns, e.g. I would know that cols <- c('b','c','d') Does anyone know a way of doing this?