FAQ Database Discussion Community


R: Using the “names” function on a dataset created within a loop

r,paste,assign,names
I am using a for loop to read in multiple csv files and naming the datasets import1, import2, etc. For example: assign(paste("import",i,sep=""), read.csv(files[i], header=FALSE)) However, I now want to rename the variables in each dataset. I have tried the following: names(as.name(paste("import",i,sep=""))) <- c("xxxx", "yyyy") But get the error "target of...

R paste string with collapse - How to keep string with quotes?

r,paste,collapse
I have a problem with the quotes in pasting two strings together. I want an output like this: query= "sql query","port" I tried: query<-c("sql query","port") paste(queryString,collapse=",") which gives:"sql query,port" Also tried this: query<-c("sql query") query<-paste(query,"port",sep=",") which also gives: "sql query,port" Without the quotes in the right place the query won't...

Autohotkey ClipboardAll in function does not work

copy,clipboard,autohotkey,paste
Hello I have this script in Autohotkey and for some reason it does not work just for ClipboardAll in function: global clips := Object() copy(index){ Send ^c clips[0] := ClipboardAll } paste(index){ Clipboard := clips[0] Send ^v } ^q:: copy(0) !q:: paste(0) but if I try the function copy with...

How to use paste command recursively in a shell script

linux,shell,awk,paste
I have a paste command in my script. But it is not giving my desired output. my datafile is file.txt 1 3 5 4 my shell script is f1=file.txt for j in 1..12 do awk '{printf ("%.1f\n", $1+'$j');}' $f1 > $j_$f1 paste $j_$f1 > ofile.txt # ofile.txt is a new...

Paste the elements of two columns [duplicate]

r,performance,data.frame,paste,rcpp
This question already has an answer here: Speedy/elegant way to unite many pairs of columns 3 answers I have a data.frame of the following kind set.seed(12) d = data.frame(a=sample(5,x=1:9), b=sample(5,x=1:9), c=sample(5,x=1:9), d=sample(5,x=1:9), e=sample(5,x=1:9), f=sample(5,x=1:9)) d # a b c d e f # 1 1 1 4 4 2...

Defining a Variable in a for loop using paste in r with an sqlQuery

