Displaying 20 results from an estimated 715 matches for "var2".
Did you mean:
var
2008 Jul 16
2
Group level frequencies
Dear List,
I have Multi-level Data
i= Indivitual Level
g= Group Level
var1= First Variable of interest
var2= Second Variable of interest
and I want to count the frequency of "var1" and "var2" on the group
level.
I found a way, but there must be a much simpler way.
data.ml <-
data.frame(i=c(1:8),g=as.factor(c(1,1,1,2,2,3,3,3)),var1=c(3,3,3,4,4,4,4
,4), var2=c(8,8,8,2,2,4,4,4))
t...
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 shown above the 4th column is not "...
2002 Jul 09
3
Assignment converts variable to factor
Hello,
I would like to know if this behaviour in R is as expected.
I have a data frame 'dat' with column var1 being character (and not
factor). Then I create a new column 'var2' by:
> dat[,"var2"] <- dat$var1;
Column var2 is now a factor.
But if I do:
> dat$var2 <- dat$var1;
Then column var2 is character (and not factor).
I don't want to have var2 as factor by doing the first assignment. I tried
using 'as.character(dat$var1)'...
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 vectors VAR1, VA...
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 1 1 1
3 3 0 0 0 0
4 4 1 0 0 0
5 5...
2013 Mar 15
6
[LLVMdev] Simple question
Hi,
I think this is a very simple question, and it must just be missing something.
I am looking for find out how to assign a constant integer value to
the variable in llvm ir.
The following returns 12, and %var2 = 12.
; ModuleID = 't.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
define i32 @test() nounwind readnone {...
2006 Oct 23
1
Lmer, heteroscedasticity and permutation, need help please
Hi everybody,
I'm trying to analyse a set of data with a non-normal response, 2 fixed
effects and 1 nested random effect with strong heteroscedasticity in the
model.
I planned to use the function lmer : lmer(resp~var1*var2 + (1|rand)) and
then use permutations based on the t-statistic given by lmer to get
p-values.
1/ Is it a correct way to obtain p-values for my variables ? (see below)
2/ I read somewhere that lme is more adequate when heteroscedasticity is
strong. Do I have to use lme instead of lmer ?
3/ It...
2008 Jan 07
4
is there something like or() ?
hi, this may be trivial, but we can't seem to find anything adequate,
(although there is a work around with match() ). We are looking for something
along the lines of
plot(table1[table1$var2==or("a","b","c","d"),"var1"])
would be handy, with the potential or() function leading to what
plot(table1[table1$var2=="a" | table1$var2=="b" | table1$var2=="c" |
table1$var2=="d","var1"])
wou...
2011 Feb 28
3
Problems using unique function and !duplicated
...e variables from two or more
variables in a small R data.frame. I am trying to reproduce the SAS
statements from a Proc Sort with Nodupkey for those familiar with SAS.
Here's my example data :
test <- read.csv("test.csv", sep=",", as.is=TRUE)
> test
date var1 var2 num1 num2
1 28/01/11 a 1 213 71
2 28/01/11 b 1 141 47
3 28/01/11 c 2 867 289
4 29/01/11 a 2 234 78
5 29/01/11 b 2 666 222
6 29/01/11 c 2 912 304
7 30/01/11 a 3 417 139
8 30/01/11 b 3 108 36
9 30/01/11 c 2 288 96
I am tryi...
2010 Dec 20
2
Turning a Variable into String
...tring. I have tried
as.symbol and as.name but it doesnt work for what I'd like to do
Essentially, I'd like to feed the function below with two variables. This
works fine in the bit working out number of elements in each variable.
In the print(sprintf("OK with %s and %s\n", var1, var2)) line I would like
var1 and var2 to be magically substituted with a string containing the name
of var1 and name of var2.
Thanks in advance
Paolo
haveSameLength <- function(var1, var2) {
if (length(var1)==length(var2))
{
print(sprintf("OK with %s and %s\n", var1, var2))
}...
2012 Jan 16
3
Select rows based on multiple comparisons
...or 4 times. I need
to aggregate this data to maintain only one unit by row. But I need to do
that based on a comparison between the values of such units. I can't find a
function to help me on that. I appreciate any help. Below I provide an
example of what I want:
This is my data:
Units Var1 Var2 Var3
1 B 2 2
1 C 1 3
2 D 3 3
2 C 2 1
2 A 1 2
3 C 2 1
3 A 1 3
4 B 3 3
4 C 2 2
4 A...
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'))
c<-ts(matrix(c(3,3,3,12,12,12,22,22,22),nrow=3),names=c('var1','var2','var3'))
data<-list(a,b,c)
I now want to find the means of all vector...
2008 Aug 07
2
List of "occurrence" matrices
R users,
I don't know if I can make myself clear but I'll give it a try. I have
a data.frame like this
x <- "var1,var2,var3,var4
a,b,b,a
b,b,c,b
c,a,a,a
a,b,c,c
b,a,c,a
c,c,b,b
a,c,a,b
b,c,a,c
c,a,b,c"
DF <- read.table(textConnection(x), header=T, sep=",")
DF
and I would like to sum all the combinations/occurences by a factor
(letter in this case) between variables and produce a list of
"oc...
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 a una función
rm(list=ls())
#setwd("D:/DEMO_new/demo_scripts/OR/")
#setwd("D:/Public/Documents/R/EPICALC/funciones/OR/")...
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 <- read.csv("~/Downloads/OR.csv")
head(x)
# resultados SIN graficas
with(x, foo(estado, cake, chocolate, graph = FALSE))
Saludos,
Jorge.-
2014-08-21 12:40 GMT+10:00 J...
2008 May 02
2
Coercing by/tapply to data.frame for more than two indices?
...h needs to pay attention to the indices of the
output...this is to say, the "create an array" function of tapply doesn't
quite work because an array is not quite what we want.
Consider this data set:
df <- data.frame(var1= factor(rep(rep(1:5,25*5),10)),
var2= factor(rep(rep(1:5,each=25*5),10),
trial= rep(rep(1:25,25),10),
id= factor(rep(1:10,each=5*5*25)),
score= rnorm(n=5*5*25*10) )
...this is to say, each of 10 ids has scores for 5 different levels of
var1 and 5 different levels of var2...across...
2013 Dec 06
2
Using assign with mapply
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk <- data.frame(vars=c("var1", "var2", "var3"),
vals=c(10, 20, 30), stringsAsFactors=F)
If I do
: assign(kkk$vars[1], kkk$vals[1])
it works
: var1
[1] 10
However, if I try with mapply this is what I get:
: mapply(assign, kkk$vars, kkk$vals)
var1 var2 var3
10 20 30...
2009 Jan 13
3
Comparing elements for equality
Suppose I have a dataframe as follows:
dat <- data.frame(id = c(1,1,2,2,2), var1 = c(10,10,20,20,25), var2 =
c('foo', 'foo', 'foo', 'foobar', 'foo'))
Now, if I were to subset by id, such as:
> subset(dat, id==1)
id var1 var2
1 1 10 foo
2 1 10 foo
I can see that the elements in var1 are exactly the same and the
elements in var2 are exactly the same....
2010 Jul 29
3
Fwd: duplicates
-- Eredeti üzenet --
Feladó: Dévaványai Agamemnón <devavanyai@citromail.hu>Címzett: r-hel@r-project.org, r-hel@r-project.orgElküldve: 2010. július 29. 16:29Tárgy : duplicates
Sorry!
I try it again
Dear R Users!
I have a dataframe with duplicatecases. Var1 duplicated by var2.
var1 var2 var3 var4 var5
1 4 500 1 2
1 3 200 2 5
1 8 125 1 9
2 2 120 2 52
2 6 22 1 20
2 9 400 1 22
3 1 100 2 8
3 2 200 5 40...
2012 Mar 12
3
lapply to change variable names and variable values
Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation With R and the R Book and can't find an answer.
Sample list of data frames looks as follows:
.xx<-list(df<-data.frame(Var1=rep('Alabama', 400), Var2=rep(c(2004, 2005, 2006, 2007), 400)), df2<-data.frame(Var1=rep('Tennessee', 400), Var2=rep(c(2004,2005,2006,2007), 400)), df3<-data.frame(Var1=rep('Alaska', 400), Var2=rep(c(2004,2005,2006,2007), 400)) )
I would like to accomplish the following two tasks.
First, I'd like...