Menu
  • HOME
  • TAGS

R - Collapse By Row

r,paste,collapse

matrix(apply(seq, 1, paste, collapse=''), ncol=1) # [,1] #[1,] "hffl" #[2,] "dkdl" #[3,] "ssdd" #[4,] "ssdd" ...

ActiveSheet.Paste Failing VBA Excel

excel,vba,paste

Dim varTemp as Variant Windows("Invoice Program.xlsm").Activate Range("B4").Select varTemp = ActiveCell.Value Workbooks.Open ("C:\Users\Invoice Database.xlsx") Windows("Invoice Database.xlsx").Activate Range("A" & Rows.Count).End(xlUp).Offset(1).Select ActiveCell = varTemp ...

Concatanate two columns in a data.frame/file with 1000 columns to one column in a new data.frame/file

r,bash,function,awk,paste

You could try df1 <- df[c(TRUE,FALSE)] df2 <- df[c(FALSE,TRUE)] as.data.frame(mapply(paste, df1, df2, sep="/")) # V1 V3 V5 V7 V9 #1 a/b c/d s/f r/t g/g #2 f/j g/k r/k d/a f/l #3 f/p j/h g/i t/b k/k #4 h/j l/u z/b g/b d/h Or you could do as.data.frame(`dim<-`(paste(as.matrix(df1), as.matrix(df2), sep="/"),...

GUI glitch using paste?

awk,paste

I can reproduce the behavior with a file that has Windows line endings (\r\n instead of \n). In this case, the last field will not be "15865" but "15865\r", so every time $3 is printed, the cursor is moved to the beginning of the line before the next tab and...

c# How to validate when pasting into textbox

c#,validation,paste

