Displaying 6 results from an estimated 6 matches for "zhihuali".
Did you mean:
zhihua
2008 Sep 22
4
sort a data matrix by all the values and keep the names
Dear all,
If I have a data frame x<-data.frame(x1=c(1,7),x2=c(4,6),x3=c(8,2)):
x1 x2 x3
1 4 8
7 6 2
I want to sort the whole data and get this:
x1 1
x3 2
x2 4
x2 6
x1 7
x3 8
If I do sort(X), R reports:
Error in order(list(x1 = c(1, 7), x2 = c(4, 6), x3 = c(8, 2)), decreasing = FALSE) :
unimplemented type 'list' in 'orderVector1'
The only way
2008 Mar 07
4
locate the rows in a dataframe with some criteria
Hi, netters,
This is probably a rookie question but I couldn't find the answer after hours of searching and trying.
Suppose there'a a dataframe M:
x y
10 A
13 B
8 A
11 A
I want to locate the rows where x >=10 and y="A". I know how to do it to vectors by using
which, but how to do it with the dataframe?
Thank you very much!
Zhihua Li
2008 Jan 26
3
An R clause to bind dataframes under certain contions
Hi netters,
Suppose I have two data frames X and Y. X has three colnames A, B and C. Y has three colnames A,B and D.
I want to combine them into one matrix, joining the rows having the same A and B values (X$A==Y$A and X$B = Y$B). So the resulting dataframe has four variables/columns: A,B,C and D.
I was wondering what's the best way to do it in R. Could anyone give me some advice?
Thanks!
2008 Jan 26
3
Comparison of aggregate in R and group by in mysql
Hi, netters,
First of all, thanks a lot for all the prompt replies to my earlier question about "merging" data frames in R.
Actually that's an equivalence to the "join" clause in mysql.
Now I have another question. Suppose I have a data frame X with lots of columns/variables:
Name, Age,Group, Type, Salary.
I wanna do a subtotal of salaries:
aggregate(X$Salary,
2008 Sep 24
2
keep the row indexes/names when do aggregate
Hi, R-users,
If I have a data frame like this:
>x<-data.frame(g=c("g1","g2","g1","g1","g2"),v=c(1,7,3,2,8))
g v
1 g1 1
2 g2 7
3 g1 3
4 g1 2
5 g2 8
It contains two groups, g1 and g2. Now for each group I want the max v:
> aggregate(x$v,list(g=x$g),max)
g x
1 g1 3
2 g2 8
Beautiful. But what if I want to keep the row index of (g1
2008 Apr 17
1
how to use a function in aggregate which accepts matrix and outputs matrix?
Dear netters, suppose I have a matrix X [1,] 'c1' 'r6' '150'[2,] 'c1' 'r4' '70'[3,] 'c1' 'r2' '20'[4,] 'c1' 'r5' '90'[5,] 'c2' 'r2' '20'[6,] 'c3' 'r1' '10'I want to apply some funciton to groups of rows by the first column.If the function is just to