similar to: Looping

Displaying 20 results from an estimated 20000 matches similar to: "Looping"

2009 Sep 22
3
converting a character vector to a function's input
Hi all, I have been trying to solve this problem and have had no luck so far. I have numeric vectors VAR1, VAR2, and VAR3 which I am trying to cbind. I also have a character vector "VAR1,VAR2,VAR3". How do I manipulate this character vector such that I can input a transformed version of the character vector into cbind and have it recognize that I'm trying to refer to my numeric
2014 Aug 21
2
pregunta
Buenas noches Javier y José, Estoy en contra de usar attach(), asi que propongo la siguiente alternativa con with(): # paquete require(epicalc) # los argumentos en ... pasan de epicalc:::cc # ver ?cc para mas informacion foo <- function(var1, var2, var3, ...){ or1 <- cc(var1, var2, ...) or2 <- cc(var1, var3, ...) list(or1 = or1, or2 = or2) } # datos x <-
2004 Aug 17
5
Bug in colnames of data.frames?
Hi, I am using R 1.9.1 on on i686 PC with SuSE Linux 9.0. I have a data.frame, e.g.: > myData <- data.frame( var1 = c( 1:4 ), var2 = c (5:8 ) ) If I add a new column by > myData$var3 <- myData[ , "var1" ] + myData[ , "var2" ] everything is fine, but if I omit the commas: > myData$var4 <- myData[ "var1" ] + myData[ "var2" ] the name
2012 Jul 01
2
list to dataframe conversion-testing for identical
HI R help, I was trying to get identical data frame from a list using two methods. #Suppose my list is: listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2)) #Creating dataframe using cbind dat1<-data.frame(do.call("cbind",listdat1)) colnames(dat1)<-c("Var1","Var2","Var3") #Second dataframe conversion
2006 Jan 13
2
find mean of a list of timeseries
Can someone please give me a clue how to 're'write this so I dont need to use loops. a<-ts(matrix(c(1,1,1,10,10,10,20,20,20),nrow=3),names=c('var1','var2','var3')) b<-ts(matrix(c(2,2,2,11,11,11,21,21,21),nrow=3),names=c('var1','var2','var3'))
2011 May 19
2
trouble with summary tables with several variables using aggregate function
Dear all, I am having trouble creating summary tables using aggregate function. given the following table: Var1 Var2 Var3 dummy S1 T1 I 1 S1 T1 I 1 S1 T1 D 1 S1 T1 D 1 S1 T2 I 1 S1 T2 I 1 S1 T2 D 1 S1 T2 D 1 S2
2012 Oct 17
2
loop of quartile groups
Greetings R users, My goal is to generate quartile groups of each variable in my data set. I would like each experiment to have its designated group added as a subsequent column. I can accomplish this individually with the following code: brks <- with(data_variables, cut2(var2, g=4)) #I don't want the actual numbers, I need a numbered group data$test1=factor(brks,
2014 Aug 21
2
pregunta
Estimados Estoy entrenando hacer funciones que respondan a comandos, en esta caso en la salida gráfica se observa que dice : Exposure=var3 y outcome=var 1 quisiéramos que se reflejan los nombres de la base de datos : var1=estado, var2=cake, var3=chocolate Espero haberme explicado adecuadamente Adjunto tabla con datos #################################### #Comando que llama
2014 Apr 11
2
crear variable en base a nombre de columnas que tienen un 1
Carlos, en principio si sería algo así, sólo que en vez de quedarme con todas las columnas var1 a var4 tuviera sólo 3, ya que en mis datos no hay ningún caso que tenga el valor 1 en más de 3 variables.. Había llegado a una solución (mucho menos elegante que usando reshape), que implicaba un for sobre las filas. Jorge, creo que tu solución me vale. Muchas gracias a los dos.. Saludos El
2013 Mar 25
2
Faster way of summing values up based on expand.grid
Hello! # I have 3 vectors of values: values1<-rnorm(10) values2<-rnorm(10) values3<-rnorm(10) # In real life, all 3 vectors have a length of 25 # I create all possible combinations of 4 based on 10 elements: mycombos<-expand.grid(1:10,1:10,1:10,1:10) dim(mycombos) # Removing rows that contain pairs of identical values in any 2 of these columns: mycombos<-mycombos[!(mycombos$Var1
2005 Nov 29
1
Indexing variables within lapply?
Hello I am using R 2.2.0 with Windows XP. I've got a five element list object, each element containing two dataframes of equivalent size. > str(mylist) List of 1 $ data1:List of 2 ..$ data1a :`data.frame': 77 obs. of 63 variables: .. ..$ var1 : num [1:77] 0.41375 0.00056 1.43040 1.43528 0.61730 ... .. ..$ var2 : num [1:77] 1.154 1.686 0.673 0.800 0.760 ... ..
2016 Apr 28
0
Antwort: RE: Interdependencies of variable types, logical expressions and NA
Hi your initial ds > str(ds) 'data.frame': 2 obs. of 3 variables: $ var1: num 1 1 $ var2: logi TRUE FALSE $ var3: logi NA NA first result > str(ds) 'data.frame': 2 obs. of 6 variables: $ var1 : num 1 1 $ var2 : logi TRUE FALSE $ var3 : logi NA NA $ value_and_logical: logi TRUE TRUE $ logical_and_na : logi TRUE NA
2009 Jan 24
2
how to prevent duplications of data within a loop
Hi All, I had posted a question on a similar topic, but I think it was not focused. I am posting a modification that I think better accomplishes this. I hope this is ok, and I apologize if it is not. :) I am looping through variables and running several regressions. I have reason to believe that the data is being duplicated because I have been monitoring the memory use on unix. How can I avoid
2011 Jan 23
3
FUNC_ODBC and ARRAY
Gentlemen, I have googled, searched the mailing list archives, and even spoke on the IRC channel, but have not found an answer to the following problem. I am attempting to retrieve multiple columns in an ODBC query using ARRAY per the solutions offered by many individuals. My dialplan code is as follows: exten => _.,n,Set(ARRAY(var1,var2,var3)=${ODBC_LOOKUP(${KEYVAL})}) exten =>
2009 Nov 25
1
Sampling dataframe
Hi, I have a table like that: > datatest var1 var2 var3 1 1 1 1 2 3 1 2 3 8 1 3 4 6 1 4 5 10 1 5 6 2 2 1 7 4 2 2 8 6 2 3 9 8 2 4 10 10 2 5 I need to create another table based on that with the rules: take a random sample by var2==1 (2 sample rows for example): var1 var2 var3 1 1
2012 Nov 15
1
Extracting list names within a looped function
Hello all, I have the following problem: 1) A list was defined as 'a' a <- list("var1"=c(100:1), "var2"=c(1:100), "var3"=rnorm(100)) 2) a function 'foo' was defined that extracts the variable name assigned to x using the deparse(substitute()) functionality. This name will then be used within the function to generate specific output files, etc.
2014 Apr 11
6
crear variable en base a nombre de columnas que tienen un 1
Buenos días. Hoy ando un poco (o bastante) espeso y no doy con la tecla de una cosa que seguro que es muy simple.. Pongo un ejemplo. var1 <- c(rep(0,3),rep(1,2)) var2 <- c(rep(1,2),0,0,1) var3 <- c(rep(1,2),rep(0,3)) var4 <- c(rep(1,2),rep(0,3)) datos <- data.frame(fila=1:5,var1, var2, var3, var4) datos datos fila var1 var2 var3 var4 1 1 0 1 1 1 2 2 0
2010 Jun 18
3
inverse function of melt
Dear list, I'm looking for an inverse function of melt(which is in package reshape).Namely, I had a data frame like this (Table1) YEAR VAR1 VAR2 VAR3 1995 7 3 45 1996 5 6 32 1997 6 10 15 I transformed my data by using the melt function and my data was reshaped in the following format: (Table2) YEAR variable
2010 Feb 01
1
Manipulating data, and performing repeated simple regressions, not multiple regression
I have a simple table of data: Result Var1 Var2 Var3 1 0.10 0.78 0.12 0.38 2 0.20 0.66 0.39 0.12 3 0.10 0.83 0.09 0.52 4 0.15 0.41 0.63 0.95 5 0.60 0.88 0.91 0.86 6 -0.02 0.14 0.69 0.94 I am trying to achieve two things: 1) Manipulate this data so that I have the "Result" data unchanged, and all the other data
2009 Sep 01
2
Simple question about data.frame reduction
Hi, this is a simple question I have this data.frame: > test <- data.frame(var1=c(1,1,1,1,1,1),var2=c("a","a","b","c","d","e"),var3=c("a1","a1","b1","a1","c1","d1")) > test var1 var2 var3 1 1 a a1 2 1 a a1 3 1 b b1 4 1 c a1 5 1