Displaying 20 results from an estimated 40000 matches similar to: "writing a function"
2008 Feb 07
2
matrix loop
Dear list,
I'm trying to make a loop of a (5x10) matrix and below are my codes. Could anybody help me figure out why my loop is not working. Thanks in advance!!
m<-1:5
n<-1:10
for(i in 1:length(m))
{ for(j in 1:length(n))
{
y[i,j]=sum(i,j)
y<-as.matrix(y[i,j])
}
}
cheers,
Anisah
---------------------------------
[[alternative HTML version
2008 Feb 12
3
reverse vector elements
Dear lists,
I want to write a function of a vector and reverse the order of its elements. Here is my code:
revector<-function(n){
y=vector(length=n)
for(i in n:1){
y[i]=i
}
return(y)
}
i want my output to be like this:
y
[1] 10 9 8 7 6 5 4 3 2 1
Any suggestion?? Thanks!!
Cheers,
Anisah
---------------------------------
2008 Jun 12
3
p-value
Dear R User,
say I have this sample of data ( attach with). What i'm going to do is to test whether this data is uniformly distributed or not by finding the p-value. I've tried using the punif command but it gave me the value of 1 of all the data. Any suggestion on R command to find the p-value??Thanks in advance!!
Cheers,
Anisah
-------------- next part
2008 Feb 17
1
extracting elements by using logical values
dear lists,
My question is quite simple but i'm a new user in R and it's seem tough to me. How am i going to recall back my values??ok..it could be easy if i ilustrate my problem with the simple example. say that,
x
[1] 1 2
y
[1] 2 3
and my logical output from my function are (Below is my function):
overlapped(x,y)
[1] TRUE
[1] TRUE
suppose i
2008 Feb 01
2
overlapping intervals
hi!!
Below I have 4 columns vector of c and d which are unequal in length.These c and d have 2 columns each where these 2 columns represent an interval values. How am I going to get an overlapping over these interval values?? Please help me sort this problem!! Thanks in advance..
c d
17130612 17587118 17712302 18100404
17712302
2008 Feb 05
1
Vector loop
hi,
I'm in my learning process of doing a programming with "for" loop. How to make a loop of a vector of length 10 where elements are 1,2,3,4,5,6,7,8,9,10. Any suggestion needed!! Many thanks.
Cheers,
Anisah
---------------------------------
[[alternative HTML version deleted]]
2008 Feb 15
1
help on loop function
Dear lists,
Anysuggestion on how to write a loop function which has nx2 matrix as an input, where each of the row represents an interval. the function should return a mx2 matrix containing the no matched interval of x?? i've tried my own function but it's only applies for 2x2 matrix.
Here is my code:
overlap<-function(x,y){
m=length(x)
n=length(y)
for(i in 1:m){
2008 Jan 22
1
stripchart
hi,
I want to plot a dotplot graph but unfortunately R does not have it any more. It suggest to use either the stripchart or the dotchart and i prefer to play around with the stripchart graph. Sadly, the result is not like i want where I'm actually wants the plots/points were scattered around the x-axis. Plus, from the results shows that and the x-axis gave a very large scale, i.e
2008 Jan 08
3
splitting the column
Hi,
I have a matrix data with 21 rows and 6 columns. Below and attach with is my matrix data. My problem is to split the column into 3 subcolumns (except for column 3 and 4) . I want my new matrix data to have 14 columns and 21 rows. Kindly help is highly appreciated.
[,1] [,2] [,3] [,4] [,5] [,6]
2008 Feb 08
1
remove the missing value,NA
I have two sets of interval data.Below are my two dataset. In these dataset, there is a missing values in each of the data. I want to find the non-overlapping interval values. Here is my code:
mysetdiff=function(x,y){
m=length(x)
n=length(y)
bx = logical(m)
by = logical(n)
for(i in 1:m){
for(j in 1:n){
if(x[i]<=y[j]){
bx[i] = T
by[j] = T
}
2008 Jun 27
1
finding the suitable distribution
Dear R-users,
Attach with is my data..what i want to do is finding a suitable distribution for my data..I want to run a few test like the poisson and the exponential distribution. Please help me on how to find the p-value for poisson as well as the exponential distribution without knowing the parameter. Is it possible?? Thanks in advance.
love,
Anisah
-------------- next
2008 May 24
1
combine elements of list into a vector
Dear R,
Can anybody help me on how to combine all the elements in a list into a single vector?? I've tried using unlist command but it gave me wrong output. Below is the example of the vector output that i want and attach with is my list of data. Any suggestion?? Many Thanks
breakp.start
6978022
10249966
10955201
11045352
11814604
13847633
2008 Feb 13
4
writing a simple function
Dear lists,
any suggestion on how to write a function to return a TRUE if interval [a,b] overlaps the interval [c,d]. I've tried it but an error occur saying that 'could not find function v ; in addition warning message occur'. Below is my codes.Please help me sort this problem as i'm in process of learning of writing a function. Many thanks
overlap<-function(m,n){
2008 Feb 09
1
error in the function
Dear lists,
i want to find the non-overlapping interval values with this code:
mysetdiff=function(x,y){
m=length(x)
n=length(y)
bx = logical(m)
by = logical(n)
for(i in 1:m){
for(j in 1:n){
if(x[i]<=y[j+1]){
bx[i] = T
by[j] = T
NA = NA
}
}
}
sx = x[!bx]
sy = y[!by]
s=c(sx,sy)
return(s)
}
Below is my
2008 Jan 29
1
remove similar values
hello!!
say that i have the values of x1 and x2. my x1 has longer length than x2. how am i going to remove the similar values of x1 and x2. Any suggestion?? Thanks in advance!!
Cheers,
Anisah
e f
[1,] 17358865 17906353
[2,] 17966995 21295547
[3,] 21306539 27880531
[4,] 27880531 34118702
[5,] 34166504 35395488
[6,] 36111044 36132622
[7,]
2008 Jan 24
1
adjustment on the x-axis scale width
Hi,
I have sucessfully plotted the graph by using the following command:
ec<-rep(0,length(e))
fc<-rep(0,length(f))
plot(e,ec,type="p",col=1,pch=19)
points(f,fc,col=2,pch=20)
legend(1.0e+08,1.0,c("dog", "human"),text.col="green4",pch=c(19,20),col=c(1,2))
Below are the values for e and f...the questions is how am i going to adjust
2007 Dec 31
2
How to import ENSEMBL text data using R
Dear all,
I have a data which is in text file and i would like to import the data to R. From the manual, i?ve found the read.table command function is the most appropriate but when i wrote the command an error had occur. It say ?Error in read.table"C:/Users/user/Documents/cfa-1.txt", header = T, sep = "\t",skip=10) :more columns than column names?. Please help me with this as
2008 May 23
3
extracting columns from a list
Dear all,
i have 2 lists of data with each of the list contain 14 columns. How am i going to extract column 12 and 13 from each of the list ?? and can i combine my extracted columns to form a single list. Attach with are my data. Your coorperation is highly appreciated. Many thanks
Regards,
Anisah
-------------- next part --------------
An embedded and charset-unspecified
2011 May 25
2
Fwd: transpose ?
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20110525/4926c5ee/attachment.pl>
2017 Jul 05
4
expand gridded matrix to higher resolution
Hi all,
(if me email goes out as html, than my email client don't do as told, and I apologies already.)
We need to downscale climate data and therefore first need to expand the climate from 0.5deg to the higher resolution 10min, before we can add high resolution deviations. We basically need to have the original data at each gridcell replicated into 3x3 gridcells.
A simple for loop can do