Hello,
### I created two classes A and B. A is the superclass of B.
setClass(A, representation(s1=numeric),prototype=prototype(s1=8))
setClass(B,contains=A,representation(s2=character),prototype=list(s2=hi))
myA=new(A)
myB=new(B)
I created functions for A and B
f1=function(x,...)
hi,
I have a simple problem.
how can I test whether a variable is NULL?
a = NULL
if (a == NULL){
...
}
it seems not work
thanks
YU
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hello,
I have a simple question: I want to list numbers 1:k, but if k 1, I hope
nothing listed.
how should we do?
k=2
for (i in 1:k) print(i)
[1] 1 # -correct
[1] 2
k=0
for (i in 1:k) print(i)
[1] 1 # wrong
[1] 0
thanks
jian
[[alternative HTML version
hi,
can anyone tell me how to merge a vector and a matrix?
v=c(1,4,2)
names(v)=c(e,r,t)
m=matrix(c(r,t,r,s,e,5,6,7,8,9),nr=5)
colnames(m)=c(c1,c2)
I want to do like
merge(v, m, by.x=names,by.y=c1)
I got error
Error in fix.by(by.x, x) : 'by' must specify valid column(s)
thanks
jian
Hello,
I have a data.frame:
name col1 col2 col3 col4
AA 23 54 0.999 0.78
BB 123 5 1 0.99
AA 203 98 0.79 0.99
I want to get mean value data.frame in terms of name:
name col1 col2 col3 col4
AA 113. 76. 0.8945 0.8850
BB
?
--- On Thu, 29/4/10, Tengfei Yin yinteng...@gmail.com wrote:
From: Tengfei Yin yinteng...@gmail.com
Subject: Re: [R] by funtion
To: Petr PIKAL petr.pi...@precheza.cz
Cc: Yuan Jian jayuan2...@yahoo.com, r-help@r-project.org
Received: Thursday, 29 April, 2010, 6:44 AM
Hi,
Thanks, actually I
Hi there,
I checked google for aov. usually one uses summary to see whether the p-value
is small.
but I want to put aov in my script. how can I get the p-value, (0.1115, 0.6665,
0.6665 in the following example)?
thanks
YU
Hi R-experts,
I try to find a way to transfer a matrix to a data.frame that is used as input
of aov.
can you give me advice for that?
mdat - matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE, dimnames =
list(c(row1, row2), c(Col1, Col2, Col3)))
mdat
Col1 Col2 Col3
row1 1 2
Hi there,
how can I test every element in a vector whether appears in another vector?
such as
a-c(aa, bb, ff, cc)
b -c(oo,jj,bb,cc)
somefunction(a,b) gives [False, True, False, True]
thanks
yuan jian
[[alternative HTML version deleted
3 56
kk 8 9
the result is expected as
col1.x col2.x col1.y col2.y
kk 6 8 9
kk 3 8 9
Yuan Jian
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https
Hello,
I have a dataframe:
dd - data.frame(b = c(chr2, chr1, chr15, chr13),
x = c(A, D, A, C), y = c(8, 3, 9, 9),
z = c(1, 1, 1, 2))
dd
b x y z
1 chr2 A 8 1
2 chr1 D 3 1
3 chr15 A 9 1
4 chr13 C 9 2
Now I want to sort them according column b, but only its number is
jorgeivanve...@gmail.com wrote:
From: Jorge Ivan Velez jorgeivanve...@gmail.com
Subject: Re: [R] sort a data.frame
To: Yuan Jian jayuan2...@yahoo.com
Cc: r-help@r-project.org
Received: Thursday, 20 May, 2010, 1:31 PM
Hi Yuan,
Try
dd[order(as.numeric(gsub([^0-9], , dd$b))), ]
HTH,Jorge
On Thu, May 20
Hi,
if I know the colnames x and y in the following example, I can easily to do lm.
tmp - data.frame(x=c(1,1.2),y=c(1,2))
lm(y ~ x, data=tmp)
when the colnames are variable, what should I do? for example
colnames(tmp)[1] - paste(aa,1,sep=_)
lm(y ~ paste(aa,1,sep=_), data = tmp)
it gives me
Hello R experts,
can you tell me a simple way to convert a charactor matrix to numeric matrix?
if I use as.numeric, the matrix is converted to a vector.
a-cbind(c(23,54,65),c(1,2,3))
a
[,1] [,2]
[1,] 23 1
[2,] 54 2
[3,] 65 3
as.numeric(a)
[1] 23 54 65 1 2 3
thanks
Jian
Hi R experts.
how can I average two sets of columns?
dd - data.frame(b = c(chr2, chr1, chrY, chr13, chrX),
w=11:15, x = 1:5, y = c(8, 3, 9, 9,7),
z = c(1, 1, 1, 2, 8))
expected result for mean(w,x) and mean(y,z) is
1 chr2 6 4.5
2 chr1 7 2
3 chrY 8 5
4 chr13 9 5.5
5 chrX
Hello,
I could not find a clear solution for the follow question. please allow me
to ask. thanks
mynames=cbind(c('a','b'),c(11,22))
lst=list(a=c(1,2), b=5)
now I try to combine mynames and lst:
a 1 11
a 2 11
b 5 22
thanks
jian
[[alternative HTML version
Hi,
it seems a simple problem, but I can not find a clear way.
I have a list:
lst=list(m=c('a','b','c'),n=c('c','a'),l=c('a','bc'))
lst
$m
[1] a b c
$n
[1] c a
$l
[1] a bc
how can I get list elements that include a given subset? for example, for given
subset {'a','c'}, the answer should be
hi,
when I used cbind to combine columns, some contents of columns has been
replaced by
number. in the script below, column should be aaa,bbb,ccc but I was given 1,2,3.
but when I change the column to vector, it gave me correct contents. can you
please
tell me why?
d-read.table(aaa.txt)
d
PROTECTED]
Subject: Re: [R] cbind in data.frame
To: r-help@r-project.org
Date: Monday, August 25, 2008, 6:09 AM
Le Sun, Aug 24, 2008 at 10:56:43PM -0700, Yuan Jian a écrit :
hi,
when I used cbind to combine columns, some contents of columns has been
replaced by
number. in the script below, column
Hi,
I try to add items to a vector, but when the it has existed, the item should be
skipped.
does anyone know how to do it a simple way?
Yu
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hi,
when I pick out one element from a matrix, the attribute name is kept, but when
more than one elements are extracted, the attribute name lost;
a-matrix(c(1,2,3,11,12,13,45,56,76),ncol=3,dimnames=list(c(),c(c1,c2,c3)))
k-a[a[,c3]50,c3]
kk-a[a[,c3]60,c3]
attributes(k)
NULL
attributes(kk)
Hi,
how to remove levels that have less than a specific number such as 2. i.e..
f-as.factor(c(a,b,a))
f
[1] a b a
Levels: a b
I want to remove level b because level b has less than 2.
f
[1] a a
Levels: a
[[alternative HTML version deleted]]
Hello,
is there a simple way to give all combinations for a given vector:
v-c(a,b,c)
combination(v,v) becomes
aa,ab,ac,bb,bc,cc'
combination(v,v,v) becomes
aaa,aab,aac,abb,..
[[alternative HTML version deleted]]
__
PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all combinations for a given vector:
v-c(a,b,c
PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all combinations for a given vector:
v-c(a,b,c
PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all combinations for a given vector:
v-c(a,b,c
--- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all
--- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all
--- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all combinations
--- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all
PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian jayuan2008 at yahoo.com writes:
Hello,
is there a simple way to give all combinations for a given vector:
v-c(a,b,c
){
v.v-c(v.v,paste(v[i],v[j]))
}
}
is there simpler way to do?
thanks
Yu
--- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote:
From: Lucien Lemmens [EMAIL PROTECTED]
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM
Yuan Jian
Hi,
I am looking for R editor. does anyone know good editor? which tells you
syntax error and it has function to beautify format (insert TAB etc.).
Yu
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hello,
I tried to use a variable to refer colname, but I got error, could anyone give
me advice?
df=data.frame(cbind(AB=1:3,AC=3:5))
df$AC
[1] 3 4 5
df$paste(A,C,sep=)
Error: attempt to apply non-function
thanks
Jian
[[alternative HTML version deleted]]
Hi,
I am using plot to show scatter points in 2_D.
in my data, there is no data between -1 and +1 in x-axis.
I want to skip this region, i.e. x axis becomes [-Inf:-1, 1:Inf].
can any one tell me how to do?
YU
[[alternative HTML version deleted]]
a range of axis
To: Yuan Jian jayuan2...@yahoo.com
Cc: r-help@r-project.org
Received: Wednesday, 12 January, 2011, 10:26 AM
On 01/12/2011 03:46 PM, Yuan Jian wrote:
Hi,
I am using plot to show scatter points in 2_D.
in my data, there is no data between -1 and +1 in x-axis.
I want to skip
Hello,
I found the residuals of glm is not the same as calculated manually.
y=c(12,14,33,50,67,74,123,141,165,204,253,246,240)
t=1:13
m1=glm(y~t+I(t^2),family=poisson(link=log))
coefficients(m1)[1]+coefficients(m1)[2]*log(t)+coefficients(m1)[3]*log(t^2)
[1] 1.901459 2.257258 2.465388 2.613058
Hello,I used l to draw a figure, but I got different result (26 vs 301) when I
input the same parameters.
> length(predict(lm(A$Counts ~ AT),list(ATE=timevalues)))
[1] 26
> length(predict(lm(A$Counts ~ ATE),list(ATE=timevalues)))
[1] 301
all variables are initialized as below:
>A <-
Hello,I have a SAS formatted file as attached, when I use lookup.xport i got
error below> lookup.xport("patient.ssd01")Error in lookup.xport.inner(file) :
unable to open file: 'No such file or directory'
can anyone please help me to figure it out?
thanksyuan
39 matches
Mail list logo