[R] Extract only certain rows from a table

2008-06-18 Thread naw3
Hi, I have a table where column 1 has ID numbers and column two has data, and I have a vector containing a subset of those ID numbers. How can I create a new table with only the rows from the old table that match the IDs in the vector, like below: Original Table: ID Value 1123 2

[R] reset row numbers when extracting a subset of a table

2008-06-24 Thread naw3
Hi I created a new table by extracting only certain rows of table, but the row numbers in my new table correspond to those from the original table. Is there a way to reset the row numbers in my new table so that they start from one? like below: my table: COL1 COL2 17 v 45 18 b

[R] Error reading a table

2008-06-27 Thread naw3
Hi, I get the following error when I try to read in a CSV file: > Path<-read.table('MetaCycSample2.csv',sep=',', header=FALSE) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 17 did not have 5 elements Some of the rows have more columns than others. Also whe

[R] Problem reading a CSV

2008-06-30 Thread naw3
Hi, I have a CSV file where each row has at least 20 columns and some rows have up to 30 columns of data. When I use the command, Pathways<-read.table('MetaCycSample3.csv',sep=',',header=FALSE,quote='"') anything past the 21st column gets kicked down to a new row. How can I fix this? Thanks, -N

[R] Ignore blank columns when reading a row from a table

2008-07-01 Thread naw3
Hi, I am extracting data from a table where the rows have different column lengths, and empty columns have NA in them. Whenever I extract a row with some empty columns, the resulting vector carries all the NAs. Is there a way to ignore the empty columns? Thanks, -Nina ___

[R] Change name of a specific column of a data frame

2008-07-01 Thread naw3
Hi, Sorry for the simple question. Is there a way to change the name of only one column of an existing data frame? I know colnames allows you to set the name of all the columns, but only one column in the middle of my data frame needs a new name. Thanks, -Nina __

[R] Problem reading from a data frame

2008-07-02 Thread naw3
Hi, I have a data frame with strings that have two letters and four numbers. When I store a whole row as a new vector and try to remove the preceding letters using the gsub command, it returns characters of single numbers that have no relation to the numbers in each string. I also noticed that whe

[R] Help with an error message

2008-07-14 Thread naw3
Hi, I am writing a very long program that deals with multiple large databases which often have missing data cells and other quirks. I've been testing it on small samples of the data so it doesn't take too long, but when I tried it using the real files, it ran for about a minute and then gave me th

[R] Display variables when running a script

2008-07-17 Thread naw3
Hi, I know this must be a stupid question, and sorry in advance for being such a noob. But, is there way to get R to display only certain variables when running a script. I know if you want to see the value of a variable when using the interface, you just type it in and hit enter, but is there a c

[R] Decoding subscripts/superscripts from CSVs

2008-07-22 Thread naw3
Hi, I have a CSV file with various biological reactions. Subscripts, superscripts, and italics are encoded in carats, and I was wondering if R can actually recognize those and print actual superscripts, etc. Here's an example: S-adenosyl-L-methionine + rRNA = S-adenosyl-L-homocysteine + rRNA c

[R] Help with which()

2008-07-24 Thread naw3
Hi, I'm using which to find the position of a value in my data table, and it is returning the correct position and the position of another number that differs by an extra decimal place. For example, when I do: where1<-which(Operons==3573.1,arr.ind=TRUE) it returns the position of that number and

[R] Insert rows into a pre-existing data frame

2008-07-25 Thread naw3
Hi, I'm sorry if this is a simple question. How do you insert a blank row into a data frame? I basically need to do this: old table: new table: C1 C2 C3 C1 C2 C3 1 32 34 1 32 34 2 52 23 54 2 52 23 _

[R] Converting to subscripts and superscripts

2008-07-30 Thread naw3
Hi, I am reading in a CSV file of chemical reactions where the subscripts and superscripts are encoded in angle brackets, like below: 2 H+ + 2 O2- Is there a way to convert these to actual sub/superscripts and save them in another excel file? I greatly appreciate the help! Thanks, -Nina PS. I

[R] Really simple question

2008-06-10 Thread naw3
Hi, I don't have too much programming experience - sorry in advance if this question is very basic, and thanks for the help. I have a vector of numbers and another vector of a subset of those numbers. How can I create a third vector with all the numbers in the original list that aren't in the giv

[R] Search entire table for a value

2008-06-11 Thread naw3
Hi, I have a table of numbers without any repeats. Is there a function that will search the entire table for a specified value and return the indices if it is found? Also, some rows may have columns without values. Thank you so much, -Nina __ R-help@r-