search for: paste0

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

Did you mean: paste
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 >...
2019 Jun 14
2
Ejecutar un script de Python con argumentos desde R
...onsola 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 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....
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...
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...
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...
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...
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...
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...
2016 Apr 26
0
Antwort: Fw: Re: Creating variables on the fly (SOLVED)
Hi Don, Hi to all readers, many thanks for all your answers and all your help. I adapted Don's code to my data and Don's code does the trick: str(Kunden01) for (year in 2011:2015) { Reeller_Kunde <- paste0("Reeller_Kunde_", year) Umsatz <- paste0("Umsatz_", year) cat('Creating', Reeller_Kunde,'from', Umsatz,'\n') Kunden01[[ Reeller_Kunde ]] <- ifelse( Kunden01[[ Umsatz ]] >= 0, 1, 2) Kunden01[[ Reeller_Kunde ]] <- factor( Kunden01[[ Reel...
2013 Sep 27
3
Compare species presence and absence between sites
Dear List, I want to compare the presence and absence of bird species based on the sites in a matrix. The matrix has 5 rows for Island A, B, C, D, and E. It has 100 columns for bird species D001-D100. In each cell of the matrix, the presence-absence of bird species will be recorded as 1 or 0. (For example, if species D001 is found on Island D, the matrix cell of species D001 and Island D
2017 Dec 04
2
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> >...
2014 Dec 09
2
Optimizar paste0()?
Hola a todos, Me gustaria construir un vector a partir de otros dos. Ejemplo: x <- 1:3 y <- 4:6 d <- data.frame(x, y) d$z <- with(d, paste0(x, ":", y, "-ABC")) d El problema es "d" tiene ~70 millones de filas y toma mucho tiempo construir el vector "z". Alguna sugerencia? Muchas gracias, Jorge Velez [[alternative HTML version deleted]]
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all, Without a loop, I would like transform 3 numeric vectors empty of 0/1 of same length Vec1 : transform 1 to A and 0 to "" Vec2 : transform 1 to B and 0 to "" Vec3 : transform 1 to C and 0 to "" to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC, BC, AC, AB,...) Any idea ? Thank you for your help -- Michel ARNAUD
2018 Apr 16
5
how to write a loop to repetitive jobs
Hi All.., I need to do the following repetitive jobs: seg71 <- read.csv("C:/Awork/geneAssociation/removed8samples/neuhausen71/seg.pr3.csv", head=T) seg71$id <-"sn71" seg72 <- read.csv("C:/Awork/geneAssociation/removed8samples/neuhausen72/seg.pr3.csv", head=T) seg72$id <-"sn72" seg73 <-
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
Hi, Suppose, if I create 15 files in my working directory. set.seed(48) lapply(1:15,function(i) {m1 <- matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)}) ?D <-dir() D1 <- D[order(as.numeric(gsub("\\D+","",D)))] D1 ?res <- t(sapply(D1,function(x) {x1<- read.table(x,header=TRUE); x1[,2]})) dim(res) #[1]?? 15 1686 #or res1 <- do.call(rbind,lapply(D...
2011 Dec 13
0
paste0 bug in install.packages() - leopard installer?
...rce* package 'abind' ... ** package 'abind' successfully unpacked and MD5 sums checked ** R ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded *** arch - i386 *** arch - ppc Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function Calls: Sys.setenv -> .expand_R_libs_env_var -> expand -> gsub -> paste0 Execution halted *** arch - x86_64 ERROR: loading failed for 'ppc' * removing '/Library/Frameworks/R.framework/Versions/2.15...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...ion (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...