This is what I made, and it works :) I will only add try-catch block as Krekkon has suggested. private void phoneNumberValidity(object sender, EventArgs e) { counter4 = Convert.ToInt32(IsPhoneNumberCorrect(textBoxPhoneNumber.Text)); pictureBoxPhoneNumber.Image = imageList1.Images[counter4]; if (Regex.IsMatch(textBoxPhoneNumber.Text, "[^0-9-+]")) { Regex regex = new Regex("[^0-9-+]"); string output = regex.Replace(Clipboard.GetText(), ""); textBoxPhoneNumber.Text = output; }...

Need to paste picture into Powerpoint then defining its location without selecting it

excel,vba,location,powerpoint,paste

You nearly never need to select anything to work with it. ' if you're running the code from within PowerPoint: Dim oSh as Shape ' or if from Excel: Dim oSh as Object ' Get a reference to the newly pasted shape ' Don't miss the (1) at the end...

Selecting a linked excel chart in powerpoint

vba,charts,powerpoint,paste

This should be cleaner but you can save the copy/paste step if you simply ungroup the chart shape. That'll give you a metafile directly. Sub Select_All() Dim oPresentation As Presentation Set oPresentation = ActivePresentation Dim oSlide As Slide Dim oSlides As SlideRange Dim oShape As Shape ' These should be...

Loop through range and copy cell contents to another worksheet offsetting each time

excel,vba,loops,copy,paste

You can do something using .Offset like: Sub blah() Dim inRng As Range, outCell As Range, inCell As Range Set inRng = Selection 'change Set outCell = Range("B1") 'change to be first cell of output range Application.ScreenUpdating = False For Each inCell In inRng inCell.Copy outCell 'if you want Values...

How do I paste programmatically with Swift?

ios,swift,paste

You should just be able to convert those to Swift: @IBAction func copy() { let pb: UIPasteboard = UIPasteboard.generalPasteboard(); pb.string = textView.text // Or another source of text } @IBAction func paste() { let pb: UIPasteboard = UIPasteboard.generalPasteboard(); textView.text /*(Or somewhere to put the text)*/ = pb.string } ...

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

r,paste,collapse

Try this: queryq <- toString(shQuote(query)) which gives: > cat(queryq, "\n") "sql query", "port" ...

Using paste in R including a comma

r,paste

Your problem isn't in paste. It's in lm. The comma is not expected in a formula so when it goes to convert your pasted string (which works correctly, pull it out of the lm and you will see this) into a formula it barfs at you. Additionally, given what you...

transpose every n lines into a single line

linux,shell,awk,sed,paste

Through awk. $ awk -v RS= '{gsub(/\n/, " ")}1' file hi hello how are you i am fine how are you hi how is she doing i have not herd from her ...

Keyboard Keys to Paste Text with AutoHotKey

text,keyboard,autohotkey,paste

You can do this just fine with AHK. Use a continuation section (check out Method #2) section and SendInput. myText = (LTrim Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend ultrices metus, a auctor tellus vulputate eu. Praesent sed quam vitae tortor venenatis tempor. Duis a pretium eros....

VBA Paste Special on Existing Chart

excel,vba,paste

Well, I tried a simple code and it works. Suppose you have a data like below and you made a simple Clustered Column Chart: Now you want to paste special Data2 as in your screen shot. VBA code which works at my end is below: Sub test() Dim ch As...

Excel - special paste options?

excel,vba,paste

With your data in A1:J1 you can enter the following formula in A2: =IFERROR(INDEX($A$1:$J$1,1,(ROW(1:1)-1)*4+COLUMN(A:A)),"") And drag it down to D4. Result: Change *4 if you need more columns....

R paste values dynamically with seperator [duplicate]

r,paste,string-concatenation,concat

I think you want to paste together the elements of a vector like 1:2 to get a comma separated string. To do this you use the collapse argument of paste, since you are passing it only a single argument. paste(1:3, collapse = ",") [1] "1,2,3" On the other hand if...

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

excel,vba,excel-vba,copy,paste

This is the solution that works: 'print J1 values to Column 4 of masterfile With WB For Each ws In .Worksheets StartSht.Cells(i + 1, 1) = objFile.Name With ws .Range("J1").Copy StartSht.Cells(i + 1, 4) End With i = i + 1 'move to next file Next ws 'close, do not...

How to paste a backslash character to a string?

regex,r,string,character-encoding,paste

You do need to use double escapes to represent a single backslash character. Your second attempt works as expected. Use cat() to print the string and see for yourself or nchar("\\") cat(paste("hello", "\\", "World")) # hello \ World ...

Cutting and pasting nodes in a TreeView control?

vb6,treeview,paste

... upon clicking cut it copies the selected node to copynode. then remove the selected node. so the node is stored in the copynode slot This won't work as copynode is a reference to the thing you just removed (destroyed) so after removal copynode will point to Nothing. Instead;...

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

excel,excel-vba,if-statement,paste

Take the left of the string, the number of chars is equal to the total length minus 4 Cells(i,4).Formula = Left(Cells(i, 4).Value, len(Cells(i, 4).Value)-4) ...

Arelle automate small procedure to trasfer data to Excel by using Python

python,excel,copy,paste,xbrl

Arelle provide a Python API that you can find here with the documentation here. This API will allow you to automate your process by scripting actions, this removes the necessity to automate working with the GUI itself which would be cumbersome....

Paste text into vb label on formload

vb.net,label,paste

You can use Clipboard.GetText(). Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load Label1.Text = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text) End Sub ...

R - basic subsetting: keeping some variables of a larger data frame

r,variables,paste,ls,subsetting

I really don't understand why you're trying to use paste() here. This function is typically only for concatenating character values. Method 2 returns an error because paste(data[c(1, 4:7)], sep="") returns c("1", "4", "5", "6", "7") which is a character vector and when you index with a character vector R looks...

Jquery tagsinput not creating tags automatically on pasting input

jquery,tags,paste,eventtrigger,jquery-tags-input

Ok finally figured out the solution: DEMO HERE Just add a listener to your textbox while pasting and do not set onAddTag during initialization and just give it a simple call as below: $("#tagsinput").tagsInput();//Initialization $("#tagsinput_tag").on('paste',function(e){ var element=this; setTimeout(function () { var text = $(element).val(); var target=$("#tagsinput"); var tags = (text).split(/[...

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

r,paste,assign,names

A better approach would be to read the files into a list of data.frames, instead of one data.frame object per file. Assuming files is the vector of file names (as you imply above): import <- lapply(files, read.csv, header=FALSE) Then if you want to operate on each data.frame in the list...

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

emacs,paste

As artscan wrote in a comment, you can get this functionaly for the normal yank (paste) operations by adding: (delete-selection-mode 1) to your configuration. If you want yank by mouse to also delete the current selection, you can add: (put 'mouse-yank-primary 'delete-selection 'yank) in your configuration as well....

Userform CommandButton to Populate based on CheckBox True/False

excel,vba,checkbox,paste,commandbutton

For your first issue, please avoid relying on Selection. Instead, you should explicitly state the destination range, like: NewBook.Sheets(1).Range("A1").PasteSpecial... Now, you are getting multiple workbooks open because the Sheets(_name_).Copy method will always return a new workbook if you have not specified a destination explicitly in the Copy statement. http://msdn.microsoft.com/en-us/library/office/ff837784(v=office.15).aspx Instead,...

Automatically Run Macro When Data Is Pasted VBA

excel,vba,paste

A simple implementation: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A1:C" & ThisWorkbook.Worksheets(1).UsedRange.Rows.Count)) Is Nothing Then 'Call your Macro to do stuff End If End Sub Intersect checks if Target is in the range you want to monitor. So if something changes in columns past C, Intersect will...

create a loop and paste

r,loops,paste

Something like this might work: lapply(s, function(df) apply(expand.grid(df$E, df$S),1,paste0,collapse="")) Or, as proposed by @akrun, lapply(s, function(df) do.call(paste0, expand.grid(df$E, df$S))) ...

combine data.frame columns to new columns by vector of names

r,data.frame,paste,do.call

Just use do.call(paste, dat[cnames]) #[1] "y 2011 mid" "r 2012 mid" "r 2013 late" "r 2014 mid" "r 2011 late" #[6] "b 2012 early" "y 2014 early" "r 2013 mid" "r 2011 late" "b 2014 early" If you need different delimiter do.call(paste, c(dat[cnames], sep=",")) ...

How to paste previously prepared code snippets in Vim?

vim,paste

Basic expansion can be done via the built-in abbreviations, for example: :inoreabb d1 DoSomething()<CR>{<CR><CR>}<CR><Up><Up> Read more at :help abbreviations. snippets are like the built-in :abbreviate on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is...

R: How to paste a full vector within another vector

r,vector,reference,character,paste

You can also keep your former code and just use get: In your loop, if you replace sub = df[grepl(paste(allSearches[i],collapse="|"), df$Cars, ignore.case=T),] by sub = df[grepl(paste(get(allSearches[i]),collapse="|"), df$Cars, ignore.case=T),] It should work. for (i in 1:length(allSearches)){ sub = df[grepl(paste(get(allSearches[i]),collapse="|"), df$Cars, ignore.case=T),] sub[,allSearches[i]] <- "Yes" df = merge(df, sub, all.x = T)...

Copy Paste from Excel

c#,winforms,clipboard,paste

You could remove that ending line newline a few different ways. Since you're already splitting the string, you could tell it to treat the newline as an additional delimiter, and remove empty substrings. string[] lines = s.Split(new[] {"\t", Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); Alternatively, you could use TrimEnd() to trim specific characters off...

PyQt paste function TypeError when activating QShortcut

python,qt,pyqt,typeerror,paste

You are attempting to pass the return value of a method to connect, when you should be passing the callable itself (i.e. without parentheses): self.shortcutPaste.activated.connect(self.__handlePaste) ...

Pasting value at the intersection of Row X and Column Y

excel,intersection,paste

You did not post any actual question. I guess you want to perform the task in your title, faster than you currently do it. I guess slowness is due to your summary worksheet having too many formulas, which are recalculated upon each change. If so, your solution would be either:...

Find and copy/paste last colums

vba,excel-vba,range,paste

Thanks all, I was not aware of this Both the Copy and the PasteSpecial methods must be used on a Range >reference/object. You are trying to use Copy on a Columns reference I have rearranged my code as follows and this works out Sub Macro1() Dim ws As Worksheet Dim...

bash paste does not retain line breaks

linux,bash,paste

You could try the below Perl command. $ perl -0777pe 's/(?s)"[^"]*"(*SKIP)(*F)|\n(?!$)/,/g' file John,21-2-2015,some city,"108 Brent Street Ridgewoods sometown somecountry" Add -i parameter to save the changes made to that file....

Concatenating strings in data.frame columns without duplication

r,duplicates,concatenation,vectorization,paste

You need to strsplit each entry of each vector, do a union of the resulting vectors, and paste them together: strsplit(d$t1, split=", ") -> t1s ## list of vectors strsplit(d$t2, split=", ") -> t2s ## list of vectors # do a union of the elements and paste them together to...

Excuting text via linux shell

regex,linux,bash,shell,paste

Like this? cat list.txt aaaaaaaaaa.htm 4 bbbbbbbbbb.htm 5 awk '{gsub(/.htm/,"",$1);for (i = 2; i<=$2;i++){printf "%s_%s.htm\n",$1,i}}' list.txt aaaaaaaaaa_2.htm aaaaaaaaaa_3.htm aaaaaaaaaa_4.htm bbbbbbbbbb_2.htm bbbbbbbbbb_3.htm bbbbbbbbbb_4.htm bbbbbbbbbb_5.htm ...

How to use paste command recursively in a shell script

linux,shell,awk,paste

I would suggest doing the whole thing in awk, rather than using a shell loop: awk '{for (i=1; i<=12; ++i) printf "%d%s", $1+i, (i<12?FS:RS)}' "$f1" > output This loop runs for each line of the file and outputs all of the columns, saving the need to use another tool such...

Paste the elements of two columns [duplicate]

r,performance,data.frame,paste,rcpp

This matches your description, but not the output you show: mat = as.matrix(d) matrix(paste0(mat[, seq(1, ncol(mat), by = 2)], mat[, seq(2, ncol(mat), by = 2)]), ncol = ncol(mat) / 2) # [,1] [,2] [,3] # [1,] "11" "44" "23" # [2,] "72" "79" "75" # [3,] "85" "38" "12" #...

What is the use of 'sep' in paste command of R?

r,paste

sep is more generally applicable when you have more than two vectors of length greater than 1. If you were looking to get "something_to_paste", then you would be looking for the collapse argument. Try the following to get a sense of what the sep argument does: paste(a, 1:3, sep =...

VBA: Combine and move to new sheet [closed]

vba,copy,move,paste

Here is a macro that does what you want. More on running a macro here: http://office.microsoft.com/en-us/excel-help/run-a-macro-HP010342865.aspx Sub CopyExtra() Dim LastRow As Long Dim CurRow As Long Dim DestRow As Long LastRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row For CurRow = 1 To LastRow DestRow = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1 With Sheets("Sheet2")...

Excel-VBA Copy image from worksheet1 to worksheet 2

excel,image,vba,copy,paste

You have 2 paste operations in your code. One that you know of: WshtCrnt.Paste and one that is part of this range copy statement: . . With WshtSht1 .Range(.Cells(1, 1), .Cells(RowSht1DataFirst - 1, ColSht1LastHdr)).Copy_ Destination:=WshtCrnt.Range("A1") . . By specifying a "Destination" you are requesting a copy AND paste of your...

Why do my pasted images looked cropped in LibreOffice Writer?

image,crop,paste,libreoffice,writer

Fixed it by just copying everything from this document into a new document. This way, I lost the original styles, but I got rid of the image issue as well. I then changed my styles manually to make my document look like before.

using paste with a list

r,paste,strsplit

While yes, cat will concatenate and print to the console, it does not actually function in the same way paste does. It's result best explained in help("cat") The collapse argument in paste is effectively the opposite of the split argument in strsplit. And you can use sapply to return the...

Excel VBA to search for specific text in cell and then copy to another sheet

excel-vba,copy,paste

Start by moving the data you KNOW moves by setting the values in the beginning. The tricky part is checking for each item. Since you know there are 12 of them, as long as the example you provided is how it's going to be laid out, you just loop through...

Create a list of multiple identical (same dimension) matrices in R

r,list,matrix,paste,dimensions

What about: L <- replicate(10, matrix(0, ncol=C, nrow=R, dimnames=list(paste("Round",1:R),paste("Player", 1:C))), simplify=FALSE) names(L) <- paste0("M", 1:10) edit use setNames as @akrun did, to simplify further setNames(replicate(10, matrix(0, ncol=C, nrow=R, dimnames=list(paste("Round",1:R),paste("Player", 1:C))), simplify=FALSE), paste0("M", 1:10)) ...

Using italics in the title on an object from a dataframe [duplicate]

r,plot,data.frame,paste,italic

You could try bquote nm1 <- 'Musa paradisiaca' plot(1,1, main=bquote('Species = '~italic(.(nm1)))) Update Or using substitute plot(1,1, main=eval(substitute(expr=expression(paste('Species = ', italic(x))), env=list(x=as.name(nm1))))) ...

passing strings as arguments in ddply

r,plyr,paste

Is this what you are after... library(plyr) library(dplyr) Data 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),...

Paste Values From One Worksheet To Another If X = True

excel,vba,excel-vba,paste

I think the issue here is that you're copying 5 cells in a row from Worksheets(5), but only incrementing w by 1 on each for loop. If the goal really is to add to the same row on Worksheets(1), you would need to increment w by 5 instead... which is...

Find value and copy entire row to another sheet

excel,vba,copy,paste,vlookup

Try this, Sub SpecialCopy() Dim targetSh As Worksheet Set targetSh = ThisWorkbook.Worksheets("ControlAnswered") Dim i As Long For i = 1 To Cells(Rows.Count, "F").End(xlUp).Row If Cells(i, 6).Value = "Answered" Then Range(Cells(i, 2), Cells(i, 6)).Copy Destination:=targetSh.Range("A" & targetSh.Cells(Rows.Count, "A").End(xlUp).Row + 1) End If Next i End Sub I should say that you...

Combine several images horizontally with Python

python-2.7,python-imaging-library,paste

You can do something like this: import sys from PIL import Image images = map(Image.open, ['Test1.jpg', 'Test2.jpg', 'Test3.jpg']) widths, heights = zip(*(i.size for i in images)) total_width = sum(widths) max_height = max(heights) new_im = Image.new('RGB', (total_width, max_height)) x_offset = 0 for im in images: new_im.paste(im, (x_offset,0)) x_offset += im.size[0] new_im.save('test.jpg')...

Autohotkey ClipboardAll in function does not work

copy,clipboard,autohotkey,paste

Seems that AutoHotkey's arrays cannot store the contents of clipboardAll. Someone should report this... Instead, if you use pseudo arrays, it'll work. So you can either go for this global clips0,clips1,clips2,clips3,clips4 ; ... copy(index){ Send ^c clips%index% := ClipboardAll } paste(index){ Clipboard := clips%index% Send ^v } ^q:: copy(0) !q::...

Paste multiple elements of a list of vectors

r,list,data.table,paste

x <-structure(list(ID = c(2760925L, 2760925L, 2771451L, 2771451L, 2771451L, 2771451L, 2771451L, 2771451L), Name = c("01_HOOFD_010", "01_HOOFD_015", "01_HOOFD_010", "01_HOOFD_190_2", "01_HOOFD_030_2", "08_AWB45_020_2", "08_AWB45_040", "01_HOOFD_065_2")), .Names = c("ID", "Name"), row.names = c(NA, -8L), class = c("data.table", "data.frame" )) x$two <- gsub( "(.*?)_(.*?)_(.*?)" , "" , x$Name ) ...

Looping over pairs of values in bash

bash,for-loop,nested-loops,paste

If you want to use one variable and perform and action with it, you just need to use one loop: for file in 4 5 6 7 8 do paste "${file}_1" "${file}_2" done This will do paste 4_1 4_2 paste 5_1 5_2 ... ...

Copy and paste visible cells only to variable row

excel-vba,filter,copy,paste

It's a bit confusing, because you have With GAR070 but no End With, so I can't tell where your With ends. This may not be the source of the problem you're having, but this line: copyRange.SpecialCells(xlCellTypeVisible).Copy GAR070.Range(Cells(newrow, 1), Cells(newrow + 1, 14)) uses Cells without a qualifier. If End With...

Paste pivot table as bitmap into Body of Outlook Appointment

excel-vba,bitmap,outlook,paste,appointment

There is no HTML support in appointment items and hence no no Oapt.HTMLbody Unfornunately the SendMessage API also doesn't work. So I finally (unwillingly) tested with SendKeys and it works. Note: I am not using .Save as this code is only for testing. To save the appointment, re add the...

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

r,for-loop,paste,qsqlquery

From the documentation, the output of paste0 is a character vector, not a variable. You can't use a character vector and the <- operator to assign into a variable, for that you need assign(). But anyway, you'd be better off storing a list of related sql results in an actual...