Displaying 20 results from an estimated 20000 matches similar to: "Extract only certain rows from a table"
2008 Jul 01
3
Ignore blank columns when reading a row from a table
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
2008 Jul 01
3
Change name of a specific column of a data frame
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
2008 Jun 30
4
Problem reading a CSV
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,
-Nina
2008 Jul 17
3
Display variables when running a script
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 command that I can
use in a script file that will show the value at a certain point?
Thanks,
-Nina
2008 Jul 02
2
Problem reading from a data frame
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 when I view the new vector
before using gsub, it includes the original headers from the data frame. For
2008 Jun 11
1
Search entire table for a value
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
2008 Jul 22
2
Decoding subscripts/superscripts from CSVs
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:
<i>S</i>-adenosyl-L-methionine + rRNA = <i>S</i>-adenosyl-L-homocysteine +
rRNA containing
2008 Jul 24
2
Help with which()
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 of 3573.15.
Is it possible to get the function to only return a position if the number
2008 Jun 27
1
Error reading a table
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 when I try the read.csv
command, the very last column, which only has one cell
2008 Jun 10
1
Really simple question
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 given subset. Like this:
List1 subset --> result
1 1 2
2 3
3 4
2008 Jul 14
1
Help with an error message
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 this error message:
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow
2008 Jul 30
1
Converting to subscripts and superscripts
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<SUP>+</SUP> + 2 O<SUB>2</SUB><SUP>-</SUP>
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 asked this before, but I
2008 Jul 25
1
Insert rows into a pre-existing data frame
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
2001 Oct 30
2
extracting object names as strings
Hi,
I'm looking for a function which returns the name of the argument
object as a string:
>vect <- 1:3
>function(vect)
"vect"
I've looked at 'name', 'names', 'objects', none seem to do exactly what I
want. ls/objects comes close, but I can't figure out how to force it to
give me only one object name.
daver
2007 Aug 10
2
need help to manipulate function and time interval
Hi R-users,
I have to define a noise level function L and its energy in the various
moment of the day by:
if time is between 18:00:00 and 23:59:59 then L[j] <- L[j]+5 and W <-
10^((L+5)/10)
if time is between 22:00:00 and 05:59:59 ==> L <- L+10 and W <-
10^((L+10)/10)
else
L=L and W = W
Could someone help me to realize this function please? You will find my
following
2012 Feb 08
1
How indices calculated in package "boot"
Hi,there,
I am using R package "boot" to bootstrap. I have one question here: does
anybody possibly know how the boot package generates the "indices" which is
used in the statistic function?
I thought "indices = sample(data, replace=TRUE)", but when I replaced
"indices" with this command and used "boot", I got different results.
Specifically,
2018 May 03
4
adding overall constraint in optim()
Hi ?
This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ?
The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim.
Mo.vect <-
2006 Sep 04
3
Subsetting vectors based on condition
Hello,
I have a question regarding subsetting of vectors. Here's an example of
what I'm trying to do:
vect.1 <- c(76,195, 290, 380)
vect.2 <- c(63, 95, 133, 170, 215, 253, 285, 299, 325, 375)
I would like to subset vect.2 so that it has the same length as vect.1,
and its numbers are the first corresponging higher value compared to
vect.1.
The output should be:
final.output =
2008 Jun 09
1
Cross-validation in R
Folks; I am having a problem with the cv.glm and would appreciate someone
shedding some light here. It seems obvious but I cannot get it. I did read
the manual, but I could not get more insight. This is a database containing
3363 records and I am trying a cross-validation to understand the process.
When using the cv.glm, code below, I get mean of perr1 of 0.2336 and SD of
0.000139. When using a
2012 Dec 11
1
Rprof causing R to crash
I'm trying to use Rprof() to identify bottlenecks and speed up a particullary
slow section of code which reads in a portion of a tif file and compares
each of the values to values of predictors used for model fitting. I've
written up an example that anyone can run. Generally temp would be a
section of a tif read into a data.frame and used later for other processing.
The first portion