Sponsored Content
Full Discussion: Grep part of dataframe in R?
Top Forums Programming Grep part of dataframe in R? Post 302771843 by yifangt on Thursday 21st of February 2013 05:19:56 PM
Old 02-21-2013
Found the answer!

Got answer from stackoverflow!
Code:
>dfrm
A 1 3 4 
B 4 5 6
C 7 8 9
D 1 3 4
E 1 3 3
F 2 4 5

## and my list of the interest is stored in a file
Code:
subset <-read.table("infile", header=F)
>subset
1 A
2 C
3 E
4 F
> dfrm[rownames(dfrm) %in% subset[,1], ]
A 1 3 4 
C 7 8 9
E 1 3 3
F 2 4 5

subset[, 1] does the trick, subset is a dataframe too, that I should have been aware of!
R is also very powerful.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep within certain part of file

Hi, Is it possible to grep only on a certain part of a file? Say I have file in.txt which contains below: 11/16 13:07:19.5436 --- ERROR 123 detected. 11/16 13:08:19.5436 --- Generating a <reading> event 11/16 13:08:19.7784 ---- Sending a <writing> event 11/16 14:08:37.4516 ---... (2 Replies)
Discussion started by: Orbix
2 Replies

2. Shell Programming and Scripting

grep a part of a line

Hi, In a file FILE, there is a line like this one MOLECULE C2 H2 I want to extract "C2 H2". I can do it in two step in a script : VARIABLE="`grep MOLECULE FILE`" # Assign "MOLECULE C2 H2" VARIABLE=`echo ${VARIABLE/"MOLECULE "}` # Remove "MOLECULE ". Then, $echo $VARIABLE gives C2... (6 Replies)
Discussion started by: tipi
6 Replies

3. Shell Programming and Scripting

Grep part of the line

How do I print only the values of the variables from set or env. For example I have the lines USER=USER XYZ='text' SHELL=/bin/bash How do I print only the part after or starting from = Let's say I have those lines in a list X If I run Y = echo $X | grep -o "=*$" Y won't contain... (3 Replies)
Discussion started by: Transsive
3 Replies

4. Shell Programming and Scripting

grep part of file name

Hi, I have a problem to use grep in my script . If I want to grep the file for example : PTWO9089.txt The code below works . grep ^PONE But, I dont know on how to grep the file like this 9066PTWO.txt I'll try to use this code : grep PTWO^ ,but it doesn't work. For your info, the... (4 Replies)
Discussion started by: badbunny9316
4 Replies

5. UNIX for Dummies Questions & Answers

How to use grep to get only part of a line...

Hello All. I have an output file which contains the phrase "Total DFT Energy =" and then a number. This occurs many times in the output file, and what I want is to pipe the numbers (which are all different) to a file so I can plot them. How do I grep "Total DFT Energy =" and then get the numbers... (3 Replies)
Discussion started by: EinsteinMcfly
3 Replies

6. Shell Programming and Scripting

How to get a part of the line(need help in using grep)

Hi, Suppose, DBconnection=jdbc: oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=YYYY))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=project_db1))) This is a part of a file <filename> . I Need to get the value of SERVICE_NAME from this line… The... (4 Replies)
Discussion started by: Dpu
4 Replies

7. UNIX for Dummies Questions & Answers

can I grep a part of one line ?

<exp code="12556a" message="ok, fine4" displayMessage="jksdfj ksd" \> <exp code="123456a" message="ok, 2fine" displayMessage="jksdfj ksd" \> <exp code="12dfgda" message="1ok, fine" displayMessage="jksdfj ksd" \> now I want to cut code attribute and message attribute, such as ... (2 Replies)
Discussion started by: vincent_W
2 Replies

8. Ubuntu

Merging strings that have identical rownames in a dataframe

Hi I have a data frame with repeated names in column 1, and different descriptors in column 2. I want to merge/cat strings that have same entry in column 1 into one row with any separator. Example for input: Cvel_1 KOG0155 Cvel_1 KOG0306 Cvel_1 KOG3259 Cvel_1 ... (4 Replies)
Discussion started by: Alyaa
4 Replies

9. Shell Programming and Scripting

How to grep only some part of character?

Hi, I have log : # cat log $ cat 4 2014092014 2014102014 2014112023 2014123014 2014010100 2014010101 2014010102 2014010103 2014010104 2014020123 2014020115 2014020116 (3 Replies)
Discussion started by: justbow
3 Replies

10. UNIX for Beginners Questions & Answers

Remove duplicates in a dataframe (table) keeping all the different cells of just one of the columns

Hello all, I need to filter a dataframe composed of several columns of data to remove the duplicates according to one of the columns. I did it with pandas. In the main time, I need that the last column that contains all different data ( not redundant) is conserved in the output like this: A ... (5 Replies)
Discussion started by: pedro88
5 Replies
stl_ctrl(4)						     Kernel Interfaces Manual						       stl_ctrl(4)

NAME
stl_ctrl - Software subset control files DESCRIPTION
Each software subset that is distributed for the setld command has an associated control file. This control file is created by the kits(1) utility. The control file's name consists of the subset name with the string .ctrl for a suffix. The control file contains attribute information for the subset. Once the subset has been installed on a system, the control file is placed in the usr/.smdb. directory. The attribute definitions in the file are stored one per line as attribute name/value pairs separated by equals signs (=). The attributes are: NAME The name (text description) of the product of which this subset is a component, as given by the NAME attribute defined in the prod- uct attributes section of the key file. DESC The text description of the subset, as given in the subset descriptor for this subset in the key file. ROOTSIZE The size in bytes that are used on the root file system. USRSIZE The size in bytes that are used on the usr file system. VARSIZE The size in bytes that are used on the ar file system. MTLOC Two integers separated by a colon (:). These integers are used by the setld utility to find the subset on tape media. The first number specifies the volume in the product tape set; the second is the location within that volume. The values established for this attribute by the kits utility are placeholders. The actual values are generated as the subset is being written to tape by the gen- tapes command. DEPS The dependency list for this subset. FLAGS The value specified by the flags field of this subset's record in the key file. EXAMPLES
The following example shows the contents of OATDCB100.ctrl, the control file for a hypothetical subset: NAME='Orpheus Authoring Tools OAT- DCB100' DESC='Document Building Tools' ROOTSIZE=12352 USRSIZE=43941 VARSIZE=8704 NVOLS=1:2 MTLOC=1:1 DEPS="." FLAGS=0 RELATED INFORMATION
gendisk(1), gentapes(1), kits(1), stl_key(4), setld(8) Guide to Preparing Product Kits delim off stl_ctrl(4)
All times are GMT -4. The time now is 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy