[R] Function question

2009-09-25 Thread njhuang86

Hi. I was wondering how I can write a function that generates the outcome
values for a user specified equation. For example, function(x^2, 4) will
return back 16 and function(x^3 - 10, 2) will give back -2...

I've been playing around with various lines of code but somehow, I just
cannot get R to recognize the equation that I pass to it is just a random
variable and doesn't need to be initialized...
-- 
View this message in context: 
http://www.nabble.com/Function-question-tp25619434p25619434.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] Plotting two qqnorm plots:

2009-09-08 Thread njhuang86

Hi all,

Does anyone know how to plot overlapping qqnorm plots on the same window?
Suppose I have data in the vector x and y:

qqnorm(x)
lines(qqnorm(y))

I though these two lines will do the job... However, lines doesn't seem to
work. Anyways, thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/Plotting-two-qqnorm-plots%3A-tp25352893p25352893.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] Re moving the numbers of the X/Y axis

2009-08-30 Thread njhuang86

Hi all,

Suppose I have some data that I plot using the histogram command - ie.
hist(x)
Is there an option that will allow me to remove the numbers that appear
along the X and Y axis as I'm just interested in the overall distribution of
the data and not the actual values? Anyways, any help is greatly
appreciated!


-- 
View this message in context: 
http://www.nabble.com/Removing-the-numbers-of-the-X-Y-axis-tp25214292p25214292.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] Sequence generation

2009-08-29 Thread njhuang86

Hey guys,

I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2, 3, 1,
2, 3... with the '1, 2, 3' repeated over 10 times.

Also, is there a simple method to generate 1, 1, 1, 2, 2, 2, 3, 3, 3?

Anyways, any help with be greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Sequence-generation-tp25205593p25205593.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] Loess question

2009-07-30 Thread njhuang86

Hi, suppose I have a vector of values in 'A'. Suppose I use:
scatter.smooth(A) to add in a smooth curve. Is there a way to obtain the
maximum value of the smoothed curve? Anyways, any help will be greatly
appreciated!
-- 
View this message in context: 
http://www.nabble.com/Loess-question-tp24738574p24738574.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] Plotting two overlapping curves

2009-07-30 Thread njhuang86

Hi. Sorry if this question might have already been asked... I'm trying to
plot two curves on the same X-Y coordinate. The par(mfrow) command allows me
to plot the two curves on the same window however on different coordinate
systems. Is there a way to force the two curves into the same coordinate
system? Anyways, thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/Plotting-two-overlapping-curves-tp24740989p24740989.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] find duplicates... need help!

2009-07-07 Thread njhuang86

Hi all,
Suppose I have x = c('a', 't', 'c', 'y', 'g')
and also y = c('a', 'a', 'g', 's')

If I do something like x%in%y, I obtain a vector like this: [TRUE, FALSE,
FALSE, FALSE, TRUE] which I can easily turn into this: [1, 0, 0, 0, 1].
I was wondering is there anyway for me to get a vector back in return in the
form of: [2, 0, 0, 0, 1]? Essentially, the 2 will tell me that in the first
position of vector 'x', there were two matches found with vector y.

Thanks a ton in advance!
-- 
View this message in context: 
http://www.nabble.com/find-duplicates...-need-help%21-tp24379828p24379828.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] Vector of string

2009-06-23 Thread njhuang86

Hi all. Suppose I have a vector of strings ie: [12384, TYU123123,
AVC3939, hhr1919, TYU0029]

Is there an efficient method that would allow me to return a vector of the
position of strings that start with TYU? So essentially, I would like to
get back in return [2, 5]. Anyways, any help with be greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Vector-of-string-tp24167271p24167271.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] Any method to speed up this problem?

2009-06-18 Thread njhuang86

Hi all,

Suppose I have a vector like this:

[1] STAT1  STAT1  STAT1  STAT1  GAPDH  GAPDH  GAPDH  ACTB  
ACTB  
[10] ACTB   DDR1   RFC2   HSPA6  PAX8   GUCA1A UBE1L  THRA  
PTPN21
[19] CCL5   CYP2E1  STAT1  THRA  PAX8

I would like to produce a vector such that it has the same length as the one
above but it tells me where the duplicates are. So essentially, if I could
represent each gene symbol as a specific number, and have the duplicates be
the same number, that would be ideal. Right now, I'm using the unique
command along with two nested for loops to do the job... But it's really
taking too long... Any suggestions would be greatly appreciated. Thank you!
-- 
View this message in context: 
http://www.nabble.com/Any-method-to-speed-up-this-problem--tp24094164p24094164.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] Question regarding dataframes, matrix, frame, etc...

2009-06-16 Thread njhuang86

Hi all,

As of now, I have a 15x8 matrix (name is asdf). The first seven columns
contain numbers while the last column contains a string. The class of each
column is character. When I use the plot function to display a scatter
plot between any of the two columns, ie. plot(asdf[, 1], asdf[, 2])
everything works fine. However, if I want to use the command pairs to show
all combination of scatter plots between the first seven columns (without
the columns of strings), it gives me a error message telling me that I'm
passing a non-numeric arguement to 'pairs'.

As a result, I changed the original matrix into a dataframe via.
as.data.frame(asdf) so the columns are of the class factor. However, when
I now utilize the pairs command to plot the scatterplots of the first seven
columns, the scatterplots are totally off. I think that the pairs command
changes all the factor columns into numeric columns - and by performing this
class transformation, the values within each column are also physically
changed.

I'm just really lost. Is there a way to utilize the pairs command in my
setting? Or is there a method to change the class of each column without
physically altering the values? Anyways, thanks in advance!!!
-- 
View this message in context: 
http://www.nabble.com/Question-regarding-dataframes%2C-matrix%2C-frame%2C-etc...-tp24056147p24056147.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] Creating this vector, any suggetions?

2009-06-12 Thread njhuang86

Suppose I have the first vector: c(1, 6, 8, 9)

I will like to create a second vector of size 10 composed of 0 and 1's. The
second vector will be composed of four 1's and six 0's. The position of the
1's will be specificed by the first vector. So essentially, I want a second
vector in the form:

c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)

Any help is greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000348.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] need help with strsplit function

2009-06-11 Thread njhuang86

Hi, if I have this string: a.b.c.d and I use this function:
unlist(strsplit(a.b.c.d, \\.)), I get this as my output: a, b, c,
and d. Is there a way to just split on the first period so I obtain only
two pieces like: a and b.c.d? Anyways, thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/need-help-with-strsplit-function-tp23983888p23983888.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.