pasting

paste several column values into one value in R

社会主义新天地 提交于 2019-12-18 03:49:18
问题 I have a really simple question that I cannot find a straightforward answer for. I have a data.frame that looks like this: df3 <- data.frame(x=c(1:10),y=c(5:14),z=c(25:34)) ID x y z 1 1 5 25 2 2 6 26 3 3 7 27 etc. And I want to 'paste' together the different values in each column so that they form a single, combined value, as in: ID x+y+z 1 1525 2 2626 3 3727 I'm sure that this is very easy to do, but I just don't know how! 回答1: Yep, paste() is exactly what you want to do: df3$xyz <- with(df3

python: ignoring leading “>>>” and “…” in interactive mode?

天大地大妈咪最大 提交于 2019-12-09 15:46:55
问题 Many online python examples show interactive python sessions with normal leading ">>>" and "..." characters before each line. Often, there's no way to copy this code without also getting these prefixes. In these cases, if I want to re-paste this code into my own python interpreter after copying, I have to do some work to first strip off those prefixes. Does anyone know of a way to get python or iPython (or any other python interpreter) to automatically ignore leading ">>>" and "..."

python: ignoring leading “>>>” and “…” in interactive mode?

不羁岁月 提交于 2019-12-04 02:44:59
Many online python examples show interactive python sessions with normal leading ">>>" and "..." characters before each line. Often, there's no way to copy this code without also getting these prefixes. In these cases, if I want to re-paste this code into my own python interpreter after copying, I have to do some work to first strip off those prefixes. Does anyone know of a way to get python or iPython (or any other python interpreter) to automatically ignore leading ">>>" and "..." characters on lines that are pasted in? Example: >>> if True: ... print("x") ... You just need to either switch

paste several column values into one value in R

删除回忆录丶 提交于 2019-11-29 02:42:09
I have a really simple question that I cannot find a straightforward answer for. I have a data.frame that looks like this: df3 <- data.frame(x=c(1:10),y=c(5:14),z=c(25:34)) ID x y z 1 1 5 25 2 2 6 26 3 3 7 27 etc. And I want to 'paste' together the different values in each column so that they form a single, combined value, as in: ID x+y+z 1 1525 2 2626 3 3727 I'm sure that this is very easy to do, but I just don't know how! Yep, paste() is exactly what you want to do: df3$xyz <- with(df3, paste(x,y,z, sep="")) # Or, if you want the result to be numeric, rather than character df3$xyz <- as