r,for-loop,paste,qsqlquery
I am trying to define a variable in a for loop in r using the paste function, an example is as follows: for (i in 1:length(XX)) { (paste0("Test",Name[i],sep="")) <- sqlQuery(channel, paste("SampleQuery", sep = "")) } I get the following error: Error in (paste0("Test", Name[i], sep = "")) <- sqlQuery(channel, :...

Find and copy/paste last colums

vba,excel-vba,range,paste
I have a problem inserting new columns and pasting the values of the last columns in these new columns. The code i got so far is this Sub Macro1() Dim ws As Worksheet Dim LC As Long Set ws = ActiveWorkbook.Worksheets("TOT") LC = ws.Cells(3, Columns.Count).End(xlToLeft).Column ws.Columns(LC - 2).Insert ws.Columns(LC -...

GUI glitch using paste?

awk,paste
this is my file: file.txt cg13869341 1 15865 cg24669183 1 534242 cg15560884 1 710097 cg01014490 1 714177 cg17505339 1 720865 cg11954957 1 758829 cg23803172 1 763119 cg16736630 1 779995 cg00168193 1 790667 cg05898754 1 805102 awk '{print $2 "\t" $3 "\t" $3 "\t" $1}' file.txt output 1 cg13869341 1 cg24669183...

passing strings as arguments in ddply

r,plyr,paste
set.seed(1) df <-data.frame(category=rep(LETTERS[1:5],each=10),superregion=sample(c("EMEA","LATAM","AMER","APAC"),100,replace=T),country=sample(c("Country1","Country2","Country3","Country4","Country5","Country6","Country7","Country8"),100,replace=T),market=sample(c("Market1","Market2","Market3","Market4","Market5","Market6","Market7","Market8","Market9","Market10","Market11","Market12"),100,replace=T),hospitalID=sample(seq(1,50,1),100,replace=T),IndicatorFlag=sample(seq(0,1,1),100,replace=T))...

How to force emacs's pasting to behave like in other apps

emacs,paste
I am new emacs user and one of the things that irritates me is that when I want to replace current selected text with the one from clipboard I need to delete it first. Every other application that I know replaces pasted text with the current selection by default. Here's...

Copy cell J1 from multiple files and paste into column of masterfile

excel,vba,excel-vba,copy,paste
I currently have this code which will take files from a folder, open each one, print its name into the first column of my "Master file" close it and loop through the entire folder that way. In each file that is opened, there is information in cell J1 that I...

Jquery tagsinput not creating tags automatically on pasting input

jquery,tags,paste,eventtrigger,jquery-tags-input
I'm using jquery.tagsinput and would like to be able to paste a list of email addresses separated by comma or space. Using something like this https://github.com/xoxco/jQuery-Tags-Input/issues/22 but it doesn't add them until I press Enter - Tried triggering keypress Enter event but it doesn't work. No luck with blur event...

Paste pivot table as bitmap into Body of Outlook Appointment

excel-vba,bitmap,outlook,paste,appointment
Using Excel VBA, I'd like to make a small pivot table visible to Outlook users. I do NOT want to paste into a message body I DO want to paste into an appointmentItem Here is my code that creates the Appointment and copies Range to clipboard. How do I paste...

Excel-VBA Copy image from worksheet1 to worksheet 2

excel,image,vba,copy,paste
I am having difficulty getting the code in the workbook attached to function as intended. Everything is working but it is copying the photo twice. Any suggestions? Basically, it looks at the master worksheet then creates a unique sheet for each supplier based on the date entered and copies over...

bash paste does not retain line breaks

linux,bash,paste
Need some urgent help please. My bash script is pasting from file1.txt which has line by line entries into a CSVformat. for e.g File1.txt contains text; John 21-2-2015 some city "108 Brent Street Ridgewoods sometown somecountry" the converted o/p for a CSV upload should look like John,21-2-2015,some city,"108 Brent Street...

Copy and paste visible cells only to variable row

excel-vba,filter,copy,paste
I am writing a VBA macro that copies a set of data,applies some filtering, then copies the filtered data to the next available row. My issue is with the last line "copyRange.SpecialCells(xlCellTypeVisible).Copy GAR070...." which sometimes works and sometimes doesn't bringing up the error: Runtime error '1004': Method 'Range' of object'_Worksheet'...

Paste multiple elements of a list of vectors

r,list,data.table,paste
I have a data table like this ID Name 1: 2760925 01_HOOFD_010 2: 2760925 01_HOOFD_015 3: 2771451 01_HOOFD_010 4: 2771451 01_HOOFD_190_2 5: 2771451 01_HOOFD_030_2 6: 2771451 08_AWB45_020_2 7: 2771451 08_AWB45_040 8: 2771451 01_HOOFD_065_2 For the "Name" field, I want to have the part after the second underscore in a separate...

Looping over pairs of values in bash

bash,for-loop,nested-loops,paste
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...

Excel Macro: If the final characters of a cell is “something” then, cut them and paste them elsewhere

excel,excel-vba,if-statement,paste
This is an extension of a previously asked question that was amazingly answered and made me think of how else I can simplify my sloppy code. Dim i As Long, l As Long l = Cells(Rows.Count, 4).End(xlUp).Row For i = l To 1 Step -1 If Right(Cells(i, 4).Value, 4) =...

transpose every n lines into a single line

linux,shell,awk,sed,paste
I am trying to bring bunch of n lines into a single line,not sure how to do it. Any help is appreciated. bunch of 11 words then a blank line and then again bunch of ll words and then blank like...so on. Example: cat filename hi hello how are you...

Combine several images horizontally with Python

python-2.7,python-imaging-library,paste
I am trying to horizontally combine some JPEG images in Python. Problem: I have 3 images - each is 148 X 95 - see attached. I just made 3 copies of the same image - that is why they are the same. My attempt: I am trying to horizontally join...

Find value and copy entire row to another sheet

excel,vba,copy,paste,vlookup
I'm trying to create a vba code but I'm not succeeding. I want to search on COLUMN "F", for value: "Answered" then copy row from "COLUM B TO F" and paste on sheet "ControlAnswered" lastrow;...

Excel - special paste options?

excel,vba,paste
I need some help. Let's say that I would like to copy a long...long.. row in Excel: 2.337662338 2.368421053 2.479452055 2.283950617 2.72 2.625 What should I do to copy this row and paste it in such a form: 2.337662338 2.368421053 2.479452055 2.283950617 2.72 2.625 etc... Thank you very much for...

Selecting a linked excel chart in powerpoint

vba,charts,powerpoint,paste
I have a powerpoint presentation with 100 slides and most of them have linked excel charts. I am trying to run a macro that will cycle through the slides and then the shapes on the slides and find the linked chart/graph, copy it, and paste it into the same position...

How to paste a backslash character to a string?

regex,r,string,character-encoding,paste
How can I paste a backslash character? ToPrintOnFile = paste("hello", "\", "World") Error: unexpected symbol in "paste("hello", "\", "World" If I try to escape this character with an extra "\".. ToPrintOnFile = paste("hello", "\\", "World") [1] "hello \\ World" My goal is to write ToPrintOnFile on a file, where ToPrintOnFile...

Keyboard Keys to Paste Text with AutoHotKey

text,keyboard,autohotkey,paste
I am using AutoHotKey software to change the use of some buttons. It helps a lot especially if you want to open programs without having to find the shortcuts and click on them. All I want now is to save a specific text (with paragraphs) in some F keys. For...

Why do my pasted images looked cropped in LibreOffice Writer?

image,crop,paste,libreoffice,writer
I'm writing an academic paper in Writer, and wherever I paste an image into it, the image will look cropped, like this (notice the top section): However, if I paste the same image in any other writer document, it will look just fine: I have to mention that I initially...