similar to: Loop over several Variables, add on question

Displaying 20 results from an estimated 10000 matches similar to: "Loop over several Variables, add on question"

2013 Apr 25
2
Selecting and then joining data blocks
Hi all, I have 4 matrices, each having 5 columns and 4 rows .....denoted by B1,B2,B3,B4. I have generated a vector of 7 indices, say (1,2,4,3,2,3,1} which refers to the index of the matrices to be chosen and then appended one on the top of the next: like, in this case, I wish to have the following mega matrix: B1over B2 over B4 over B3 over B2 over B3 over B1. 1> How can I achieve this?
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
2013 Mar 04
3
A problem with text manipulation
Hello again, Let say I have following vector: set.seed(1) Vec <- sample(LETTERS[1:5], 10, replace = TRUE) Vec Now with each repeated letter, I like to add suffix programatically. Therefore I want to get following vector: c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A") Can somebody
2020 Jul 25
2
Guidelines when to use LF vs CRLF ("\n" vs. "\r\n") on Windows for new lines (line endings)?
Dear R developers, I am developing an R package which returns strings with new line codes. I am not sure if I should use "\r\n" or "\n" in my returned strings on Windows platforms. What is the recommended best practice for package developers (and code in base R) for coding new lines in strings? And just out of curiosity: What is the reason (or history) for preferring
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,
2017 May 24
2
reg-tests-1d.R fails in r72721
On 2017-05-24, Duncan Murdoch wrote: > > I think the test is wrong 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("~/",
2006 Jan 05
1
Adding dsmark qdisc fails
I ''m having a problem identical to one encountered on this list awhile back: >I''m trying to configure dsmark qdisc on 2.6.11.4 user mode linux and >tc from iproute2-2.6.11-050314. > > >I think I have some mismatch in my setup since adding dsmark qdisc >fails *unless* I specify "set_tc_index" argument which I believe should >be optional:
2019 Jun 14
2
Ejecutar un script de Python con argumentos desde R
Ni idea de eso; te lo agradezco. Seguramente lo voy a terminar usando bastante. Pregunto: ahí debería hacer todas las operaciones propias del sistema? No me encuentra el script, y se me hace raro. Capaz que pasa al sistema desde la carpeta en 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
2019 Jun 14
2
Ejecutar un script de Python con argumentos desde R
Hola, amigos Se me acabo la sapienza. A ver: tengo un sript de Python script.py que neesita sus argumentos arg1 arg2 arg3, si 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/')
2013 Mar 23
4
Converting a character vector to numeric
Hello again, Let say I have following vector: Vec <- c("0.0365780769", "(1.09738648244378)", "(0.812507787221523)", "0.5778069963", "(0.452456601362355)", "-1.8900812605", "-1.8716093762", "0.0055217041", "-0.4769192333", "-2.4133018880") Now I want to convert this vector to numeric vector. 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" > >
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 +
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(
2008 Apr 13
1
promptFunctions() to handle multiple names
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi all, I wanted to set up my first (private) R-package and wondered if there was a function to prompt() for multiple aliases in one Rd-file, e.g. to create something like the normal distribution manual page encompassing rnorm, dnorm,... As I didn't find it, I modified prompt.default() and wrote a small function to do this job, called
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
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi R-users! Being new to R, and a fairly advanced Stata-user, I guess part of my problem is that my mindset (and probably my language as well) is wrong. Anyway, I have what I guess is a rather simple problem, that I now without success spent days trying to solve. I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 aa_2002, etc. Each dataset is imported as a matrix, and
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi! Thanks for the replies! I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The syntax from Peter Dalgaard was really clever, and I learned a lot from it, even though it didn't solve my problem (I guess it wasn't very well explained). My problem was basically that I have a data matrix
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 that. What I do is: > > > #create in a loop the
2018 Sep 19
5
segfault issue with parallel::mclapply and download.file() on Mac OS X
I have an lapply 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
2017 Dec 04
0
Dynamic reference, right-hand side of function
Um, if you insist on doing it that way, at least use assign(varname, as.vector(get(varname))) -pd > On 4 Dec 2017, at 22:46 , Love Bohman <love.bohman at sociology.su.se> wrote: > > Hi! > Thanks for the replies! > I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The