Displaying 20 results from an estimated 129 matches for "var4".
Did you mean:
var
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 1 1 0 0
El caso es que quiero crear 3 variables...
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
"occurrence&q...
2004 Aug 17
5
Bug in colnames of data.frames?
...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 "var4":
> myData
var1 var2 var3 var1
1 1 5 6 6
2 2 6 8 8
3 3 7 10 10
4 4 8 12 12
but names() and colnames() return the expected name...
2008 Mar 19
4
plot with diffrent colour and plotting symbols
Dear mailing list members,
I am a new R user, I would like to plot the follewing data
var1 <- c(1,2,1,1,2,1,2,1,2,2)
var2 <- round(rgamma(10,2,1)/0.1)*0.1
var3 <- c(0,1,0,1,0,0,0,0,1,0)
var4 <- c(1,2,2,2,1,1,1,1,1,1)
Var <- data.frame(var1,var2,var3,var4)
Var <- Var[sort(Var$var1),]
tt <- Var$var1+((runif(length(Var$var1))/6)-(0.5/6))
labelname <- c("time 1", "time 2")
plot(tt,var2,xaxt = "n")
axis(1,1:length(unique(var1)), labelname)
Cou...
2013 Mar 25
2
Faster way of summing values up based on expand.grid
...<-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 == mycombos$Var2),]
mycombos<-mycombos[!(mycombos$Var1 == mycombos$Var3),]
mycombos<-mycombos[!(mycombos$Var1 == mycombos$Var4),]
mycombos<-mycombos[!(mycombos$Var2 == mycombos$Var3),]
mycombos<-mycombos[!(mycombos$Var2 == mycombos$Var4),]
mycombos<-mycombos[!(mycombos$Var3 == mycombos$Var4),]
dim(mycombos)
# I want to write sums of elements from values1, values2, and values 3
whose numbers are contained in each...
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 11/04...
2011 Jan 19
3
lme-post hoc
...all,
I analysed my data with lme and after that I spent a lot of time for
mean separation of treatments (post hoc). But still I couldn’t make
through it. This is my data set and R scripts I tried.
replication fertilizer variety plot height
1 level1 var1 1504 52
1 level1 var3 1506 59
1 level1 var4 1509 54
1 level1 var2 1510 48
2 level1 var1 2604 47
2 level1 var4 2606 51
2 level1 var3 2607 55
2 level1 var2 2609 44
3 level1 var2 3401 46
3 level1 var3 3402 64
3 level1 var4 3403 64
3 level1 var1 3404 50
1 level2 var3 1601 59
1 level2 var1 1605 56
1 level2 var2 1610 53
1 level2 var4...
2009 Sep 21
5
More elegant way of excluding rows with equal values in any 2 columns?
...rows that have equal values in ANY 2 columns. Here is how I am
doing it:
index<-expand.grid(1:4,1:4,1:4,1:4)
dim(index)
# Deleting rows that have identical values in any two columns (1 line of code):
index<-index[!(index$Var1==index$Var2)&!(index$Var1==index$Var3)&!(index$Var1==index$Var4)&!(index$Var2==index$Var3)&!(index$Var2==index$Var4)&!(index$Var3==index$Var4),]
dim(index)
index
I was wondering if there is a more elegant way of doing it - because
as the number of columns increases, the amount of code one would have
to write increases A LOT.
Thank you very much f...
2012 Oct 17
2
loop of quartile groups
...1:ncol(survival_data_variables)){
brks=as.data.frame(with(survival_data_variables,
cut2(survival_data_variables[,i], g=4)))
Any assistance would be sincerely appreciated. I would like the final data
set to have the following layout:
ID var1 var2 var3 var4 quartile var1
quartile var2 quartile var3 quartile var4
Here is a subset of my data to work with:
structure(list(ID = c(11112L, 11811L, 12412L, 12510L, 13111L,
20209L, 20612L, 20711L, 21510L, 22012L), var1 = c(106, 107,
116, 67, 76, 146, 89, 62, 65, 116), var2 = c(0, 0, 201,...
2011 Apr 04
4
merging data list in to single data frame
...t this is not what I want.
I want a single dataframe (all separate dataframes have same variable
headings) with additional row for example
; just for example, two small datasets are created by my component datasets
are huge, need automation
;read from file K1cd.txt
var1 var2 var3 var4
1 6 0.3 8
3 4 0.4 9
2 3 0.4 6
1 0.4 0.9 3
;read from file K2cd.txt
var1 var2 var3 var4
1 16 0.6 7
3 14 0.4 6
2 1 3...
2012 May 09
0
serie de tiempo incompleta: rellenar sólo fechas (claudiomet)
...ificil saber donde hay discontinuidades. No me interesa llenar los vacÃos
> en las variables, sólo las fechas y dejar las variables en blanco ¿es
> posible hacerlo en R?. Mi serie de tiempo es del tipo (con fecha en formato
> dd-mm-yyyy hh:mm):
>
> 01-01-2011 00:00 var1 var2 var3 var4 var5 var6 var7 var8
> 01-01-2011 00:01 var1 var2 var3 var4 var5 var6 var7 var8
> 01-01-2011 00:02 var1 var2 var3 var4 var5 var6 var7 var8
> 01-01-2011 00:03 var1 var2 var3 var4 var5 var6 var7 var8
> 01-01-2011 00:04 var1 var2 var3 var4 var5 var6 var7 var8
> 01-01-2011 00:07 var1 var2...
2011 Apr 04
2
reading from text file that have different rowlength and create a data frame
Hi R-experts
I have many text files to read and combined them into one into R that are
output from other programs. My textfile have unbalanced number of rows for
example:
;this is example
; r help
Var1 Var2 Var3 Var4 Var5
0 0.05 0.01 12
1 0.04 0.06 18 A
2 0.05 0.08 14
3 0.01 0.06 15 B
4 0.05 0.07 14 C
and so on
Inames<-as.data.frame(read.table("CLG1mpd.asc",hea...
2012 Jan 10
4
Sum of a couple of variables of which a few have NA values
...ll over the internet but I cannot find a way to solve my problem.
In my data I want to sum a couple of variables. Some of these
variables have NA values, and when I add them together, the result is
NA
dat <- data.frame(
id = gl(5,1),
var1 = rnorm(5, 10),
var2 = rnorm(5, 7),
var3 = rnorm(5, 6),
var4 = rnorm(5, 3),
var5 = rnorm(5, 8)
)
dat[3,3] <- NA
dat[4,5] <- NA
> dat
?id ? ? ?var1 ? ? var2 ? ? var3 ? ? var4 ? ? var5
1 ?1 ?9.371328 7.830814 5.032541 3.491053 7.626418
2 ?2 10.413516 7.333630 6.557178 1.465597 8.591770
3 ?3 10.967073 ? ? ? NA 6.674079 3.946451 7.251263
4 ?4 ?9.900380...
2012 Mar 10
1
Use different panel functions with lattice
Hi,
I have a data.frame df with
names(df) = c("Var1", "Var2", "Var3", "Var4")
and I plot data with
xyplot(Var1+Var2~Var3|Var4, data=df)
I want to use different panel functions for Var1 and Var2.
How can I do ?
Something like :
panel.mypanel = function(x, y, ...) {
if (Var1) panel.Var1Panel(x, y, ...)
else panel.Var2Panel(x, y, ...)
}
xyplot(Var1+Var2~Var3|Var...
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
...uld not solve it by spending days.
My data looks like this:
# data
set.seed(1234)
clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100
level for this factor var;
yvar <- rnorm(40, 10,6);
var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2);
var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15, 8) # just example
df <- data.frame(clvar, yvar, var1, var2, var3, var4, var5)
# manual splitting
df1 <- subset(df, clvar == 1)
df2 <- subset(df, clvar == 2)
df3<- subset(df, clvar == 3)
df4<- subset(df, clvar == 4)
df5<- subset(df,...
2006 Jan 11
1
updating formula inside function
...39;+'),sep=''))
linmod <- lm(f)
return(linmod)
}
By typing
foo(mydata,'a','b','c')
I get the result of the linear model a~b+c.
How can I rewrite the function so that the formula can be updated inside
the function, i.e.
foo <- function(data,var1,var2,var3,var4) {
f <- formula(paste(var1,'~',paste(var2,var3,sep='+'),sep=''))
linmod <- lm(f)
return(linmod)
f2 <- update.formula(f,.~.-var3+var4)
}
Like that it won't work because var3 and var4 are characters, but also
with substitute() and eval() I did not manage to g...
2008 Sep 30
0
calculating weighted correlation coefficients
...apply.
$ model :'data.frame': 297 obs. of 6 variables:
..$ VAR1 : num [1:297] 5.21 9.82 8.08 0.33 8.7 6.82 3.94 4 0 5 ...
..$ VAR2 : num [1:297] 7.82 9.79 8.5 5.59 7.82 7.13 5.59 7 0 5 ...
..$ VAR3 : num [1:297] 8.07 9.82 8.07 5.19 8.69 7.45 6.08 5 0 8 ...
..$ VAR4 : num [1:297] 6.66 9.81 8.62 4.97 8.62 5.9 5.9 0 0 6 ...
..$ VAR5 : num [1:297] 4.79 9.8 7.9 0.27 7.9 5.76 3.44 5 0 4 ...
..$ (weights): num [1:297] 1.01e-05 4.05e-01 1.24e-02 2.68e-05 3.02e-01
...
I use cov.wt() function (as this is the only function I could find to
calculate weighted...
2012 Sep 06
1
Interaction plot glm?
...inner in both statistics and the usage of R. I have been stuck for
days with a problem I hope somebody is willing to help me solving.
I'm trying to create some kind of graphical plot etc. of my results of the
following glm of interactions.
I17<-glm(formula = response ~ var1+ var2 + var3 + var4 + var1:var3 +
var1:var4, data = data)
Is there any possibility to solve this??
Thanks in advance!!
--
View this message in context: http://r.789695.n4.nabble.com/Interaction-plot-glm-tp4642354.html
Sent from the R help mailing list archive at Nabble.com.
2010 Nov 08
2
Several lattice plots on one page
Dear all,
I am trying (!!!) to generate pdfs that have 8 plots on one page:
df = data.frame(
day = c(1,2,3,4),
var1 = c(1,2,3,4),
var2 = c(100,200,300,4000),
var3 = c(10,20,300,40000),
var4 = c(100000,20000,30000,4000),
var5 = c(10,20,30,40),
var6 = c(0.001,0.002,0.003,0.004),
var7 = c(123,223,123,412),
var8 = c(213,123,234,435),
all = as.factor(c(1,1,1,1)))
pdf("test1.pdf", width=20, heigh=27, paper="a4")
print(plot(groupedData(var1 ~ day | all, data =...
2010 Dec 03
2
Add columns of dataset
Dear all,
I have a dataset that looks like
id var1 var2 var4 var7 var8
1 0.0 0.1 0.3 0.9 0.0
2 0.4 0.6 0.0 0.0 0.2
3 0.0 0.0 0.0 0.8 0.7
Some columns are missed, for example, here the fourth (var3), sixth(var5)
and seventh (var6) columns. I want to first determine which columns are
missed in a huge da...