Displaying 20 results from an estimated 10000 matches similar to: "Putting column names in some automated way"
2008 Jun 23
3
expand.grid() function
Hi,
I have one question on expand.grid() function.
When I write following syntax :expand.grid(c("u", "l"), c("u", "l"), c("u", "l")) I get following as desired :
Var1 Var2 Var3
1 u u u
2 l u u
3 u l u
4 l l u
5 u u l
6 l u l
7 u l l
8 l l l
However
2010 May 05
3
concatenate values of two columns
Dear list,
I'm trying to concatenate the values of two columns but im not able to do it:
i have a dataframe with the following two columns:
X VAR1 VAR2
1 2
2 1
3 2
4 3
5 4
6 4
what i would like to
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
2009 Jun 24
2
subsetting data frame using a vector of column names / values
Hello
I have a data frame d with columns "var1", "var2", "var3"
Then I have two vectors:
columns <- c("var2", "var3")
values <- c(0, 1)
Is there a compact way to subset the data frame
using these two vectors and get the result equivalent to:
select (d, var2==0 & var3==1) ?
Thank You
Blazej
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 <-
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
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
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'))
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
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
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
2012 Feb 15
2
assign same legend colors than in the grouped data plot
Dear community,
I've plotted data and coloured depending on the factor variable v3.
In the legend, I'd like to assign properly the same colors than in the
factor (the factor has 5 levels).
I've been trying this but it doesn't work.
plot(var1, var2, xlab = "var1", ylab = "var2", col =var3 , bty='L')
legend(locator(1),c("level 1 var3",
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
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
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
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
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 =>
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
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
2011 Mar 18
1
help please: put output into dataframe
Dear R community members
I have been struggling on this simple question, but never get appropriate
solution. So please help.
# my data, though I have a large number of variables
var1 <- rnorm(500, 10,4)
var2 <- rnorm(500, 20, 8)
var3 <- rnorm(500, 30, 18)
var4 <- rnorm(500, 40, 20)
datafr1 <- data.frame(var1, var2, var3, var4)
# my unsuccessful codes
nvar <- ncol(datafr1)