Displaying 12 results from an estimated 12 matches for "rtan".
Did you mean:
ran
2010 Mar 09
5
data frame select max group by like function
Hi, I have a data frame with 3 columns: ID, year and score. How can I
select for each unique ID, the year that has the max score? For
example, for data frame
ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 2000, 97
tom, 1998, 60
mary, 1998,100
I shall have
ID, year, score
tom, 1995, 88
rick, 1994, 90
mary, 1998,100
Thanks,
Richard
[[alternative HTML version deleted]]
2009 Apr 13
3
toupper does not work in sub + regex
Hi, I don't know what I am doing wrong to the toupper does not seem
working in sub + regex. The following returns 's' not the upper class
'S' as I expect:
sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw")
Can someone tell me where I did wrong?
Thanks,
Richard
[[alternative HTML version deleted]]
2010 Oct 07
3
aggregate text column by a few rows
Hi, R function aggregate can only take summary stats functions, can I
aggregate text columns? For example, for the dataframe below,
> a <- rbind(data.frame(id=1, name='Tom',
hobby='fishing'),data.frame(id=1, name='Tom',
hobby='reading'),data.frame(id=2, name='Mary',
hobby='reading'),data.frame(id=3, name='John',
2010 Sep 16
3
get top n rows group by a column from a dataframe
Hi, is there an R function like sql's TOP key word?
I have a dataframe that has 3 columns: company, person, salary
How do I get top 5 highest paid person for each company, and if I have
fewer than 5 people for a company, just return all of them?
Thanks,
Richard
[[alternative HTML version deleted]]
2009 Jun 08
1
Regex question to find a string that contains 5-9 alpha-numeric characters, at least one of which is a number
Hi,
This is not exactly an R question but I am trying to use gsub to replace
a string that contains 5-9 alpha-numeric characters, at least one of
which is a number. Is there a good way to write it in a one line regex?
Thanks,
Richard
2009 Mar 13
1
search for string insider a string
Hi, sorry if it is a too stupid question, but how do I a string search
in R:
I have a dataframe A with A$test like:
test1
bcdtestblabla2.1bla
cdtestblablabla3.88blabla
and I want to search for string that start with 'dtest' and ends with
number and return the location of that substring and the number, so the
end result would be:
NA NA
3 2.1
2 3.88
I find grep can
2010 Nov 22
2
aggregate a Date column does not work?
Hi, I am trying to aggregate max a Date type column but have weird
result, how do I fix this?
> a <- rbind(
+ data.frame(name='Tom', payday=as.Date('1999-01-01')),
+ data.frame(name='Tom', payday=as.Date('2000-01-01')),
+ data.frame(name='Pete', payday=as.Date('1998-01-01')),
+ data.frame(name='Pete',
2009 Feb 12
3
get top 50 correlated item from a correlation matrix for each item
Hi,
I have a correlation matrix of about 3000 items, i.e., a 3000*3000
matrix. For each of the 3000 items, I want to get the top 50 items that
have the highest correlation with it (excluding itself) and generate a
data frame with 3 columns like ("ID", "ID2", "cor"), where ID is those
3000 items each repeat 50 times, and ID2 is the top 50 correlated items
with ID,
2010 Nov 24
0
4. Rexcel (Luis Felipe Parra)-how to run a code from excel
...s:
OP2003Seppos.AICnonsp-OP2003Seppos.AICsp
#[1] -4
(OP2003Seppos.lf0.p<-exp(OP2003Seppos.lf0$beta)/(1+exp(OP2003Seppos.lf0$beta
))) #P non spatial
#[1] 0.9717596
(OP2003Seppos.lf.p<-exp(OP2003Seppos.lf$beta)/(1+exp(OP2003Seppos.lf$beta)))
#P spatial
#[1] 0.9717596
It must what have an important influence at kriging, because it shows as
following:
OP2003Sepposbin.krig<-glsm.krige(OP2003Seppos.tune,loc=OP2003Seppospro.pred.
grid,bor=OP2003Sepposbor)
#glsm.krige: Prediction for a generalised linear spatial model
#There are 50 or mode advices (use warnings() to see them)
#> warnings(...
2009 Nov 10
2
gsub does not support \b?
Hello, can someone help? How come
> gsub("\bINDS\b","INDUSTRIES","ADVANCED ENERGY INDS")
[1] "ADVANCED ENERGY INDS"
not ADVANCED ENERGY INDUSTRIES
Thanks.
Richard
[[alternative HTML version deleted]]
2011 Jan 05
1
categorize a character column
Hi, I know I can do this with a for loop with strsplit and grep, but is
there more efficient way?
Given a data dataframe (input) and a category column (lst),
> input
item loc
1 item 1.1: earnings <sep> item 1.2: w2 <sep> shelf 1
2 item 1.3: deductions drawer 1
3 item 1.1:
2009 Feb 19
1
transform key value pair to column
Hi, is there a good way (instead of a time-consuming for loop) to
transfer a key/value pair dataframe to a dataframe with key as column
and value as row? For example, I have a dataframe with three columns:
id, code, value:
id,code,value
1,hi,10.3
1,lo,5.2
2,hi,19.4
3,hi,20
3,lo,12
4,lo,5.8
I want to get a dataframe like this:
id,hi,lo
1,10.3,5.2
2,19.4,NA
3,20,12
4,NA,5.8
Thank you,