search for: paste0

Displaying 20 results from an estimated 642 matches for "paste0".

Did you mean: paste
2017 May 24
2
reg-tests-1d.R fails in r72721
...because in the first case you are working in a > locale where that character is representable. In my locale it is not, so x1 > is converted to UTF-8, and everything compares equal. > > An explicit conversion of x1 to UTF-8 should fix this, i.e. replace > > x1 <- path.expand(paste0("~/", filename)) > > with > > x1 <- enc2utf8(path.expand(paste0("~/", filename))) > > Could you try this and see if it helps? Nope: > ## path.expand shouldn't translate to local encoding PR#17120 > filename <- "\U9b3c.R" > &gt...
2018 Apr 10
1
Fail to save an object using name as string
Dear list member, I think that I have detected a strange behavior of the save() command: > year <- "2000" > assign(paste0("Var_", year), list(A=10, B=20)) > get(paste0("Var_", year)) $A [1] 10 $B [1] 20 # At this point all is ok, I have created a list of name Var_2000 > save(paste0("Var_", year), file=paste0("Var_", year, ".Rdata")) Error in save(paste0(&quo...
2019 Jun 14
2
Ejecutar un script de Python con argumentos desde R
...la que está el script de R, no desde el wd de R. Ahora me toca salir y después intentar probar y que funcione. Gracis de vuelta Hau idatzi du Marcelino De La Cruz Rot (marcelino.delacruz en urjc.es) erabiltzaileak (2019 eka. 14, or. (11:46)): > ¿Has probado esto? > > system( > > paste0('script.py ', > > paste0(ar[i], '1 '), > ar[i], > paste0(' ', ar[i], '3') > ) > > ) > > > > > El 14/06/2019 a las 11:36, Juan Abasolo escribió: > > Hola, amigos > > Se...
2019 Jun 14
2
Ejecutar un script de Python con argumentos desde R
...i desde la consola del sistema me pongo en la carpeta en la que lo tengo y hago: $ script.py arg1 arg arg3 Funciona perfecto. Pero desde R no lo consigo (entiendo que por no saber) Lo hago así (copio y pego): dir <- getwd() setwd('data/row/directoriocondatos/') py_run_string( paste0('script.py ', paste0(ar[i], '1 '), ar[i], paste0(' ', ar[i], '3') )) setwd(dir) El resultado del paste0() ese lo pego en la consola del sistema y perfecto... pero olvidate del for. Yo quiero que el script quede integra...
2016 Apr 22
4
Creating variables on the fly
Hi all, I would like to use a loop for tasks that occurs repeatedly: # Groups # Umsatz <= 0: 1 (NICHT kaufend) # Umsatz > 0: 2 (kaufend) for (year in c("2011", "2012", "2013", "2014", "2015")) { paste0("Kunden$Kunde_real_", year) <- (paste0("Kunden$Umsatz_", year) <= 0) * 1 + (paste0("Kunden$Umsatz_", year) > 0) * 2 paste0("Kunden$Kunde_real_", year) <- factor(paste0("Kunden$Umsatz_", year),...
2017 May 24
2
reg-tests-1d.R fails in r72721
Hi, I am failing make check in r72721 at the end of reg-tests-1d.R. The relevant block of code is ## path.expand shouldn't translate to local encoding PR#17120 filename <- "\U9b3c.R" print(Encoding(filename)) x1 <- path.expand(paste0("~/", filename)) print(Encoding(x1)) x2 <- paste0(path.expand("~/"), filename) print(Encoding(x2)) stopifnot(identical( path.expand(paste0("~/", filename)), paste0(path.expand("~/"), filename))) ## Chinese character was changed to hex code Encoding(x1) i...
2017 May 24
1
reg-tests-1d.R fails in r72721
On 2017-05-24, Duncan Murdoch wrote: [...] > Okay, how about if we weaken the test? [...] > try > > stopifnot(path.expand(paste0("~/", filename)) == > paste0(path.expand("~/"), filename)) > Nope: > ## path.expand shouldn't translate to local encoding PR#17120 > filename <- "\U9b3c.R" > > #stopifnot(identical(path.expand(paste0("~/", fi...
2017 May 24
0
reg-tests-1d.R fails in r72721
...case you are working in a >> locale where that character is representable. In my locale it is not, so x1 >> is converted to UTF-8, and everything compares equal. >> >> An explicit conversion of x1 to UTF-8 should fix this, i.e. replace >> >> x1 <- path.expand(paste0("~/", filename)) >> >> with >> >> x1 <- enc2utf8(path.expand(paste0("~/", filename))) >> >> Could you try this and see if it helps? > > Nope: Okay, how about if we weaken the test? Instead of stopifnot(identical(path.expand(paste0(...
2017 Dec 04
3
Dynamic reference, right-hand side of function
...that only a Stata-word?) in the right hand side of the functions. When I try to replace the static reference with a dynamic one (like in the left-hand side), the syntax just doesn't work. I would very much appreciate some help with this issue! All the best, Love year <- 2002 dataname <- paste0("aa_",year) assign(paste0(dataname), as.numeric(aa_2002[,1])) year <- 2003 assign(paste0("aa_",year), as.numeric(aa_2003)) year <- 2005 assign(paste0("aa_",year), aa_2005[,1]) list1 <- c(2000:2007) list1[c(7)] assign(paste0("aa_",list1[c(7)]), as....
2012 Nov 02
4
Loop over several Variables, add on question
...variables-td4648112.html) I want to rename the Variables in the new dataset so that all y will be called tiy. Doing it separately the following line works fine: ti<-rename (ti,c(y5="tiy5")) So I thought I simply extend to the following and the loop will be fine: ti<-rename (ti,c([paste0("y", 1:5)] = [paste0("tiy", 1:5)])) However, this will give me the following error message: Error: unexpected '[' in "ti<-rename (ti,c([" Removing the ?[? I then used the following line ti<-rename (ti,c(paste0("y", 1:5) = paste0("tiy&qu...
2017 Dec 04
3
Dynamic reference, right-hand side of function
...olleague I finally solved it with the (eval(as.name()) function (I include the loop I used below). I understand that looping isn't kosher among you more devoted R-users, and eventually I hope I will learn to use lists in the future instead. Thanks! Love for (year in 2000:2007){ varname <- paste0("aa_",year) assign(paste0(varname), as.vector(eval(as.name(varname)))) } -----Ursprungligt meddelande----- Fr?n: peter dalgaard [mailto:pdalgd at gmail.com] Skickat: den 4 december 2017 16:39 Till: Love Bohman <love.bohman at sociology.su.se> Kopia: r-help at r-project.org ?mne: R...
2018 Sep 19
5
segfault issue with parallel::mclapply and download.file() on Mac OS X
...y function call that I want to parallelize. Below is a very simplified version of the code: url_base <- "https://cloud.r-project.org/src/contrib/" files <- c("A3_1.0.0.tar.gz", "ABC.RAP_0.9.0.tar.gz") res <- parallel::mclapply(files, function(s) download.file(paste0(url_base, s), s)) Instead of download a couple of files in parallel, I get a segfault per process with a 'memory not mapped' message. I've been working with Henrik Bengtsson on resolving this issue and he recommended I send a message to the R-Devel mailing list. Here's the output:...
2017 Aug 05
2
Ussing assign
Hi there, Imagine I want to use a variable created with assign,but automatically. I have an issue with that. What I do is: #create in a loop the variables for(i in 1:5){ assign(paste0("variable",i),data.frame(x=rnorm(100),y=rnorm(100)) } Now, if I want to do create the five models, I do not know how to set this created data.frames I have tried: for (i in 1:5){ assign(paste0("model",i),lm(y~x,data=paste0("variable",i))) } but it does not...
2008 Apr 13
1
promptFunctions() to handle multiple names
...ile name string or NA for console ~ names = NULL, # character vector of object names ~ rdname = NULL, # name of the documentation ~ overwrite = FALSE # overwrite existing Rd file? ~ ) { ~ ## helper functions ~ paste0 <- function(...) paste(..., sep = "") ~ is.missing.arg <- function(arg) typeof(arg) == "symbol" && ~ deparse(arg) == "" ~ ## generate additional names from objects ~ objects <- as.list (substitute (...[])) ~ objects <- objects[se...
2013 Sep 05
2
binary symmetric matrix combination
...0 0 s2 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0",sep="",header=TRUE)) names1<-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4))) Out2<-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) vec1<- paste0(colnames(m1)[col(m1)],rownames(m1)[row(m1)]) vecOut<- paste0(colnames(Out2)[col(Out2)],rownames(Out2)[row(Out2)]) Out2[match(vec1,vecOut)]<- m1 vec2<- paste0(colnames(m2)[col(m2)],rownames(m2)[row(m2)]) Out2[match(vec2,vecOut)]<- m2 vec3<- paste0(colnames(m3)[col(m3)],rownames(m3)[ro...
2019 Jul 14
3
Potential bug with data.frame replacement
Dear R-devel, I have encountered a crash-inducing scenario and would like to enquire as to whether this would be considered a bug. To reproduce the crash: X <- sample(letters, 3000, TRUE) D <- data.frame(X, 1:3000, X, X, X, X, X) D$X1.3000 <- paste0("GSM", D) The reason why I'm not sure if this would be considered a bug is because I typed this by accident, when what I meant was: D$X1.3000 <- paste0("GSM", D$X1.3000) I can never image a scenario where I would intentionally perform the former. This issue seems to h...
2017 Dec 04
0
Dynamic reference, right-hand side of function
The generic rule is that R is not a macro language, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_", 2000:2007) datalist <- lapply(datanames, get) names(datalist) <- datanames col1 <- lapply(datalist, "[[", 1) colnum <- lapply(col1, as.numeric) (The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspac...
2015 Oct 09
3
reverse object creation
...e of the most tedious tasks is modification of lookup or conversion tables So far, I have not found functions that create the commands for creating objects (vectors, data frames) based on the objects themselves - i.e. to reverse-engineer them. Here are my suggestions: c_rev <- function(x) cat(paste0('c("', gsub(', ', '", "', toString(x)), '")\n')) df_rev <- function(x) { X <- apply(x, 1, function(x) { paste0('c(', paste0(shQuote(x), collapse = ", "),...
2017 Aug 05
0
Ussing assign
Hi Jesus, You probably want: assign(paste0("model",i),lm(y~x,data=get(paste0("variable",i)))) Jim On Sat, Aug 5, 2017 at 7:01 PM, Jes?s Para Fern?ndez <j.para.fernandez at hotmail.com> wrote: > Hi there, > > > Imagine I want to use a variable created with assign,but automatically. I have an issue with...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...he (eval(as.name()) function (I include the loop I used below). I understand that looping isn't kosher among you more devoted R-users, and eventually I hope I will learn to use lists in the future instead. > > Thanks! > Love > > > for (year in 2000:2007){ > varname <- paste0("aa_",year) > assign(paste0(varname), as.vector(eval(as.name(varname)))) > } > > -----Ursprungligt meddelande----- > Fr?n: peter dalgaard [mailto:pdalgd at gmail.com] > Skickat: den 4 december 2017 16:39 > Till: Love Bohman <love.bohman at sociology.su.se> &gt...