[R] merging two specific rows in a DF

2012-11-26 Thread karthicklakshman
Hello members,

I have this data frame with 3 columns,
C1  C2  TYPE
10  20  A
33  44  B
66  80  A
111 140 B
144 220 B
300 340 A
380 449 A
455 500 B
510 520 A
540 580 B

Here,  the rows 4 , 5 has type "B" and similarly 6,7 has "A" . I need to
merge these rows in a way to get the output with unique type, something like
below, where the lowest value from DF$C1 and  highest value from DF$C2
corresponding to rows 4,5 are picked.

C1  C2  TYPE
10  20  A
33  44  B
66  80  A
111 220 B
300 449 A
455 500 B
510 520 A
540 580 B

I Request your kind help..
Regards,
karthick




--
View this message in context: 
http://r.789695.n4.nabble.com/merging-two-specific-rows-in-a-DF-tp4650826.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] DF grouping

2012-11-26 Thread karthicklakshman
Hello Petr Savicky, hello all,

I have a situation similar to the previous one,
I need to group a data.frame in a specific way,

col1 col2   score
2873  3192   319
4268  4451   183
5389  5534   145
6622 10622  4000
12631 17853  5222
20408 20615   207
21595 21838   243
23121 2313918

the out put should be like,

[1] 
2873  3192   4268  4451   5389  5534  6622 10622 
[2] 
10622  12631
[3] 
17853 20408 20615  21595 21838   23121 23139 

Basically the split should be based on the DF$score > 500, and all the col1
and col2 values should be aggregated. but  DF[i, "col2"] != DF[i+1, "col1"]

Your inputs will be very helpful
Thank you
Karthick




--
View this message in context: 
http://r.789695.n4.nabble.com/DF-grouping-tp4381310p4650865.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Cbind query

2010-10-22 Thread karthicklakshman

I am new to R and request your kind help.

I have a table like the one below, 
   one two
1  apple  fruit
2  ball game
3  chair   wood
4  wood   plain
5  fruitbanana
6  cloth   silk

Note: duplicate entries are there

the task is to create relations to each each row entries, like "apple ->
fruit" . when I tried to combine column1 with column 2 (one, two), using
"cbind" the string is changed to numerical value...something like this
[,1] [,2]
   [1,]   10   53
   [2,]   25  562
   [3,]   25  462
   [4,]   25 1045
   [5,]   25  488
   [6,]   26 1062
   [7,]   27  951
   [8,]   27  144
   [9,]   27  676
  [10,]   27  486

Please suggest me how to get the string names back like the first table in
the out put, using cbind.

Thanks in advance
regards
kaarz

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Cbind-query-tp3006988p3006988.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cbind query

2010-10-22 Thread karthicklakshman

Hello jholtman,

Thanks very much for the suggestion.

I tried using "as.is=TRUE" and it worked as the way I expected. Sorry for
not being clear about the problem in my mail.

The characters are very much needed, cos I am trying to create a signaling
network using "Rgraphviz".

Thanks again.
Regards,
kaarz
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Cbind-query-tp3006988p3008190.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Odp: Cbind query

2010-10-22 Thread karthicklakshman

Hello Petr Pikal,

Thanks for the suggestion.

I am sorry for not being very clear in my mail. from your example, Its clear
to me now about how to turn factors to character values. 

I am working on large data sets, and the ultimate aim is to create
interaction network, so the characters are very important and your post is
of true value.

Thanks for your inputs
Regards,
karthick
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Cbind-query-tp3006988p3008195.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Parsing txt file

2010-11-10 Thread karthicklakshman

Hello,

I have a tab limited text document with multiple lines as mentioned below,



#FILE FORMAT
#Book   booknameauthor  publisher   pages
#CD namecontent

--
BookbioRxxx abc publishers  230
CD  biorexampleschapter5
--
Bookbioc++  mmm tata publishers 400
CD  samples workexamples
CD  dataexperiments
--
Bookmanagement toolsaaa some publishers 200
--


here the texts "book" and "CD" are present in each block.

now, I am interested in creating a data frame with two columns, column
names="bookname" and "content". Using "grep" it is possible to pick specific
rows (grep("^book, finename")) but my expertise in programming is limited to
create the mentioned data.frame.

Note: the rowname "book" is present in all blocks but "CD" is variable (ie.,
some block has two and some with no CD row, as shown above)

please help me in creating something like this,


 bookname   content
[1] bioR   chapter5
[2] bioc++workexamples, experiments
[3] management tools   NA


Thanks in advance,
karthick
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Parsing-txt-file-tp3035749p3035749.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Parsing txt file

2010-11-10 Thread karthicklakshman

Hello Jim, hello all,

