Hi,
I went for a slight alteration of your solution
x1<-c(1,2,3,4,NA ,NA ,NA, 3, 1, 1, 1, 1, 2, 2, 3, 4, 4)
x2<-c(2,3,4,3,4,3,4,2,2,3,4,NA,NA,NA,NA,4,3)
x3<-c(1,1,1,1,"aaa",2,2,2,3,3,3,3,4,4,4,1,2)
m<-data.frame(x1,x2,x3)
m<-replace(m,is.na(m),"NA")
levels=unique(as.vector(as.matrix(m)))
mapply(f
Dear R users,
I have a dataframe like this:
x1<-c(1,2,3,4,NA ,NA ,NA, 3, 1, 1, 1, 1, 2, 2, 3, 4, 4)
x2<-c(2,3,4,3,4,3,4,2,2,3,4,NA,NA,NA,NA,4,3)
x3<-c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,1,2)
m<-data.frame(x1,x2,x3)
I would like to create a frequency table like this:
x1 x2 x3
NA
1
2
3
4
whe
paste(a,b,sep=".")
}
}
Ralikwen wrote:
>
> Is there a way to use the cycle variable for rowname?
>
Thanks again.
Balázs
--
View this message in context:
http://www.nabble.com/using-for-variable-as-rowname-tp19533203p19549904.html
Sent from the R help ma
Is there a way to use the cycle variable for rowname?
v=1:6
for (a in 1:3){
for (b in 4:5) {
v=rbind(v,a.b=1)
}
}
v
This above obviously does not work, but I couldn't find out how to use a and
b to construct a rowname like 14, 15, 24, 25.
Thanks for the help.
Balazs
--
View this message in
Ok, I think I have this
it works if I use data.frame(cast(df,entityID ~ attributeID))
Ralikwen wrote:
>
> When I do as.matrix I loose those columns that I specified as row headers
> during cast.
> Maybe its because of this:
> "When coercing a vector, it produces a on
quot;numeric"
> Warning message:
> In eval(expr, envir, enclos) : NAs introduced by coercion
>> cbind(df, RTot=rowSums(x, na.rm=TRUE))
> a b c d RTot
> 1 o 21 10 15 46
> 2 p NA 11 16 27
> 3 q 23 12 17 52
>>
>
>
> On Tue, Sep 2, 2008 at 5:50 PM,
; # convert to numeric
>> x <- as.matrix(df)
>> mode(x) <- "numeric"
> Warning message:
> In eval(expr, envir, enclos) : NAs introduced by coercion
>> cbind(df, RTot=rowSums(x, na.rm=TRUE))
> a b c d RTot
> 1 o 21 10 15 46
> 2 p NA 11 16 27
> 3 q 23 1
Hi,
I am new to R.
I have a dataframe with many columns some of which contain genuine strings
some numerical values as strings. The dataframe is created by cast so I have
no control over the resulting data type.
I want to attach columns as aggregates of other columns to the dataframe.
Here is the
8 matches
Mail list logo