Displaying 20 results from an estimated 9000 matches similar to: "extracting elements by using logical values"
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 Feb 08
6
writing a function
Dear lists,
I'm in my process of learning of writing a function. I tried to write a simple functions of a matrix and a vector. Here are the codes:
mm<-function(m,n){ #matrix function
w<-matrix(nrow=m, ncol=n)
for(i in 1:m){
for(j in 1:n){
w[i,j]=i+j
}
}
return(w[i,j])
}
v<-function(n){ #function of a vector
y=vector(length=n)
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 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 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 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 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 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 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 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 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 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
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 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
2004 Jul 29
3
Help w/ matrix calc
Dear All,
Help is needed! I have a matrix with frequencies of fish larvae per length
class (var. sl) and age-group (var. median.no) obtained with
>k<-table(cut(sl,(5:22)),median.no)
>k[2:5,1:5] #to ilustrate k
4 5 6 7
(6,7] 3 1 0 0
(7,8] 3 0 1 0
(8,9] 3 4 3 5
(9,10] 3 15 7 13
from this matrix I would like to obtain the mean age per length class i.e.
2003 Oct 11
2
Problem in 'methods' package (PR#4525)
Full_Name: Fernando Henrique Ferraz Pereira da Rosa
Version: 1.8.0
OS: Linux 2.4.21
Submission from: (NULL) (200.206.211.169)
After installing R 1.8.0, the R DBI interface stopped working. I tracked it
down as a problem in the 'methods' package, that comes in the default
installation.
Somehow the function '.valueClassTest' which is defined on package
'methods',