Displaying 20 results from an estimated 5000 matches similar to: "Format integer"
2008 Jun 24
4
Find max of a row in data frame (like Excel)
Hi,
Here's the data we have:
> rs[1:5,]
probe_id f1 f2 f3 f4 M A f
1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59
2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59
3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59
4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59
5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59
I want rs$f be the max of f1, f2, f3,
2008 May 06
2
Concatenate a vector into a string, only using distinct component
I'm trying to use combine c('a','b','c','a','c') into 'a, b, c', the order
does not matter.
paste(c('a','b','c','a','c'), collapse=', ') yields 'a, b, c, a, c'.
Any idea?
--
Regards,
Anh Tran
[[alternative HTML version deleted]]
2008 Jun 19
2
Draw curve for histogram
Hi all,
What parameter should I feed to the hist function to draw a line, not bar
graph for a histogram? Smoothed line would be great too.
I've looked at curve() for normal distribution but it's not what I need. I
need some curve on top of the histogram (fit to the actual data). Just as a
way to illustrate, rather than bargraph.
Thanks
--
Regards,
Anh Tran
UCLA NeuroOncology Lab
2008 May 06
2
Print table data on to a plot
Hi,
Is there away to print a short table out along side with a plot?
I'm thinking about doing a
par(mfrow = c(1,2))
Then, the plot is on one side, summary result on the other.
Is there any quick way to print out a data.frame in table format? Thanks
--
Regards,
Anh Tran
[[alternative HTML version deleted]]
2008 Aug 02
3
convert for loop into apply()
Hi all,I know this topic has came up multiple times, but I've never fully
understand the apply() function.
Anyway, I'm here asking for your help again to convert this loop to apply().
I have 2 data frames with the following information: a1 is the fragment that
is need to be covered, a2 is the probes that cover the specific fragment.
I need to count the number of probes cover every given
2008 Jun 21
2
Scatter plot transparency
Hi all,
I'm putting a few plots together and wondering what format would be best to
export a few scatter plots to Illustrator to make a figure. I'm thinking
about overlaying some plot in Illustrator, so the export file type has to be
transparent for Illustrator (version 10).
I tried PNG and TIFF, but it does not seems to have transparency that is
recognized by Illustrator (or Photoshop for
2008 May 09
1
Rescaling a column in a matrix based on a certain rows
Hi,
Let say I have this matrix:
> mat<-matrix(cbind(rnorm(20),rnorm(20)), ncol = 2)
And I want to rescale values of column [,1] and [,2] using values from row 1
to 5, such that the values of row 1:5 should be rescale to the same
amplitude (kinda like take the z-score of population from row 1:5). column 1
and 2 are two different samples need to be compared.
I hope I made myself clear
2012 Feb 23
3
I'm sure I'm missing something with formatC() or sprintf()
I have a four-digit string I want to convert to five digits. Take the
following frame:
zip
2108
60321
60321
22030
91910
I need row 1 to read '02108'. This forum directed me to formatC previously
(thanks!) That usually works but, for some reason, it's not in this
instance. Neither of the syntaxes below change '2108' to '02108.' The values
in cand_receipts[,1] are of
2008 Aug 02
2
Multiple R console for OS X?
Hi gang,
I always open more than 1 R console in Windows. I can't figure out a way to
do this with OS X yet. I need that to utilize the duo core on my desktop.
How would I do that?
--
Regards,
Anh Tran
[[alternative HTML version deleted]]
2008 May 18
3
Opening more than 1 R console in Windows
Hi all,
I recently found out that R does not utilize fully the Duo Core capability
when you only run one instance of R.
I did some number crunching today and it seems that if I only open 1 R
console, it uses 50% of my CPU (either 50-50 or 100-0 on 2 cores).
Then, I open the second instance and divide the work into two parts, and run
them parallelly, they seems to utilize 100% of my CPU.
So, my
2010 Feb 24
2
sprintf + integer(0) problem
Hello all,
I am stuck with R v2.8.0 under Linux for the time being and I am
running into a small problem that doesn't exist under 2.9.x and 2.10.x
with sprintf.
If I have the following code segment to help me determine the column
number for a specific column header/label:
nn = names(Dataset)
s = "Group"
c = which(nn==s)
cat(sprintf('found %s in col %d\n', s, c))
2011 Apr 04
3
add zero in front of numbers
Dear R users,
I need to add 0 in front of a series of numbers, e.g. 1->001, 19->019,
Is there a fast way of doing that?
Many thanks
yan
[[alternative HTML version deleted]]
2009 Aug 28
6
Google's R Style Guide
Perhaps most of you have already seen this?
http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
Comments/Critiques?
Thanks,
Esmail
ps: Reminds me of PEP 8 for Python
http://www.python.org/dev/peps/pep-0008/
Maybe not that surprising since Python is also one of the main languages
used by Google.
2005 Nov 25
2
Ordering problem
I have an ordering and factor problem to which there must be a simple
solution! The version is R 2.0.1 (2004-11-15) on A Linux platform.
A data frame H is read in from a .csv file using read.csv with as.is=TRUE.
Another data frame HN is constructed from data and I want to compare two
columns both named ss of the (sorted) data frames that are the same
length.
The problem is that HN$ss is
2008 Oct 21
1
Paddding an integer with zeros
Hello List,
Can anybody point me to a number-to-string formatting function?
I need to convert, say, 12 to 00012.
I tried format() but its too stubborn: it seems to only pad with spaces.
Thank you,
Your culpritNr1
--
View this message in context: http://www.nabble.com/Paddding-an-integer-with-zeros-tp20095300p20095300.html
Sent from the R help mailing list archive at Nabble.com.
2009 Apr 19
3
flip certain bits in vector
I have a string of binary values, and I would like to flip certain
bits in a set of positions.
Let's say the
vector p contains position [1, 3, 5, 7]
vector b contains bits [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
result r should be [0, 1, 0, 0, 0, 0, 0, 0, 1, 0]
in pseudo code this would be something like
---
r = c()
for (i in 1:10)
if (i in p)
r = c(r, flip[i])
r
----
2008 Jun 12
3
Adding new columns to (output) data - e.g., read 5 cols write 8
Hello, I have the following task I'd like to accomplish:
A file contains 5 columns of data (several hundred rows), let's call
them a, b, c, d and e (ie these are their column headers)
I also have a set of definitions, e.g.,
f = a + b
g = a * 3
h = c + d
etc.
I would like to write out a new .rda file that contains columns
a b c d e f g h etc.
I.e. , the original data plus new columns
2008 May 09
2
which.max2()
Hello,
which.max() only returns one index value, the one for the
maximum value. If I want the two index values for the two
largest values, is this a decent solution, or is there a
nicer/better R'ish way?
max2 <-function(v)
{
m=which.max(v)
v[m] = -v[m]
m2=which.max(v)
result=c(m, m2)
result
}
Seems to work ok.
Thanks,
Esmail
2009 Apr 26
4
comparing matrices
I'm trying to compare two matrices made up of bits.
doing a simple comparison of
matA == matB
yields this sort of output.
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] FALSE TRUE FALSE TRUE TRUE FALSE
[2,] TRUE TRUE TRUE TRUE TRUE TRUE
[3,] FALSE TRUE FALSE FALSE FALSE TRUE
[4,] FALSE TRUE TRUE FALSE FALSE FALSE
[5,] TRUE TRUE TRUE TRUE FALSE FALSE
[6,] TRUE TRUE
2008 May 07
1
Automatically generating new column names (and columns)
Once again I need to tap into the collective knowledge here.
Let's say I have the following columns and data below
Y X1 X2 X3 X4
I would like to generate additional new columns and column names
(ie the data would be squared - and I'd like the column names to
reflect this) like:
Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2
I believe I can compute the values correctly with the code below, but
I