Thanks very much for the inputs, I used the code and it solved my
problem
special thanks to Jim Holtman for the code.

Regards,
karthick 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Parsing-txt-file-tp3035749p3036284.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] to represent color range on plot segment

2011-08-27 Thread karthicklakshman
Dear R community,

With an advantage of being "NEW" to R, I would like to post a very basic
query here,

I am in need of representing gene expression data which ranges from -0.09 to
+4, on plot "segment". please find below the data df, the expression values
are in df[,2]. kindly help me with the code, so that I can represent the
values with a clear color gradient (something like -0.09 to 0 as red
gradient and 0 to +4 as green gradient)

location value
15  chr+:14001-15001  0.99749499
16  chr+:15001-16001  0.99957360
17  chr+:16001-17001  0.99166481
18  chr+:17001-18001  0.97384763
19  chr+:18001-19001  0.94630009
20  chr+:19001-20001  0.90929743
21  chr+:20001-21001  0.86320937
22  chr+:21001-22001  0.80849640
23  chr+:22001-23001  0.74570521
24  chr+:23001-24001  0.67546318
25  chr+:24001-25001  0.59847214
26  chr+:25001-26001  0.51550137
27  chr+:26001-27001  0.42737988
28  chr+:27001-28001  0.33498815
29  chr+:28001-29001  0.23924933
30  chr+:29001-30001  0.14112001
31  chr+:30001-31001  0.04158066
32  chr+:31001-32001 -0.05837414
33  chr+:32001-33001 -0.15774569
34  chr+:33001-34001 -0.25554110
35  chr+:34001-35001 -0.35078323
36  chr+:35001-36001 -0.44252044
37  chr+:36001-37001 -0.52983614
38  chr+:37001-38001 -0.61185789
39  chr+:38001-39001 -0.68776616
40  chr+:39001-40001 -0.75680250
41  chr+:40001-41001 -0.81827711
42  chr+:41001-42001 -0.87157577
43  chr+:42001-43001 -0.91616594
44  chr+:43001-44001 -0.95160207

Thanks in advance,
regards,
karthick



--
View this message in context: 
http://r.789695.n4.nabble.com/to-represent-color-range-on-plot-segment-tp3773392p3773392.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] to represent color range on plot segment

2011-08-29 Thread karthicklakshman
Dear Jim,

Thank you very much for your code.

There is no problem with
df[df[,2]>0,3]<-color.scale(df[df[,2]>0,2],c(1,0),1,c(0,1)) but the other
has an error message if there is a negative value, like
> df[df[,2]<0,3]<-color.scale(df[df[,2]<0,2],1,c(1,0),c(1,0))
Error in rgb(reds, greens, blues) : 
  color intensity -0.157746, not in [0,1]

Kindly update me with your comments.

Regards,
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/to-represent-color-range-on-plot-segment-tp3773392p3775990.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R matrix help

2012-06-14 Thread karthicklakshman
Dear R experts,

I am interested in getting the dimensions for the matrix dynamically, based
on the the number of elements in a matrix for example. if the number is 12, 
I should get dim= 3X4,  if it is 20, dim=5X4. 
please help me do this.

Thank you
Regards
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/R-matrix-help-tp4633372.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] DF grouping

2012-02-12 Thread karthicklakshman
Hello Members,

I need to group a data.frame in a a specific way, like shown below,

DF raw is like this,

id col1 col2 score
1  A  B   40
2  B  C   55
3  C  D   4000
4  D  E100
5  E   F300

I want the out put as

List
[1]
A B C
[2]
D E
[3]
F
Basically the split should be based on the DF$score > 200, and all the col1
and col2 values should be aggrigated.

Request your kind help,

Regards,
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/DF-grouping-tp4381310p4381310.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] DF grouping

2012-02-12 Thread karthicklakshman
Dear Petr Savicky,

Thank you very much for the solution.
your script really worked for my DF,  and yes as per your guess , its always
---> DF[i, "col2"] == DF[i+1, "col1"]

Regards,
karthick

--
View this message in context: 
http://r.789695.n4.nabble.com/DF-grouping-tp4381310p4381646.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] gslider-gwidgets

2012-05-29 Thread karthicklakshman
Hello R lovers,

For my GUI, I am using gslider of Gwidgets. I need to add the "to=" value
dynamically ie., maximum value from a data frame column(something like
to=max(df[,3])).  But I am getting error message like 

Error in checkPtrType(object, "GtkWidget") : 
  object of class NULL isn't a GtkWidget

Not sure what I am missing here!!!

Regards,
karthick


--
View this message in context: 
http://r.789695.n4.nabble.com/gslider-gwidgets-tp4631746.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.