Re: [R] off-topic: better OS for statistical computing

2007-09-10 Thread Weiwei Shi
Linux!  Mac OS is ok to me2.

On 9/10/07, Wensui Liu <[EMAIL PROTECTED]> wrote:
> Good morning, everyone,
> I am sorry for this off-topic post but think I can get great answer
> from this list.
> My question is what is the best OS on PC (laptop) for statistical
> computing and why.
> I really appreciate your insight.
> Have a nice day.
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] machine learning on ordered (ranked) feature

2007-09-10 Thread Weiwei Shi
Hi, there:

just a little bit off-topic:

any algorithm in classification is good for ordered features, like all
variables used are 1, 2, 3,...; not really continuous but ordered. i
tried random forest and dlda already.


thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] PCA IN R

2007-09-07 Thread Weiwei Shi
hi,

A very quick search of PCA in R results in a lot of packages involving
that function. Just wondering which one is generally used for "fat"
data like microarray, esp. when the number of features is really big?

Thanks for comments

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to calculate mean into a list

2007-08-28 Thread Weiwei Shi
Dear Listers:

I have this task and suppose a0 is a list of 10 data.frames, I want to
calculate like this
> (a0[[1]]+a0[[2]]+..+a[[10]])/10

Thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Is there any good tools to facilitate us to create R functions?

2007-08-17 Thread Weiwei Shi
Your question is well un-defined. Specify your question, maybe by an
example so we can help.

You can also send me personal email if you want. I graduate from Fudan
too, so I would like to give a favor, lol

Best,

Weiwei

On 8/17/07, zhijie zhang <[EMAIL PROTECTED]> wrote:
> Dear R users,
>   We have some programs for the specific task in our research, but they were
> very commonly used. We want to make some functions for them, anybody can
> recommend any good tools to facilitate us to create R functions even without
> going deep into the theories of R functions ?
>   Any suggestions or help are greatly appreciated.
>
> --
> With Kind Regards,
>
> oooO:
> (..):
> :\.(:::Oooo::
> ::\_)::(..)::
> :::)./:::
> ::(_/
> :
> [***]
> Zhi Jie,Zhang ,PHD
> Tel:86-21-54237149
> Dept. of Epidemiology,School of Public Health,Fudan University
> Address:No. 138 Yi Xue Yuan Road,Shanghai,China
> Postcode:200032
> Email:[EMAIL PROTECTED]
> Website: www.statABC.com
> [***]
> oooO:
> (..):
> :\.(:::Oooo::
> ::\_)::(..)::
> :::)./:::
> ::(_/
> :
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] finding the row(s) for a date in a data frame

2007-08-17 Thread Weiwei Shi
try this, and you will get a clue:
> (today <- Sys.Date())
[1] "2007-08-17"
> class(today)
[1] "Date"
> as.Date("2007-08-17") == today
[1] TRUE

so basically,
your.target = as.Date("1979-12-14")

apply(A, c(1,2), function(x) x==your.target)) # should work. I did not
test though.

HTH,

Weiwei

On 8/17/07, Gonçalo Ferraz <[EMAIL PROTECTED]> wrote:
> Hi,
>
> If I have a data frame A with the following format:
>
>Day1  Day2   Day3  Day4
> 1 1979-11-02  1979-11-03  1979-11-04  
> 2 1979-12-06 
> 3 1979-12-13  1979-12-14  1979-12-15  1979-12-16
> 4 1979-12-20 
>
> And a date "1979-12-14", for example.
>
> How can I find the row or rows of the data frame were that date can be
> found?
>
> The date is stored in a date format variable called 'day'. I am trying
> commands such as A==day, expecting to see a matrix of logical values, but I
> am only getting error messages such as "(list) object cannot be coerced to
> 'double'".
>
> I am looking for a simple command that would return, in this case, a vector:
>
> FALSE FALSE TRUE FALSE
>
> Thanks for any help!
>
> Gonçalo
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@stat.math.ethz.ch 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.
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Urgent Help needed

2007-08-16 Thread Weiwei Shi
try this:

t0 = read.table("datatest.txt", header=T)
X.mean = ave(t0[,1], as.factor(t0[,3]))

you do the rest of Y.mean and make them into a data.fame or whatever.

HTH,

Weiwei

On 8/16/07, AbouEl-Makarim Aboueissa <[EMAIL PROTECTED]> wrote:
> Dear All:
>
> Urgent help is needed.
>
>
> I have a data set in matrix format  of three columns: X, Y and index of four 
> groups (1,2,3,4). What I need to do is the following;
>
> 1- How I can subtract the sample mean of each group indexed 1,2,3,4 from the
>  corresponding data values of this group and create new columns say 
> X-sample mean
>   and Y-sample mean? I tried to use the "tapply" but I have some 
> difficulties to restore the new data
>
>
> 2- How I can use the "tapply" if possible or any other R-function to find the 
> correlation
>  coefficient between the X and Y columns for each group indexed 1,2,3,4.? 
> Could not use the "tapply".
>
>
> I attached part of the data as txt file.
>
>
> Thank you so much for your attention to this matter, and I look forward to 
> hear from you soon.
>
> Regards,
>
> Abou
>
>
> Data:
> 
> x   y   index
> 15807.2412.54
> 15752.5133.54
> 12893.7601.53
> 8426.88 22.23
> 5706.24 333 3
> 3982.08 560 2
> 3642.62 670 2
> 295.68  124 1
> 215.40  104 1
> 195.40  204 1
> 4240.21 22.42
> 1222.72 45.92
> 1142.26 23.62
> 63.00   90.11
> 1216.00 82.42
> 2769.60 111 2
> 1790.46 34.72
> 26.10   26.10   1
> 19676.830.994
> 10920.60203 3
> 6144.00 46  3
> 4534.48 4534.48 3
> 4.0065  4
> 29500.0056  4
> 17100.0077  4
> 9000.00 435 3
> 6300.00 84  3
> 3962.88 334 2
> 5690.00 653 3
> 3736.00 233 2
> 2750.00 22  2
> 1316.00 345 2
> 4595.00 4595.00 3
> 5928.00 45  3
> 2645.70 0.002
> 2580.24 454 2
> 6547.34 6547.34 3
> 1615.68 5   2
> 194.06  55  1
> 184.80  6   1
> 82.94   44  1
> 16649.0056  4
> 4500.00 74  3
> 1600.00 744 2
>
> =
>
>
>
> ==
> AbouEl-Makarim Aboueissa, Ph.D.
> Assistant Professor of Statistics
> Department of Mathematics & Statistics
> University of Southern Maine
> 96 Falmouth Street
> P.O. Box 9300
> Portland, ME 04104-9300
>
> Tel: (207) 228-8389
> Email: [EMAIL PROTECTED]
>   [EMAIL PROTECTED]
> Office: 301C Payson Smith
>
>
> __
> R-help@stat.math.ethz.ch 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.
>
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Formula in lm inside lapply

2007-08-15 Thread Weiwei Shi
try this:

> x = predict(z, Iris[-train, ])
> x1 <- rnorm(100,1)
> x2 <- rnorm(100,1)
> y  <- rnorm(100,1)
> group <- rep(c("A","B"),c(40,60))
> group <- factor(group)
> df <- data.frame(y,x1,x2,group)
> resf1 <- lapply(levels(df$group),function(x) {formula1 <- as.formula(y~x1); 
> lm(formula1,df, subset =group ==x)}) # put the formula defn into function(x)
> resf1
[[1]]

Call:
lm(formula = formula1, data = df, subset = group == x)

Coefficients:
(Intercept)   x1
 0.8532   0.1189


[[2]]

Call:
lm(formula = formula1, data = df, subset = group == x)

Coefficients:
(Intercept)   x1
 0.7116   0.3398

HTH,

Weiwei

On 8/15/07, Li, Yan (IED) <[EMAIL PROTECTED]> wrote:
> I am trying to run separate regressions for different groups of
> observations using the lapply function. It works fine when I write the
> formula inside the lm() function. But I would like to pass formulae into
> lm(), so I can do multiple models more easily. I got an error message
> when I tried to do that. Here is my sample code:
>
> #generating data
> x1 <- rnorm(100,1)
> x2 <- rnorm(100,1)
> y  <- rnorm(100,1)
> group <- rep(c("A","B"),c(40,60))
> group <- factor(group)
> df <- data.frame(y,x1,x2,group)
>
> #write formula inside lm--works fine
> res1 <- lapply(levels(df$group), function(x) lm(y~x1,df, subset = group
> ==x))
> res1
> res2 <- lapply(levels(df$group),function(x) lm(y~x1+x2,df, subset =
> group ==x))
> res2
>
> #try to pass formula into lm()--does not work
> formula1 <- as.formula(y~x1)
> formula2 <- as.formula(y~x1+x2)
> resf1 <- lapply(levels(df$group),function(x) lm(formula1,df, subset =
> group ==x))
> resf1
> resf2 <- lapply(levels(df$group),function(x) lm(formula2,df, subset =
> group ==x))
> Resf2
>
> The error message is
> 'Error in eval(expr, envir, enclos): object "x" not found'
>
> Any help is greatly appreciated!
>
> Yan
> 
>
> This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
>
> __________
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] feature's contribution into classification

2007-08-13 Thread Weiwei Shi
Hi, there:

The following question is more of statistics:

assume i have 5 features in a classification, and I am wondering which
methodology can help me identify which feature "contributes" the most
to classify a specific sample?

I knew some simple modeling like logistic regression probably can do
it since it provides an explicit formulae for that. Any others?

I tried to use lda{MASS} and posted the question last week but I did
not get any response. So again, I re-phrase my question.

Thanks.

WEIWEI

My previous questions are also attached for reference.


hi,

maybe I should re-phrase my question a bit:

is there a way to get explicit formulae like Y ~ sum of CiXi from the
model build by lda{MASS} to calculate $x (value) ?

I assume scaling is the coeff and Xi is from test data and Y is $x
called LD1. But I want to confirm this.


##

hi,

assume
val is the test data while m is lda model value by using CV=F

x = predict(m, val)

val2 = val[, 1:(ncol(val)-1)] # the last column is class label

# col is sample, row is variable

then I am wondering if

x$x == (apply(val2*m$scaling), 2, sum)

i.e., the scaling (is it coeff vector?) times val data and sum is the
discrimant result $x?


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] write.table

2007-08-10 Thread Weiwei Shi
I did not read ?write.table in details about CSV section.

Thanks.

On 8/10/07, Yinghai Deng <[EMAIL PROTECTED]> wrote:
> write.table(mydata.frame, "mydata", col.names=NA, quote=F, sep="\t") will
> solve the problem.
> Deng
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Weiwei Shi
> Sent: August 10, 2007 12:41 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] write.table
>
>
> Hi,
>
> I am always with this qustion when I tried to write a data.frame with
> row.names and col.names. I have to re-make the data frame to let its
> first column be the rownames and let row.names=F so that I can align
> the colnames correctly.
>
> Is there a way or option in write.table to automatically do that?
>
> thanks.
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>
> __
> R-help@stat.math.ethz.ch 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.
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] write.table

2007-08-10 Thread Weiwei Shi
Hi,

I am always with this qustion when I tried to write a data.frame with
row.names and col.names. I have to re-make the data frame to let its
first column be the rownames and let row.names=F so that I can align
the colnames correctly.

Is there a way or option in write.table to automatically do that?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] a question on lda{MASS}

2007-08-10 Thread Weiwei Shi
hi,

maybe I should re-phrase my question a bit:

is there a way to get explicit formulae like Y ~ sum of CiXi from the
model build by lda{MASS} to calculate $x (value) ?

I assume scaling is the coeff and Xi is from test data and Y is $x
called LD1. But I want to confirm this.

Thanks.

Weiwei

On 8/9/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> hi,
>
> assume
> val is the test data while m is lda model value by using CV=F
>
> x = predict(m, val)
>
> val2 = val[, 1:(ncol(val)-1)] # the last column is class label
>
> # col is sample, row is variable
>
> then I am wondering if
>
> x$x == (apply(val2*m$scaling), 2, sum)
>
> i.e., the scaling (is it coeff vector?) times val data and sum is the
> discrimant result $x?
>
> Thanks.
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] a question on lda{MASS}

2007-08-09 Thread Weiwei Shi
hi,

assume
val is the test data while m is lda model value by using CV=F

x = predict(m, val)

val2 = val[, 1:(ncol(val)-1)] # the last column is class label

# col is sample, row is variable

then I am wondering if

x$x == (apply(val2*m$scaling), 2, sum)

i.e., the scaling (is it coeff vector?) times val data and sum is the
discrimant result $x?

Thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] clustering on Trinary data

2007-08-06 Thread Weiwei Shi
Hi, Alex:

I think you need to provide your distance function by your domain
knowledge: for example, for a specific variable, is the distance from
-1 to 1 the same as that of -1 to zero. When you have this own
distance function, you can create a distance matrix. After than, any
cluster package in R can be applied to your question.

my2cents,

HTH,

Weiwei

On 8/6/07, Alex Tsoi <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I have a data matrix with 7 independent variables, and each of them is a
> trinary variable ( - 1, 0 , 1), and I would like to know what kinds of R
> package or method I should use to perform the clustering.
>
> Thanks for any comment or suggestion.
>
>
> --
> Lam C. Tsoi (Alex)
> Medical University of South Carolina
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] apply a function to loop through

2007-07-17 Thread Weiwei Shi
Hi,

first of all, your Scores are factors instead of numeric, you need to change it;

I made a new myDat for test purpose by

myDat = as.data.frame(rbind(myDat, myDat))
myDat[16:30, 3] <- "gene2"

> myDat
   tissueScores   Grp
a   A  3.01494535196933 gene1
b   A  2.99647624484379 gene1
c   A  3.00527533284709 gene1
d   A  3.02321059636917 gene1
e   A  3.04694197334289 gene1
f   B  11.1464974692841 gene1
g   B  12.2372838904939 gene1
h   B  11.7277801841221 gene1
i   B  11.6405683605147 gene1
j   B  11.1631961720026 gene1
k   C  0.67528704974662 gene1
l   C  1.21000950157251 gene1
m   C 0.843722400594721 gene1
n   C 0.881706314004343 gene1
o   C  1.43670211710054 gene1
a1  A  3.01494535196933 gene2
b1  A  2.99647624484379 gene2
c1  A  3.00527533284709 gene2
d1  A  3.02321059636917 gene2
e1  A  3.04694197334289 gene2
f1  B  11.1464974692841 gene2
g1  B  12.2372838904939 gene2
h1  B  11.7277801841221 gene2
i1  B  11.6405683605147 gene2
j1  B  11.1631961720026 gene2
k1  C  0.67528704974662 gene2
l1  C  1.21000950157251 gene2
m1  C 0.843722400594721 gene2
n1  C 0.881706314004343 gene2
o1  C  1.43670211710054 gene2
> mytry <- by(myDat, INDICES=as.factor(myDat[,3]), FUN=function(x) {
+ pairwise.wilcox.test(as.numeric(as.character(x$Scores)),
+
+ x$tissue,
+
+ p.adjust.method = "none")$p.value
+ })
> mytry
as.factor(myDat[, 3]): gene1
A   B
B 0.007936508  NA
C 0.007936508 0.007936508

as.factor(myDat[, 3]): gene2
A   B
B 0.007936508  NA
C 0.007936508 0.007936508


HTH,

Weiwei

On 7/17/07, Hai Lin <[EMAIL PROTECTED]> wrote:
> Dear R users,
>
> I have a dataset generated as follows,
>
> myDat <- data.frame(matrix(c(rep(LETTERS[1:3],
> each=5),
>  rnorm(5,mean=3,sd=0.03),
>  rnorm(5,12,1),
>  rnorm(5,1,0.5)),
>ncol=2,
>
> dimnames=list(c(letters[1:15]),
>
> c("tissue","Scores"
> myDat$Grp <-c("gene1")
>
> There is one level "gene1" in $Grp in my data step.
> I'd like to do pairwise.wilcox.test on $tissue while
> going throug $Grp if there are more levels with gene2,
> gene3.
>
> I tried to loop through $Grp using apply with an error
> message "Error in sort(unique.default(x), na.last =
> TRUE) :
> 'x' must be atomic".
>
> mytry <-  apply(as.matrix(myDat),
> 1,
>
> function(Grp)pairwise.wilcox.test(Grp$Scores,
>
> Grp$tissue,
>
> p.adjust.method = "none")$p.value)
>
> I could not find any similar stuffs in forum. Could
> anyone here give a hand?
>
> Thanks a bunch.
>
> kevin
>
> ______
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] reinforce library to re-load

2007-07-03 Thread Weiwei Shi
Hi,

I am wondering if there is a parameter in library() so that it can
reinforce package to be reloaded. It helps when you test your modified
package by yourself. Otherwise, my way is to re-start Rgui.

(by reading ?library, I understand this option is not implemented)
"...Both functions check and update the list of currently loaded
packages and do not reload a package which is already loaded.
(Furthermore, if the package has a name space and a name space of that
name is already loaded, they work from the existing names space rather
than reloading from the file system.)"

Thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] dlda{supclust} 's output

2007-07-03 Thread Weiwei Shi
Hi,

I modified dlda{supclust} so that the original example in ?dlda gives
the following output:

> set.seed(342)
> xlearn <- matrix(rnorm(200), nrow = 20, ncol = 10)
>
> ## Generating random test data: 8 observations and 10 variables(clusters)
> xtest  <- matrix(rnorm(80),  nrow = 8,  ncol = 10)
>
> ## Generating random class labels for the learning data
> ylearn <- as.numeric(runif(20)>0.5)
>
> ## Predicting the class labels for the test data
>
> t0 = dlda(xlearn, xtest, ylearn)
> t0
  [,1] [,2]
[1,] 17.595758 21.20141
[2,] 11.882305 20.34470
[3,]  7.837422 12.47240
[4,] 11.025810 12.04523
[5,] 18.167740 15.91930
[6,] 11.396010  9.26949
[7,] 33.911010 26.06992
[8,] 16.140149 19.83915

(to be noticed: the above is anti-probabilities, which means the
smaller, the higher prob for being the label of colname, for example,
sample 5, the class label is predicted as 1 instead of 0)

Here I have one question about it:

since apply(t0, 1, sum) does not give the same sum, I am wondering if
standardization is a proper way to compare the probabilities "BETWEEN"
samples, following the understanding of dlda algorithm.



Thanks,

Weiwei

On 5/7/07, Marcel Dettling <[EMAIL PROTECTED]> wrote:
> Hi Weiwei,
>
> it would be possible to obtain probabilities instead of just a 0/1
> output. The code needs to be altered though. Sorry I don't have the time
> to do that. But R is open source and contributions are most welcome.
>
> I'm sorry not to be able of more help,
>
> Marcel
>
> --
> Marcel Dettling
> Phone:  +41 79 489 72 04
> E-Mail: [EMAIL PROTECTED]
> Web:    http://stat.ethz.ch/~dettling
> --
> - Original Message -
> From: "Weiwei Shi" <[EMAIL PROTECTED]>
> To: "R Help" 
> Cc: <[EMAIL PROTECTED]>
> Sent: Tuesday, May 01, 2007 11:50 PM
> Subject: dlda{supclust} 's output
>
>
> > Hi,
> >
> > I am using dlda algorithm from supclust package and I am wondering if
> > the output can be a continuous probability instead of discrete class
> > label (zero or one) since it puts some restriction on convariance
> > matrix, compared with lda, while the latter can.
> >
> > thanks,
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> >
> > !DSPAM:4637b61518111667610022!
> >
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Installing packages...

2007-07-03 Thread Weiwei Shi
I have the exact same problem as you had when I customerized some
package: the way I go around this is using

install.packages("~/Documents/projects/R_customerized_packages/supclust_1.0-5.tar.gz",
repos=NULL, type="source")

in which supclust_... is built from
R CMD build supclust

and in your case, you just need to download the package if you insist
on using downloaded package.

HTH,

Weiwei

On 1/23/07, Nüzhet Dalfes <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am a total newbie to R. I am using R (2.4.1) on Mac OS X 10.4.8 and
> trying to install some packages using GUI Packages & Data/Package Installer
> interface...
>
> Every time I get:
>
> trying URL
> 'http://umfragen.sowi.uni-mainz.de/CRAN/bin/macosx/universal/contrib/2.4/neural_1.4.1.tgz'
> Content type 'application/x-tar' length 18920 bytes
> opened URL
> ==
> downloaded 18Kb
>
> Error in gzfile(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open compressed file 'neural/DESCRIPTION'
> >
>
> What am I doing wrong?
>
> Any help will be much appreciated.
>
> Nüzhet Dalfes
>
> Istanbul Tech. Univ.
>
> __
> R-help@stat.math.ethz.ch 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.
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] running saved scripts

2007-06-27 Thread Weiwei Shi
put into a file called abc.R or whatever,

source("abc.R")

check ?source

On 6/27/07, Jiong Zhang, PhD <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a rather naive question.  I need to run some simple calculations
> such as read.table, resid, and quantile on a data file.  How can I save
> these commands in a text file and ask R to run this text file?  Thanks.
>
> Jiong Zhang
>  The email message (and any attachments) is for the sole use of the intended 
> recipient(s) and may contain confidential information.  Any unauthorized 
> review, use, disclosure or distribution is prohibited.  If you are not the 
> intended recipient, please contact the sender by reply email and destroy all 
> copies of the original message (and any attachments).  Thank You.
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] a string to enviroment or function

2007-06-25 Thread Weiwei Shi
then how to do this

f1 <- function(mylab){
  library(mylab)
  ...
}

it seems that if you call
library("hgu133a") # which is file
# but
library(mylab) # even you pass "hgu133a" as parameter, it still
complains about "mylab" does not exist. It seems that it consider
mylab as package instead of its value.


On 6/25/07, jim holtman <[EMAIL PROTECTED]> wrote:
> I think that you might want:
>
> t0 <- (paste("hgu133a", "ENTREZID", sep=""))
> xx <- as.list(get(t0)) # make it work like xx<-as.list(hgu133aENTREZID)
>
>
>
>
> On 6/25/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I am wondering how to make a function Fun to make the following work:
> >
> > t0 <- (paste("hgu133a", "ENTREZID", sep=""))
> > xx <- as.list(Fun(t0)) # make it work like xx<-as.list(hgu133aENTREZID)
> >
> > thanks,
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] a string to enviroment or function

2007-06-25 Thread Weiwei Shi
Hi,

I am wondering how to make a function Fun to make the following work:

t0 <- (paste("hgu133a", "ENTREZID", sep=""))
xx <- as.list(Fun(t0)) # make it work like xx<-as.list(hgu133aENTREZID)

thanks,
-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to plot this?

2007-06-25 Thread Weiwei Shi
Hi, there:

Suppose I have a couple of data.frames and each one has five columns
(one for x-axis, two for y-axis and two for std of y's.) There is
another dimensions (besides x and y) which is continuous. My question
is, how to plot such series of data frames in one plot (thus,
3-dimensional plot) AND multiple 2-D plots. I am not familar with R's
plotting utilities.

Thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] how to ave this?

2007-06-22 Thread Weiwei Shi
one of my approaches is:

x0 = sapply(mylist, cbind)

and manipulate from x0 (x0[1:nrow(x0)/2, ] correponds to fc and the
lower part is tt.

but it is not neat way.


On 6/22/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a list that looks like this:
> [[1]]
>  fc  tt
> 50   0.07526882 0.0
> 100  0.09289617 0.0
> 150  0.12359551 0.0
>
> [[2]]
>  fc  tt
> 50   0.02040816 0.0
> 100  0.03626943 0.005025126
> 150  0.05263158 0.010101010
>
> and I am wondering how to "average" it so that I have one matrix t0 at
> the end, and t0[1,1] = (0.075..+0.0204..)/2
>
> Thanks,
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to ave this?

2007-06-22 Thread Weiwei Shi
Hi,

I have a list that looks like this:
[[1]]
 fc  tt
50   0.07526882 0.0
100  0.09289617 0.0
150  0.12359551 0.0

[[2]]
 fc  tt
50   0.02040816 0.0
100  0.03626943 0.005025126
150  0.05263158 0.010101010

and I am wondering how to "average" it so that I have one matrix t0 at
the end, and t0[1,1] = (0.075..+0.0204..)/2

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] merge

2007-06-20 Thread Weiwei Shi
if your nrow is not big, transpose and merge and transpose back.

HTH,

On 6/20/07, elyakhlifi mustapha <[EMAIL PROTECTED]> wrote:
> hello,
> is it possible to merge 2 matrix or data.frame by roxnames?
> I checked details about the functino merge but I haven't fond this option.
> Can you help me please?
> thanks.
>
>
>   
> _
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] outlying

2007-06-19 Thread Weiwei Shi
check package dprep

On 6/19/07, elyakhlifi mustapha <[EMAIL PROTECTED]> wrote:
> hello,
> are there functions to detecte outlying observations in samples?
> thanks.
>
>
>
>
>
>
>
>
> ___
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] source a specific function

2007-06-18 Thread Weiwei Shi
Dear Listers:

For example, if I have a .R source file which has more than one
function, and I want to just load only one of the functions, how could
I do that? (removing the rest after sourcing is not what I intend b/c
in my workspace, I might have some of the rest and I don't want to
change my workspace: i.e., I only change my workspace by adding one
function from a R source file).

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] simulate null hypothesis

2007-06-14 Thread Weiwei Shi
Hi, there:

This is a bit off-topic but I try to do it in R so I put it here:

I have 31 samples from a population of genes, and each sample contains
a pair of gene lists, with different lengths and the intersection
between the two lists also varies. I want to test my hypothesis by
creating a null hypothesis for this population. Since the distribution
for the length and the distribution for the intersection size do not
follow any known distribution, I think I need to use sample with
replacement to simulate those "parameters". And use the parameters to
permutate genes; but I am not very sure if it is alll right.

BTW, is there any general package or I just need "sample()" to do
that? (just tried to make my question on-topic:)

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] pretty report

2007-06-13 Thread Weiwei Shi
I think my initial intention is to write multiple worksheets for
multiple data frames. write.csv or write.table cannot do that.

On 6/12/07, Robert A LaBudde <[EMAIL PROTECTED]> wrote:
> At 09:13 PM 6/12/2007, Don wrote:
> >At 5:01 PM -0400 6/12/07, Weiwei Shi wrote:
> > >Dear Listers:
> > >
> > >I have a couple of data frames to report and each corresponds to
> > >different condtions, e.g. conditions=c(10, 15, 20, 25). In this
> > >examples, four data frames need to be exported in a "pretty" report.
> > >
> > >I knew Perl has some module for exporting data to Excel and after
> > >googling, I found R does not.
> >
> >I use write.table(), name the file with ".xls" as the suffix, then
> >outside R I double-click on it and it opens in Excel. Granted, it's a
> >text file, and Excel is opening a text file, but none the less, I
> >
>
> Note that files with a ".csv" extension are also associated with
> Excel and can opened with a double-click. Comma-separated-value files
> also can be unambiguously loaded by Excel without parsing.
>
> 
> Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
> Least Cost Formulations, Ltd.URL: http://lcfltd.com/
> 824 Timberlake Drive Tel: 757-467-0954
> Virginia Beach, VA 23464-3239Fax: 757-467-2947
>
> "Vere scire est per causas scire"
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] pretty report

2007-06-12 Thread Weiwei Shi
Just realized append=T might help for xtable, but I think it still not
very "pretty" :)

On 6/12/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Dear Listers:
>
> I have a couple of data frames to report and each corresponds to
> different condtions, e.g. conditions=c(10, 15, 20, 25). In this
> examples, four data frames need to be exported in a "pretty" report.
>
> I knew Perl has some module for exporting data to Excel and after
> googling, I found R does not.
>
> So I am wondering if there is a package in R for generating good
> reports. I found package xtable but it seems (if not, please correct
> me) that it can only generate one table for one file.
>
> Thanks for any suggestions,
>
> -W
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] pretty report

2007-06-12 Thread Weiwei Shi
Dear Listers:

I have a couple of data frames to report and each corresponds to
different condtions, e.g. conditions=c(10, 15, 20, 25). In this
examples, four data frames need to be exported in a "pretty" report.

I knew Perl has some module for exporting data to Excel and after
googling, I found R does not.

So I am wondering if there is a package in R for generating good
reports. I found package xtable but it seems (if not, please correct
me) that it can only generate one table for one file.

Thanks for any suggestions,

-W

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] history in R.app on Mac

2007-06-11 Thread Weiwei Shi
got it. Thanks. I was always trying to find it at menu and did not
expect that in my toolbar :)

I just assumed that any tool icon should also be shown on menu, which
is just a routine to me.

-w

On 6/11/07, Rob J Goedman <[EMAIL PROTECTED]> wrote:
> If you click on the history icon in the toolbar in R.app you will see
> them. Or up and down arrows.
> R.app implements some extra features, such as multiline command
> retrieval.
>
> Through preference settings you can control if you want to see just a
> single ls() or multiple, etc.
>
> Rob
>
> On Jun 11, 2007, at 9:18 AM, Weiwei Shi wrote:
>
> > hi,
> >
> > I am really confused by history function in R.app for Mac:
> >
> > Here is some test from command-line:
> >> ls()
> > character(0)
> >> ls()
> > character(0)
> >> ls()
> > character(0)
> >> history()
> > ls()
> > ls()
> > ls()
> > history()
> >
> > That is what I expected. But from R.app, it does not show anything.
> >
> >_
> > platform   i386-apple-darwin8.9.1
> > arch   i386
> > os darwin8.9.1
> > system i386, darwin8.9.1
> > status
> > major  2
> > minor      5.0
> > year   2007
> > month  04
> > day23
> > svn rev41293
> > language   R
> > version.string R version 2.5.0 (2007-04-23)
> >
> > Thanks,
> >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > __
> > R-help@stat.math.ethz.ch 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.
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] history in R.app on Mac

2007-06-11 Thread Weiwei Shi
hi,

I am really confused by history function in R.app for Mac:

Here is some test from command-line:
> ls()
character(0)
> ls()
character(0)
> ls()
character(0)
> history()
ls()
ls()
ls()
history()

That is what I expected. But from R.app, it does not show anything.

   _
platform   i386-apple-darwin8.9.1
arch   i386
os darwin8.9.1
system i386, darwin8.9.1
status
major  2
minor  5.0
year   2007
month  04
day23
svn rev41293
language   R
version.string R version 2.5.0 (2007-04-23)

Thanks,



-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] data mining/text mining?

2007-06-08 Thread Weiwei Shi
Dear Ruixin:
Among others, text mining is dealing with non-structural data while
data mining mainly focuses on structural one. Many algorithms can be
shared b/w them; however, some necessary data preprocessing is
required for text mining. There are a lot of online-resource there.

As to packages used for text mining in R, esp. for preprocessing,
please check the following link:
http://wwwpeople.unil.ch/jean-pierre.mueller/

I used that package very long time ago and am not sure if they are
updated for this current version of R; otherwise, you might need to go
back the old version like R1.1.

If you want to do text mining for chinese text (I guess :), there is
additional work (i.e. word splitting) needed. I remember there is some
researcher from Taiwan who does pretty good work and you can google
that. I cannot remember the details.

HTH,

Weiwei


On 6/8/07, Ruixin ZHU <[EMAIL PROTECTED]> wrote:
> Dear R-user,
>
> Could anybody tell me of the key difference between data mining and text
> mining?
> Please make a list for packages about data/text mining.
> And give me an example of text mining with R (any relating materials
> will be highly appreciated), because a vignette written by Ingo Feinerer
> seems too concise for me.
>
> Thanks
> _
> Dr.Ruixin ZHU
> Shanghai Center for Bioinformation Technology
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 86-21-13040647832
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] what fun I need to put in this "tapply"

2007-05-14 Thread Weiwei Shi
Hi,
I happened to need generate the following
> t1
  V1 V2 count count2
1  1 11 2  3
2  1 12 2  2
3  2 11 1  3
4  3 13 3  1
5  3 11 3  3
6  3 12 3  2

from
  V1 V2
1  1 11
2  1 12
3  2 11
4  3 13
5  3 11
6  3 12

I am wondering what function of funx I need to put into
tapply(t1[,2], t1[,2] funx)

to get that?

If I use length, I probabaly need to do merge by myself. Is there a better way?

thanks.


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] save intermediate result

2007-05-04 Thread Weiwei Shi
sorry for my English, staying in US over 7 years makes me think I were
ok, now :(

anyway, here is an example and why I need that:

suppose I have a function like the following:

f1 <- function(){
 line1 <- f2() # assume this line takes very long time, like more than 30 min
 # then I need to save line1 as an object into workspace b/c
 # the following lines after this might have some bugs
 # currently I use
 save(line1, file="line1.robj")
 # but I am thinking if there is anothe way, like enviroment, instead
of save it into a file

 # codes as followed might have some bugs
 # blabla...
}

if some codes as followed have bugs, my f1 function cannot return
anything, which means I have to re-run the time-consuming line again.

thanks,

Weiwei

On 5/4/07, Joerg van den Hoff <[EMAIL PROTECTED]> wrote:
> On Fri, May 04, 2007 at 03:45:10PM -0400, Weiwei Shi wrote:
> > hi,
> >
> > is there a way to save a R object into workspace instead of into a
> > file during a running of function?
> >
>
> if I understand the question correctly you want the 'super-assignment'
> operator `<<-' as in
>
> -cut---
> R> f <- function(x) y <<- 2*x
> R> f(1)
> R> y
> [1] 2
> R> f(10)
> R> y
> [1] 20
> -cut---
>
> i.e. y is assigned a value in the 'workspace'. be careful, though, with
> this kind of assignment. why not return the object you are interested
> in as a list component together with other results when the function
> call finishes?
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] save intermediate result

2007-05-04 Thread Weiwei Shi
hi,

is there a way to save a R object into workspace instead of into a
file during a running of function?

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] dlda{supclust} 's output

2007-05-01 Thread Weiwei Shi
Hi,

I am using dlda algorithm from supclust package and I am wondering if
the output can be a continuous probability instead of discrete class
label (zero or one) since it puts some restriction on convariance
matrix, compared with lda, while the latter can.

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Size of an object in workspace

2007-04-24 Thread Weiwei Shi
library(gdata)
ll()


On 4/24/07, Horace Tso <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> Is there a function to show the size of an R object? eg. in Kbytes?
>
> Couple months ago Bendix Carstensen posted this marvelous little function 
> lls(), which shows all objects in the current workspace by mode, class and 
> 'size'. This is a wonderful enhancement to the build-in ls() already and I 
> now have it sourced in my Rprofile.site at startup.
>
> The only drawback is, 'size' is just the length/dim of an object. For 
> matrices and data frames this is good enough. But for a list, knowing how 
> many elements in there doesn't help much. I need to know the totality of the 
> content in a common unit, eg. byte.
>
> Thanks in advance.
>
> Horace
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] intersect more than two sets

2007-04-24 Thread Weiwei Shi
I had a similar solution by using frequency but having more codes :(

I also like the "recursive" idea : I initially tried to use rapply,
however, which can only take one-arg function.

thanks, everyone.

-w

On 4/24/07, hadley wickham <[EMAIL PROTECTED]> wrote:
> On 4/24/07, Tony Plate <[EMAIL PROTECTED]> wrote:
> > I don't think there's that sort of "apply-reduce" function in R, but for
> > this problem, the last line below happens to be a "one-liner":
>
> Only if you have character data though:
>
> > x <- lapply(1:10, function(i) sample(20, 15))
> > names(which(table(unlist(x))==10))
> [1] "14"
>
> (not that it's hard to turn that back into a number)
>
> Hadley
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] intersect more than two sets

2007-04-24 Thread Weiwei Shi
assume t2 is a list of size 11 and each element is a vector of characters.

the following codes can get what I wanted but I assume there might be
a one-line code for that:

t3 <- t2[[1]]
for ( i in 2:11){
t3 <- intersect(t2[[i]], t3)
}

or there is no such "apply"?

On 4/24/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Hi,
> I searched the archives and did not find a good solution to that.
>
> assume I have 10 sets and I want to have the common character elements of 
> them.
>
> how could i do that?
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] intersect more than two sets

2007-04-24 Thread Weiwei Shi
Hi,
I searched the archives and did not find a good solution to that.

assume I have 10 sets and I want to have the common character elements of them.

how could i do that?

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Random Forest

2007-04-23 Thread Weiwei Shi
Hi, Ruben:

fit$confusion

if you provide your test data, then you can also access the confusion
matrix of test data by

fit$test$confusion

there are details of how to use randomForest by reading:
?randomForest

HTH,

Weiwei

On 4/22/07, Ruben Feldman <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to print out my confusion matrix after having created my random
> forest.
> I have put in this command:
> fit<-randomForest(MMS_ENABLED_HANDSET~.,data=dat,ntree=500,mtry=14,
> na.action=na.omit,confusion=TRUE)
>  but I can't get it to give me the confusion matrix, anyone know how this
> works?
>
> Thansk!
>
> Ruben
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] simply this loop?

2007-04-20 Thread Weiwei Shi
Hi, anyone interested in this:

I tried to simply this loop with lapply or something but haven't figured it out:

mapt = c("203929_s_at", "203930_s_at", "203928_x_at", "206401_s_at")
mapt.combn <- lapply(1:4, function(i) combn(mapt, i))
out = list()
k = 1
for (i in 1:length(mapt.combn)){
for (j in 1:ncol(mapt.combn[[i]])){
out[[k]] = mapt.combn[[i]][,j]
k = k + 1
}   
}
out

# the following two lines create a list of list, which is not my intended:

y0 = mapt.combn
lapply(1:4, function(j) {n=ncol(y0[[j]]); lapply(1:n, function(i) y0[[j]][,i])})

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] R-2.4.1 for MacOS X - languageR, acepack, Hmisc

2007-04-18 Thread Weiwei Shi
same problem here.

last time I had a similar one when I did "library(MASS)", I solved
that by re-installation of R 2.4.1. However, this time it does not
work.

On 4/18/07, Lara Tagliapietra <[EMAIL PROTECTED]> wrote:
> I updated R to the last 2.4.1 version and unfortunately I can not
> load languageR any longer.
> In R-2.4.1, LanguageR requires acepack, but Hmisc doesn't work when
> acepack is loaded.
>
> > library(languageR)
> Loading required package: Design
> Loading required package: Hmisc
> Loading required package: acepack
>
>
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
> unable to load shared library '/Library/Frameworks/
> R.framework/Versions/2.4/Resources/library/Hmisc/libs/i386/Hmisc.so':
> dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/
> library/Hmisc/libs/i386/Hmisc.so, 6): Library not loaded: /usr/local/
> gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
> Referenced from: /Library/Frameworks/R.framework/Versions/2.4/
> Resources/library/Hmisc/libs/i386/Hmisc.so
> Reason: image not found
> Error: package 'Hmisc' could not be loaded
>
>
> Apparently the Hmisc.so cannot be loaded, but it is actually there:
>
>
> > source("/Library/Frameworks/R.framework/Versions/2.4/Resources/
> library/Hmisc/libs/i386/Hmisc.so")
> Error in parse(file, n = -1, NULL, "?") : syntax error at
> 1: Œ
>
>
> Did anybody else encounter the same problem? And, if so, I would be
> very grateful to anybody who could tell me how to solve this problem.
>
> Thanks,
>
> Lara Tagliapietra
>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@stat.math.ethz.ch 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.
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Is this a bug?

2007-04-17 Thread Weiwei Shi
one is returned value, the other one is the result from print

> t0 <- ifelse(T, print("h"), print("e"))
[1] "h"
> t0
[1] "h"

HTH,

weiwei

On 4/17/07, Luca Braglia <[EMAIL PROTECTED]> wrote:
> I have found a strange "ifelse" behaviour (I think)
>
> This works:
>
> > ifelse(T,1+1,1+2)
> [1] 2
> > ifelse(F,1+1,1+2)
> [1] 3
>
> Maybe I missed something about R internals, but why
>
> > ifelse(T,print("hello"),print("goodbye"))
> [1] "hello"
> [1] "hello"
> > ifelse(F,print("hello"),print("goodbye"))
> [1] "goodbye"
> [1] "goodbye"
>
> values are returned two times? I'm not sure: if it's a bug I'll post it
> immediately
>
> Thank You
>
> Luca
>
>
> Version:
>  platform = i486-pc-linux-gnu
>  arch = i486
>  os = linux-gnu
>  system = i486, linux-gnu
>  status =
>  major = 2
>  minor = 4.1
>  year = 2006
>  month = 12
>  day = 18
>  svn rev = 40228
>  language = R
>  version.string = R version 2.4.1 (2006-12-18)
>
> Locale:
> LC_CTYPE=it_IT.UTF-8;LC_NUMERIC=C;LC_TIME=it_IT.UTF-8;LC_COLLATE=it_IT.UTF-8;LC_MONETARY=it_IT.UTF-8;LC_MESSAGES=it_IT.UTF-8;LC_PAPER=it_IT.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=it_IT.UTF-8;LC_IDENTIFICATION=C
>
> Search Path:
>  .GlobalEnv, package:MASS, package:utils, package:stats, package:graphics, 
> package:grDevices, package:methods, Autoloads, package:base
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] My First Function: cryptic error message

2007-04-16 Thread Weiwei Shi
Hi, Joel:

I cannot reproduce the error w/o the data called probands but I assume
the line in bagger function
bootsamples <- rmultinom (length(trees), n,
   rep(1,n)/n)

might not succeed so that it complains bootsamples not found.

try to add one line like print(dim(bootsamples)) after the above line
in your codes to see if there is a problem there.

HTH,

Weiwei

On 4/16/07, Joel J. Adamson <[EMAIL PROTECTED]> wrote:
> Dear List,
> My first R function is a rip-off bagging algorithm from pg. 138 of
> Everitt and Hothorn's "Handbook of Statistical Analyses using R"
> (HSAUR).  I'm using recursive partitioning to develop a set of useful
> variables in diagnosing ADHD.
>
> I'm running this in ESS in XEmacs 21.4.19, R 2.4.1 on Slackware Linux
> 11.0 with a 2.6 kernel.
>
> This is almost an entire script, although I've removed or disguised
> parts that would reveal my plans for world domination.  The function
> is right here at the top:
>
> 
> # bagging function:
> bagger <- function (length = 25, formula, dataframe) {
>   trees <- vector(mode = "list", length = length)
>   n <- nrow(dataframe)
>   bootsamples <- rmultinom (length(trees), n,
> rep(1,n)/n)
>   mod <- rpart(formula, data = dataframe,
>control = rpart.control(xval = 0))
>   for (i in 1:length(trees)) {
> trees[[i]] <- update(mod,
>  weights = bootsamples[, i])
>   }
> }
>
> #bring in data
> [snip]
> #Recursive partitioning:
> library("rpart")
> # get a 2/3 random sample of ids
> ids <- sample(probands$id,
>size = 2*(length(probands$id))/3,
>replace = FALSE)
> # now I want a logical vector telling me which sample to put the
> # subjects in:
> #training_true <- probands$id %in% ids
> training <- subset(probands, probands$id %in% ids)
> testing <- subset(probands, ! probands$id %in% ids)
>
> # formula for the rpart model
> adhdcbin <- factor(probands$adhdcbin, ordered = TRUE,
>labels = cbind("Control","ADHD" ))
> cbs38s <- as.formula(paste("adhdcbin ~",
>  paste(names(probands[grep("cbs38_..*",names(probands))]),
>collapse = "+")))
>
> # fitting the rpart model
> rpart_training <- rpart(cbs38s,
> data = training,
> method = "class")
> X11 (); plot(rpart_training);text(rpart_training)
> rpart_training.bagged <- bagger(length = 100, formula = cbs38s, training)
> X11 (); plot(rpart_training.bagged);text(rpart_training.bagged)
> 
>
> The second-to-last line gives me the following error:
>
> Error in eval(expr, envir, enclos) : object "bootsamples" not found
>
> I've used backtrace(), debug(bagger) and options(error=recover ()) and
> nothing seems to make sense.  What should I be looking for?
> "bootsamples" is there at every time except ...
>
> I've tried this with other formulas, I've tried typing in
> the function vs. reading it in by source(); I've re-formatted the top
> line to read with the brace on the same line as the declaration or on
> the next line.  EVerything produces the same message.  Am I binding
> the variables correctly?  Am I declaring the arguments correctly?
>
> The most irritating part is that this worked last week ;)  I swear.
>
> Thanks,
> Joel
> --
> Joel J. Adamson
> Biostatistician
> Pediatric Psychopharmacology Research Unit
> Massachusetts General Hospital
> Boston, MA  02114
> (617) 643-1432
> (303) 880-3109
>
>
>
>
>
> The information transmitted in this electronic communication...{{dropped}}
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] problems in loading MASS

2007-04-12 Thread Weiwei Shi
Hi Charilaos:

I think the installation has no problem as indicated by
"install.packages()". Anyway, I tried your way but unfortunately it
does not help.

Thanks though,

-W

On 4/12/07, Charilaos Skiadas <[EMAIL PROTECTED]> wrote:
> Weiwei,
>
> I have never had much success installing packages from within R.app
> on MacOSX, because the location that it is supposed to save things, /
> Library/Frameworks/, needs elevated priviledges, which the app
> doesn't seem to try to get.  So it at best ends up saving it in some
> temporary location, and it has to be downloaded again next time R is
> restarted.
>
> As a result, I have always downloaded the tgz file from my browser,
> then go to the terminal in that folder and do a "sudo R CMD INSTALL
> packagename.tgz".
>
> But perhaps I am doing something wrong and one can do this properly
> from within R.app, I would love to be wrong on this one.
>
>  > sessionInfo()
> R version 2.4.1 (2006-12-18)
> powerpc-apple-darwin8.8.0
>
> locale:
> en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"   "base"
>  >
>
> Haris Skiadas
> Department of Mathematics and Computer Science
> Hanover College
>
> On Apr 12, 2007, at 6:04 PM, Weiwei Shi wrote:
>
> > Hi, there:
> >
> > After I upgraded my R to 2.4.1, it is my first time of trying to use
> > MASS and found the following error message:
> >> install.packages("MASS")
> > --- Please select a CRAN mirror for use in this session ---
> > trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/universal/
> > contrib/2.4/VR_7.2-33.tgz'
> > Content type 'application/x-gzip' length 995260 bytes
> > opened URL
> > ==
> > downloaded 971Kb
> >
> >
> > The downloaded packages are in
> >   /tmp/RtmpmAzBwa/downloaded_packages
> >
> >> library(MASS)
> > Error in dyn.load(x, as.logical(local), as.logical(now)) :
> >   unable to load shared library
> > '/Library/Frameworks/R.framework/Versions/2.4/Resources/library/
> > MASS/libs/i386/MASS.so':
> >   dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/
> > library/MASS/libs/i386/MASS.so,
> > 6): Library not loaded:
> > /usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
> >   Referenced from:
> > /Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/
> > libs/i386/MASS.so
> >   Reason: image not found
> > Error: package/namespace load failed for 'MASS'
> >
> >
> >> sessionInfo()
> > R version 2.4.1 (2006-12-18)
> > i386-apple-darwin8.8.1
> >
> > locale:
> > en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> >
> > attached base packages:
> > [1] "stats" "graphics"  "grDevices" "utils"     "datasets"
> > "methods"   "base"
> >
> > other attached packages:
> > randomForestdprep
> > "4.5-18""1.0"
> >
> >
> >> version
> >_
> > platform   i386-apple-darwin8.8.1
> > arch   i386
> > os darwin8.8.1
> > system i386, darwin8.8.1
> > status
> > major  2
> > minor  4.1
> > year   2006
> > month  12
> > day18
> > svn rev40228
> > language   R
> > version.string R version 2.4.1 (2006-12-18)
> >
> >
> > Thanks
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
>
>
>
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
[EMAIL PROTECTED] 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] problems in loading MASS

2007-04-12 Thread Weiwei Shi
Hi, there:

After I upgraded my R to 2.4.1, it is my first time of trying to use
MASS and found the following error message:
> install.packages("MASS")
--- Please select a CRAN mirror for use in this session ---
trying URL 
'http://cran.cnr.Berkeley.edu/bin/macosx/universal/contrib/2.4/VR_7.2-33.tgz'
Content type 'application/x-gzip' length 995260 bytes
opened URL
==
downloaded 971Kb


The downloaded packages are in
/tmp/RtmpmAzBwa/downloaded_packages

> library(MASS)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so':
  
dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so,
6): Library not loaded:
/usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
  Referenced from:
/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so
  Reason: image not found
Error: package/namespace load failed for 'MASS'


> sessionInfo()
R version 2.4.1 (2006-12-18)
i386-apple-darwin8.8.1

locale:
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"
"methods"   "base"

other attached packages:
randomForestdprep
"4.5-18""1.0"


> version
   _
platform   i386-apple-darwin8.8.1
arch   i386
os darwin8.8.1
system i386, darwin8.8.1
status
major  2
minor  4.1
year       2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)


Thanks
-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
[EMAIL PROTECTED] 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.


Re: [R] how to reverse a list

2007-04-12 Thread Weiwei Shi
Thanks all of you!

But my next question is, how to improve R programming skills? I never
have time in improving it but I feel I need to.

Regards,

W

On 4/11/07, Seth Falcon <[EMAIL PROTECTED]> wrote:
> "Weiwei Shi" <[EMAIL PROTECTED]> writes:
>
> > I forgot to add my bad solution here:
> >
> > reverseList <- function(xlist){
> >   blist <- xlist[!is.na(xlist)]
> >   x0 <- unlist(blist)
> >   l0 <- length(blist)
> >   d0 <- as.data.frame(matrix(0, l0, 3))
> >   d0[,1] <- names(x0)
> >   d0[,2] <- x0
> >
>
> There is a helper function in Biobase that does this:
>
> reverseSplit
>
>  > reverseSplit
>  function (inList)
>  {
>  lens = sapply(inList, length)
>  nms = rep(names(inList), lens)
>  vals = unlist(inList)
>  split(nms, vals)
>  }
>  
>
> + seth
>
> --
> Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
> http://bioconductor.org
>
> __
> [EMAIL PROTECTED] 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
[EMAIL PROTECTED] 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.


Re: [R] how to reverse a list

2007-04-11 Thread Weiwei Shi
thanks. split() is what I needed.

On 4/11/07, jim holtman <[EMAIL PROTECTED]> wrote:
> try this:
>
> > x <- cbind(unlist(t0), names(t0))
> > x
>   [,1] [,2]
> a "1"  "a"
> b "1"  "b"
> c "2"  "c"
> d "1"  "d"
> > split(x[,2], x[,1])
> $`1`
>   a   b   d
> "a" "b" "d"
>
> $`2`
>   c
> "c"
>
>
>
> On 4/11/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > Hi, there:
> >
> > I am wondering if there is a quick way to "reverse" a list like this:
> >
> > t0 <- list(a=1, b=1, c=2, d=1)
> >
> > reverst t0 to t1
> >
> > > t1
> > $`1`
> > [1] "a" "b" "d"
> >
> > $`2`
> > [1] "c"
> >
> >
> > thanks.
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] how to reverse a list

2007-04-11 Thread Weiwei Shi
I forgot to add my bad solution here:

reverseList <- function(xlist){
  blist <- xlist[!is.na(xlist)]
  x0 <- unlist(blist)
  l0 <- length(blist)
  d0 <- as.data.frame(matrix(0, l0, 3))
  d0[,1] <- names(x0)
  d0[,2] <- x0


  # unique llid
  llid <- unique(d0[,2])
  outlist <- list( )
  for (i in 1:length(llid)) {
each <- llid[i]
probes <- d0[d0[,2]==each, 1]
outlist <-  c(outlist, list(probes))
  }
  names(outlist) <- as.character(llid)
  outlist
}

On 4/11/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Hi, there:
>
> I am wondering if there is a quick way to "reverse" a list like this:
>
> t0 <- list(a=1, b=1, c=2, d=1)
>
> reverst t0 to t1
>
> > t1
> $`1`
> [1] "a" "b" "d"
>
> $`2`
> [1] "c"
>
>
> thanks.
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to reverse a list

2007-04-11 Thread Weiwei Shi
Hi, there:

I am wondering if there is a quick way to "reverse" a list like this:

t0 <- list(a=1, b=1, c=2, d=1)

reverst t0 to t1

> t1
$`1`
[1] "a" "b" "d"

$`2`
[1] "c"


thanks.
-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] treenet

2007-04-03 Thread Weiwei Shi
gbm package if I am right.

On 4/3/07, HelponR <[EMAIL PROTECTED]> wrote:
> Hi, Anybody used treenet here? I downloaded a demo but don't know how to
> start with. Does R has something like treenet? Thanks,
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] help with RandomForest classwt option

2007-01-29 Thread Weiwei Shi
The fifth option:

actually it might be the easiest way:
you "boost" your minority by like 10 fold (just repeat each minority
record 10 times). Then run rf on the boosted sample. The learning
process does not exactly behave like using classwt (setting classwt[2]
= 10 will exactly gives weight=10 in gini calculation), but it is
statistically similar.

Be careful of oob error though. it won't give you a correct estimation
of it since a sample can be used in training while its duplicates
could be used in out-of-bag. But if you care about the splitting, this
approach helps, IMHO.

HTH,

weiwei

On 1/29/07, Betty Health <[EMAIL PROTECTED]> wrote:
> Thank you very much, Weiwei and Jim!
>
> Yeah, I did read the post by Andy, the contributor of this package. It seems
> that classwt is not implemented yet. For Weiwei's options, I have a few more
> questions. Thanks!
>
> "1. try to use rf in fortran by following the linky below
> http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm";
>
> I read the Fortran code briefly. But I did not find the options for down
> sampling. So does that mean I need to do down sampling myself?  Could you
> explain a little more about "2. make a wrapper function to do the down
> sampling by yourself"? You mean I can do it in R or in Fortran? Some links
> plz? I haven't done this before.
>
> Yeah, cut off did change for the final classification results. However from
> what I tried, they did not influence how the nodes are split. So I would go
> further in the above 2 options.
>
> Thank you again!
>
>  Betty
>
>
>
>
> On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > Dear Betty:
> >
> > I could suggest 3 options:
> >
> > 1. try to use rf in fortran by following the linky below
> >
> http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm
> >
> > 2. make a wrapper function to do the down sampling by yourself
> >
> > 3. try to use cutoff in randomForest, which might help in your situation.
> >
> > HTH,
> >
> > weiwei
> >
> > On 1/28/07, Betty Health < [EMAIL PROTECTED]> wrote:
> > > Hello there,
> > >
> > > I am working on an extremely unbalanced two class classification
> problems. I
> > > wanna use "classwt" with "down sampling" together. By checking the
> rfNews()
> > > in R, it looks that classwt is not working yet. Then I looked at the
> > > software from Salford. I did not find the down sampling option.  I am
> > > wondering if you have any experience to deal with this problem. Do you
> know
> > > any method or softwares can handle this problem?
> > >
> > > Thank you very much!!
> > >
> > > Betty
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@stat.math.ethz.ch 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.
> > >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] help with RandomForest classwt option

2007-01-29 Thread Weiwei Shi
Hi, Betty:

1. Fortan code 
(http://www.stat.berkeley.edu/~breiman/RandomForests/cc_examples/prog.f)

if(jclasswt.eq.0) then
do j=1,nclass
classwt(j)=1
enddo
endif
if(jclasswt.eq.1) then
c   fill in classwt(j) for each j:
c   classwt(1)=1.
c   classwt(2)=10.

You need to set the jclasswt = 1 ( you can find by "search" through the codes).
then "uncomment" the last two lines. Here you go with classwt in
fortran. You can use this classwt for extremely-imbalanced
classification problem. Down-sampling is one possible choice for that
too but it is not directly implemented in rf. Check the following
paper, and it might help.
http://oz.berkeley.edu/users/chenchao/666.pdf

2. as to the wrapper function, the idea is that you can create a set
of samples by applying some sampling probilities to implement
down-sampling. Then build a rf model for each sample;
suppose you call rf in this way for each sample,
my.rf <- randomForest(...)

then you can access the oob scores and prediction scores by
my.rf$votes or my.rf$test$votes respectively.

then you can average those scores by yourself, it is just like a
simple meta-learning process but it does exactly what downsampling
plus rf does, though downsampling is not implemented.


3. classwt and cutoff are used at different places. The former is used
at two places: calculating the gini criteria and calculating the final
vote from the leaf. While cutoff is only used in the final voting. So
cutoff won't change the splitting while classwt can. However, since
the current R's rf cannot do classwt, you can try to use cutoff to see
if it helps in your case.

4. The fourth option is you can use my implementation of rf; But I did
not write a manual for that; and it cannot show your splitting yet.

HTH,

weiwei




On 1/29/07, Betty Health <[EMAIL PROTECTED]> wrote:
> Thank you very much, Weiwei and Jim!
>
> Yeah, I did read the post by Andy, the contributor of this package. It seems
> that classwt is not implemented yet. For Weiwei's options, I have a few more
> questions. Thanks!
>
> "1. try to use rf in fortran by following the linky below
> http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm";
>
> I read the Fortran code briefly. But I did not find the options for down
> sampling. So does that mean I need to do down sampling myself?  Could you
> explain a little more about "2. make a wrapper function to do the down
> sampling by yourself"? You mean I can do it in R or in Fortran? Some links
> plz? I haven't done this before.
>
> Yeah, cut off did change for the final classification results. However from
> what I tried, they did not influence how the nodes are split. So I would go
> further in the above 2 options.
>
> Thank you again!
>
>  Betty
>
>
>
>
> On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > Dear Betty:
> >
> > I could suggest 3 options:
> >
> > 1. try to use rf in fortran by following the linky below
> >
> http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm
> >
> > 2. make a wrapper function to do the down sampling by yourself
> >
> > 3. try to use cutoff in randomForest, which might help in your situation.
> >
> > HTH,
> >
> > weiwei
> >
> > On 1/28/07, Betty Health < [EMAIL PROTECTED]> wrote:
> > > Hello there,
> > >
> > > I am working on an extremely unbalanced two class classification
> problems. I
> > > wanna use "classwt" with "down sampling" together. By checking the
> rfNews()
> > > in R, it looks that classwt is not working yet. Then I looked at the
> > > software from Salford. I did not find the down sampling option.  I am
> > > wondering if you have any experience to deal with this problem. Do you
> know
> > > any method or softwares can handle this problem?
> > >
> > > Thank you very much!!
> > >
> > > Betty
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@stat.math.ethz.ch 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.
> > >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] nnet question

2007-01-28 Thread Weiwei Shi
try to use
set.seed(10)
before you call nnet and see if you have the same correlation each time.

I did not try by myself, though.



On 1/28/07, Aimin Yan <[EMAIL PROTECTED]> wrote:
> Hello,
> I use nnet to do prediction for a continuous variable.
> after that, I calculate correlation coefficient between predicted value and
> real observation.
>
> I run my code(see following) several time, but I get different correlation
> coefficient each time.
>
> Anyone know why?
>
> In addition, How to calculate prediction accuracy for prediction of
> continuous variable?
>
> Aimin
> thanks,
>
>
>  > m.nn.omega <- nnet(omega~aa_three+bas+bcu+aa_ss, data=training, size=2,
> linout=TRUE)
> # weights:  57
> initial  value 89153525.582093
> iter  10 value 15036439.951888
> iter  20 value 15010796.121891
> iter  30 value 15000761.804392
> iter  40 value 14955839.294531
> iter  50 value 14934746.564215
> iter  60 value 14933978.758615
> iter  70 value 14555668.381007
> iter  80 value 14553072.231507
> iter  90 value 14031071.223996
> iter 100 value 13709055.312482
> final  value 13709055.312482
> stopped after 100 iterations
>  > pr.nn.train<-predict(m.nn.omega,training)
>  > corr.pr.nn.train<-round(cor(pr.nn.train,training$omega),2)
>  > pr.nn.test<-predict(m.nn.omega,test)
>  > corr.pr.nn.test<-round(cor(pr.nn.test,test$omega),2)
>  > cat("correlation coefficient for train using neural
> network:",corr.pr.nn.train,"\n")
> correlation coefficient for train using neural network: 0.32
>  > cat("correlation coefficient for test using neural
> network:",corr.pr.nn.test,"\n")
> correlation coefficient for test using neural network: 0.39
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] help with RandomForest classwt option

2007-01-28 Thread Weiwei Shi
Dear Betty:

I could suggest 3 options:

1. try to use rf in fortran by following the linky below
http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm

2. make a wrapper function to do the down sampling by yourself

3. try to use cutoff in randomForest, which might help in your situation.

HTH,

weiwei

On 1/28/07, Betty Health <[EMAIL PROTECTED]> wrote:
> Hello there,
>
> I am working on an extremely unbalanced two class classification problems. I
> wanna use "classwt" with "down sampling" together. By checking the rfNews()
> in R, it looks that classwt is not working yet. Then I looked at the
> software from Salford. I did not find the down sampling option.  I am
> wondering if you have any experience to deal with this problem. Do you know
> any method or softwares can handle this problem?
>
> Thank you very much!!
>
> Betty
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] unique/subset problem

2007-01-26 Thread Weiwei Shi
oh, i forgot, you can also convert factor into string like
dataset$genome1 <- as.character(dataset$genome1)

so you don't have to use
as.numeric(dataset$score) if you use "as.is=T" when you read.table

HTH,

weiwei

On 1/26/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> check
> ?read.table
>
> and add "as.is=T" in the option. So you read string as character now
> and avoid the factor things.
>
> Then repeat your work.
>
> For example
> > x0 <- read.table("~/Documents/tox/noodles/four_sheets_orig/reg_r2.txt", 
> > sep="\t", nrows=10)
> > str(x0,1)
> `data.frame':   10 obs. of  7 variables:
>  $ V1: Factor w/ 10 levels "-4086733916",..: 10 9 8 7 6 5 4 3 2 1
>  $ V2: Factor w/ 10 levels "-1963744741",..: 10 8 7 4 5 6 3 9 1 2
>  $ V3: Factor w/ 7 levels "-1687428658",..: 7 4 4 2 5 1 6 6 3 4
>  $ V4: Factor w/ 2 levels "5","MECHANISM": 2 1 1 1 1 1 1 1 1 1
>  $ V5: Factor w/ 2 levels "0","TYPE": 2 1 1 1 1 1 1 1 1 1
>  $ V6: Factor w/ 2 levels "USER_","alexey": 1 2 2 2 2 2 2 2 2 2
>  $ V7: Factor w/ 2 levels "3","TRUST": 2 1 1 1 1 1 1 1 1 1
> > x0 <- read.table("~/Documents/tox/noodles/four_sheets_orig/reg_r2.txt", 
> > sep="\t", nrows=10, as.is=T)
> > str(x0,1)
> `data.frame':   10 obs. of  7 variables:
>  $ V1: chr  "LINK_ID" "-4293537751" "-4247422653" "-4223137153" ...
>  $ V2: chr  "ID1" "65259" "1020286" "-518245428" ...
>  $ V3: chr  "ID2" "6436" "6436" "-2099509019" ...
>  $ V4: chr  "MECHANISM" "5" "5" "5" ...
>  $ V5: chr  "TYPE" "0" "0" "0" ...
>  $ V6: chr  "USER_" "alexey" "alexey" "alexey" ...
>  $ V7: chr  "TRUST" "3" "3" "3" ...
>
> HTH,
>
> weiwei
>
> On 1/26/07, lalitha viswanath <[EMAIL PROTECTED]> wrote:
> > Hi
> > I read in my dataset using
> > dt  > calling unique(levels(dt$genome1))  yields the
> > following
> >
> >  "aero"  "aful"  "aquae" "atum_D"
> > "bbur"  "bhal"  "bmel"  "bsub"
> >  [9] "buch"  "cace"  "ccre"  "cglu"
> > "cjej"  "cper"  "cpneuA""cpneuC"
> > [17] "cpneuJ""ctraM" "ecoliO157" "hbsp"
> > "hinf"  "hpyl"  "linn"  "llact"
> > [25] "lmon"  "mgen"  "mjan"  "mlep"
> > "mlot"  "mpneu" "mpul"  "mthe"
> > [33] "mtub"  "mtub_cdc"  "nost"  "pabyssi"
> > "paer"  "paero" "pmul"  "pyro"
> > [41] "rcon"  "rpxx"  "saur_mu50" "saur_n315"
> > "sent"  "smel"  "spneu" "spyo"
> > [49] "ssol"  "stok"  "styp"  "synecho"
> > "tacid" "tmar"  "tpal"  "tvol"
> > [57] "uure"  "vcho"  "xfas"  "ypes"
> >
> > It shows 60 genomes, which is correct.
> >
> > I extracted a subset as follows
> > possible_relatives_subset <- subset(dt, Y < -5)
> > I am pasting the results below
> >  genome1   genome2 parameterX  Y
> > 21   sent ecoliO157  0.00590 -200.633493
> > 22   sent  paer  0.18603 -100.200570
> > 27   styp ecoliO157  0.00484 -240.708645
> > 28   styp  paer  0.18497 -30.250127
> > 41   paer  sent  0.18603 -60.200570
> > 44   paer  styp  0.18497 -80.250127
> > 49   paer  hinf  0.18913 -90.056333
> > 53   paer  vcho  0.18703 -10.153929
> > 55   paer  pmul  0.18587 -100.208042
> > 67   paer  buch  0.21485  -80.898667
> > 70   paer  ypes  0.18460 -107.267454
> > 82   paer  xfas  0.26268  -61.920552
> > 95   hinf ecoliO157  0.07654 -163.018417
> > 96   hinf  paer  0.18913 -10.056333
> > 103  vcho ecoliO157  0.09518 -140.921153
> > 104  vcho  paer  0.18703 -10.153929
>

Re: [R] unique/subset problem

2007-01-26 Thread Weiwei Shi
  xfas ecoliO157  0.25833  -75.091552
> 218  xfas  paer  0.26268  -64.920552
>
> I think  even a cursory look will tell us that there
> are not as many unique genomes in the subset results.
> (around 8/10).
> However when I do
> unique(levels(possible_relatives_subset$genome1)), I
> get
>
> [1] "aero"  "aful"  "aquae" "atum_D"
> "bbur"  "bhal"  "bmel"  "bsub"
>  [9] "buch"  "cace"  "ccre"  "cglu"
> "cjej"  "cper"  "cpneuA""cpneuC"
> [17] "cpneuJ""ctraM" "ecoliO157" "hbsp"
> "hinf"  "hpyl"  "linn"  "llact"
> [25] "lmon"  "mgen"  "mjan"  "mlep"
> "mlot"  "mpneu" "mpul"  "mthe"
> [33] "mtub"  "mtub_cdc"  "nost"  "pabyssi"
> "paer"  "paero" "pmul"  "pyro"
> [41] "rcon"  "rpxx"  "saur_mu50" "saur_n315"
> "sent"  "smel"  "spneu" "spyo"
> [49] "ssol"  "stok"  "styp"  "synecho"
> "tacid" "tmar"  "tpal"  "tvol"
> [57] "uure"  "vcho"  "xfas"  "ypes"
>
> Where am I going wrong?
> I tried calling unique without the levels too, which
> gives me the following response
>
> [1] sent  styp  paer  hinf  vcho
> pmul  buch  ypes  ecoliO157 xfas
> 60 Levels: aero aful aquae atum_D bbur bhal bmel bsub
> buch cace ccre cglu cjej cper cpneuA ... ypes
>
> --- Weiwei Shi <[EMAIL PROTECTED]> wrote:
>
> > Then you need to provide more details about the
> > calls you made and your dataset.
> > For example, you can tell us by
> > str(prunedrelatives, 1)
> >
> > how did you call unique on prunedrelative and so on?
> > I made a test
> > data it gave me what you wanted (omitted here).
> >
> > On 1/26/07, lalitha viswanath
> > <[EMAIL PROTECTED]> wrote:
> > > Hi
> > > The pruned dataset has 8 unique genomes in it
> > while
> > > the dataset before pruning has 65 unique genomes
> > in
> > > it.
> > > However calling unique on the pruned dataset seems
> > to
> > > return 65 no matter what.
> > >
> > > Any assistance in this matter would be
> > appreciated.
> > >
> > > Thanks
> > > Lalitha
> > > --- Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > >
> > > > Hi,
> > > >
> > > > Even you removed "many" genomes1 by setting
> > score<
> > > > -5; it is not
> > > > necessary saying you changed the uniqueness.
> > > >
> > > > To check this, you can do like
> > > > p0 <- unique(dataset[dataset$score< -5,
> > "genome1"])
> > > > # same as subset
> > > > p1 <- unique(dataset[dataset$score>= -5,
> > "genome1"])
> > > >
> > > > setdiff(p1, p0)
> > > >
> > > > if the output above has NULL, then it means even
> > > > though you remove
> > > > many genomes1, but it does not help changing the
> > > > uniqueness.
> > > >
> > > > HTH,
> > > >
> > > > weiwei
> > > >
> > > >
> > > >
> > > > On 1/25/07, lalitha viswanath
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > Hi
> > > > > I am new to R programming and am using subset
> > to
> > > > > extract part of a data as follows
> > > > >
> > > > > names(dataset) =
> > > > > c("genome1","genome2","dist","score");
> > > > > prunedrelatives <- subset(dataset, score <
> > -5);
> > > > >
> > > > > However when I use unique to find the number
> > of
> > > > unique
> > > > > genomes now present in prunedrelatives I get
> > > > results
> > > > > identical to calling unique(dataset$genome1)
> > > > although
> > > > > subset has eliminated many genomes and
> > records.
> > > > >
> > > > > I would greatly appreciate your input about
> > using
> > > > > "unique" correctly  in this regard.
> > > > >
> > > > > Thanks
> > > > > Lalitha
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> 
> > > > > TV dinner still cooling?
> > > > > Check out "Tonight's Picks" on Yahoo! TV.
> > > > >
> > > > > __
> > > > > R-help@stat.math.ethz.ch 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.
> > > > >
> > > >
> > > >
> > > > --
> > > > Weiwei Shi, Ph.D
> > > > Research Scientist
> > > > GeneGO, Inc.
> > > >
> > > > "Did you always know?"
> > > > "No, I did not. But I believed..."
> > > > ---Matrix III
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> 
> > > Bored stiff? Loosen up...
> > > Download and play hundreds of games for free on
> > Yahoo! Games.
> > > http://games.yahoo.com/games/front
> > >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
>
>
>
>
> 
> We won't tell. Get more on shows you hate to love
> (and love to hate): Yahoo! TV's Guilty Pleasures list.
> http://tv.yahoo.com/collections/265
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Why do return or visible don´t return my obj ekt?

2007-01-26 Thread Weiwei Shi
?invisible

if you return in this function with invisible, then you need to assign like this
> x0 <- lapply(1:3, function(i) (c("0","1")))
> names(x0) <- c("a", "b", "c")
> x0
$a
[1] "0" "1"

$b
[1] "0" "1"

$c
[1] "0" "1"

> x1 <- lapply(1:3, function(i) (c("2","3")))
> names(x1) <- c("a", "b", "c")

> x2 <- interleave(x0, x1)
> x2
$a
[1] "0" "1" "2" "3"

$b
[1] "0" "1" "2" "3"

$c
[1] "0" "1" "2" "3"


otherwise, you need to remove invisible when you return, like this
> interleave(x0, x1)
$a
[1] "0" "1" "2" "3"

$b
[1] "0" "1" "2" "3"

$c
[1] "0" "1" "2" "3"

then you also assign like x2 <- interleave(x0, x1)

HTH,

weiwei

On 1/26/07, Christoph Heibl <[EMAIL PROTECTED]> wrote:
> Dear Rlist!
>
> I´ve got two lists which contain sets of DNA-sequences. They look
> something like this:
>
> List of 33
> $ Cunonia_atrorubens : chr [1:247] "t" "t" "n" "t" ...
> $ Cunonia_balansae   : chr [1:254] "t" "c" "c" "c" ...
> $ Cunonia_capensis   : chr [1:236] "v" "t" "c" "c" ...
> $ Cunonia_macrophylla: chr [1:236] "t" "t" "a" "t" ...
> $ Pancheria_engleriana   : chr [1:315] "c" "t" "c" "c" ...
> []
> $ Brunellia_colombiana   : chr [1:336] "t" "t" "c" "t" ...
> $ Brunellia_oliveri  : chr [1:368] "t" "a" "a" "t" ...
> $ Bauera_rubioides   : chr [1:276] "t" "c" "t" "c" ...
> $ Bauera_sessiliflora: chr [1:332] "t" "c" "t" "c" ...
> $ Davidsonia_pruriens_var._jeryseyana: chr [1:300] "t" "t" "c" "t" ...
> $ Davidsonia_sp._'johnsonii' : chr [1:268] "c" "c" "c" "t" ...
> - attr(*, "species")= chr [1:33] "Cunonia_atrorubens"
> "Cunonia_balansae" "Cunonia_capensis" "Cunonia_macrophylla" ...
>
>
> The names of each entry in first list match exactly the names of the
> entries in the second list and both list contain the same number of
> sequences (although not of the same length)
> I want to concatenate these sequences by the following function:
>
> interleave <- function(seq1, seq2)
> {
> #create a list to contain concatenated sequences
>     sequence <- list()
> for (name in names(seq1))   # get names as indices
> {
> # concatenate sequences
> sequence[[name]] <- c(seq1[[name]], seq2[[name]])
> }
> # return concatenated sequences
> invisible(sequence)
> }
>
> I guess the function works in principle, because they commands do so
> if I enter them step by step.
> But when I call the function it does not return my object "sequence".
> But why?
> (This happened to me with some functions that I wrote, but not all.
> The error seems quite erratic : ) to me and I can´t figure out what
> to change)
>
> Thanks a lot in advance!
>
> Christoph
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] unique/subset problem

2007-01-26 Thread Weiwei Shi
Then you need to provide more details about the calls you made and your dataset.
For example, you can tell us by
str(prunedrelatives, 1)

how did you call unique on prunedrelative and so on? I made a test
data it gave me what you wanted (omitted here).

On 1/26/07, lalitha viswanath <[EMAIL PROTECTED]> wrote:
> Hi
> The pruned dataset has 8 unique genomes in it while
> the dataset before pruning has 65 unique genomes in
> it.
> However calling unique on the pruned dataset seems to
> return 65 no matter what.
>
> Any assistance in this matter would be appreciated.
>
> Thanks
> Lalitha
> --- Weiwei Shi <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > Even you removed "many" genomes1 by setting score<
> > -5; it is not
> > necessary saying you changed the uniqueness.
> >
> > To check this, you can do like
> > p0 <- unique(dataset[dataset$score< -5, "genome1"])
> > # same as subset
> > p1 <- unique(dataset[dataset$score>= -5, "genome1"])
> >
> > setdiff(p1, p0)
> >
> > if the output above has NULL, then it means even
> > though you remove
> > many genomes1, but it does not help changing the
> > uniqueness.
> >
> > HTH,
> >
> > weiwei
> >
> >
> >
> > On 1/25/07, lalitha viswanath
> > <[EMAIL PROTECTED]> wrote:
> > > Hi
> > > I am new to R programming and am using subset to
> > > extract part of a data as follows
> > >
> > > names(dataset) =
> > > c("genome1","genome2","dist","score");
> > > prunedrelatives <- subset(dataset, score < -5);
> > >
> > > However when I use unique to find the number of
> > unique
> > > genomes now present in prunedrelatives I get
> > results
> > > identical to calling unique(dataset$genome1)
> > although
> > > subset has eliminated many genomes and records.
> > >
> > > I would greatly appreciate your input about using
> > > "unique" correctly  in this regard.
> > >
> > > Thanks
> > > Lalitha
> > >
> > >
> > >
> > >
> >
> 
> > > TV dinner still cooling?
> > > Check out "Tonight's Picks" on Yahoo! TV.
> > >
> > > __
> > > R-help@stat.math.ethz.ch 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.
> > >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
>
>
>
>
> 
> Bored stiff? Loosen up...
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] enumerates all possible combinations

2007-01-26 Thread Weiwei Shi
a little improvement on ken knoblauch's method by adding the variable n

so,

n <- 3
expand.grid(lapply(1:n, function(i) (c(0,1

HTH,

weiwei


On 1/26/07, Zhiliang Ma <[EMAIL PROTECTED]> wrote:
> Hi all R users,
> I want to create a matrix having n columns and 2^n rows, and all its entries
> are only 0 or 1. In each row, column i is 0 means dimension i is chosen, 0
> means not.  The matrix will contains all the possible combination of those n
> dimensions.
>
> Here is an example, if n = 3, the matrix will look like:
> 0 0 0
> 0 0 1
> 0 1 0
> 1 0 0
> 0 1 1
> 1 0 1
> 1 1 1
>
>
> I know I can use n "for" loops to do this, but is there a better way?
> Thanks,
> -zm
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] unique/subset problem

2007-01-25 Thread Weiwei Shi
Hi,

Even you removed "many" genomes1 by setting score< -5; it is not
necessary saying you changed the uniqueness.

To check this, you can do like
p0 <- unique(dataset[dataset$score< -5, "genome1"]) # same as subset
p1 <- unique(dataset[dataset$score>= -5, "genome1"])

setdiff(p1, p0)

if the output above has NULL, then it means even though you remove
many genomes1, but it does not help changing the uniqueness.

HTH,

weiwei



On 1/25/07, lalitha viswanath <[EMAIL PROTECTED]> wrote:
> Hi
> I am new to R programming and am using subset to
> extract part of a data as follows
>
> names(dataset) =
> c("genome1","genome2","dist","score");
> prunedrelatives <- subset(dataset, score < -5);
>
> However when I use unique to find the number of unique
> genomes now present in prunedrelatives I get results
> identical to calling unique(dataset$genome1) although
> subset has eliminated many genomes and records.
>
> I would greatly appreciate your input about using
> "unique" correctly  in this regard.
>
> Thanks
> Lalitha
>
>
>
> 
> TV dinner still cooling?
> Check out "Tonight's Picks" on Yahoo! TV.
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] n step ahead forecasts

2007-01-24 Thread Weiwei Shi
Dear Spencer:

just my2cent:
could you change the step from 1 to m, like 5 if you have a very large
validation set. I have a feeling that it won't change too much about
the result but I am not sure what your endpoint is.

weiwei

On 1/24/07, sj <[EMAIL PROTECTED]> wrote:
> hello,
>
> I have a question about making n step ahead forecasts in cases where test
> and validation sets are availiable. For instance, I would like to make one
> step ahead forecasts  on the  WWWusage data so I hold out the last 10
> observations as the validation set and fit an ARIMA model on the first 90
> observations. I then use a for loop to sequentially add 9 of the holdout
> observations to make 1 step ahead forecasts for the last 10 periods (see
> example code). In cases where there are relatively few periods I want to
> forecast for this seems to work fine, however I am working with a rather
> large validation set and I need to make n step ahead forecasts for many
> periods and it takes a very long time. Is there a more efficient way to do
> this?
>
>
>
> vset <- WWWusage[91:100]
>
> pred <-c()
> for (i in 0:9)
> { fit <-arima(WWWusage[1:(90+i)],c(3,1,0))
>   p<- predict(fit,se.fit=F)
>   pred <- c(pred, p)
> }
> plot(pred,type="o",col=2)
> lines(vset,type="o",col=1)
>
>
> thanks,
>
> Spencer
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Cronbach's alpha

2007-01-24 Thread Weiwei Shi
Hi, there:

I read that article (thanks Chucks, etc to point that out). Now I
understand how those negatives are generated since my research subject
"should" have negative convariance but they "are" measuring the same
thing. So, I am confused about this "same" thing and about if it is
proper to go ahead to use this measurement.

To clear my point , I describe my idea here a little bit. My idea is
to look for a way to assign a "statistic" or measurement to a set of
variables to see if they "act" cohesively or coherently for an event.
Instead of using simple correlation, which describes var/var
correlation; I wanted to get a "total correlation" so that I can
compare between setS of variables. Initially I "made" that word but
google helps me find that statistic exists! So I read into it and post
my original post on "total correlation". (Ben, you can find total
correlation from wiki).

I was suggested to use this alpha since it measures a "one latent
construct", in which matches my idea about one event. I have a feeling
it is like factor analysis; however, the grouping of variables has
been fixed by domain knowledge.

Sorry if it is off-list topic but I feel it is very interesting to go ahead.

Thanks,

Weiwei



On 1/24/07, Doran, Harold <[EMAIL PROTECTED]> wrote:
> Hi Dave
>
> We had a bit of an off list discussion on this. You're correct, it can
> be negative IF the covariance among individual items is negative AND if
> that covariance term is larger than the sum of the individual item
> variances. Both of these conditions would be needed to make alpha go
> negative.
>
> Psychometrically speaking, this introduces some question as to whether
> the items are measuring the same latent trait. That is, if there is a
> negative covariance among items, but those items are thought to measure
> a common trait, then (I'm scratching my head) I think we have a
> dimensionality issue.
>
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Dave Atkins
> > Sent: Wednesday, January 24, 2007 4:08 PM
> > To: R-help@stat.math.ethz.ch
> > Subject: Re: [R] Cronbach's alpha
> >
> >
> > Harold & Weiwei--
> >
> > Actually, alpha *can* go negative, which means that items are
> > reliably different as opposed to reliably similar.  This
> > happens when the sum of the covariances among items is
> > negative.  See the ATS site below for a more thorough explanation:
> >
> > http://www.ats.ucla.edu/STAT/SPSS/library/negalpha.htm
> >
> > Hope that helps.
> >
> > cheers, Dave
> > --
> > Dave Atkins, PhD
> > Assistant Professor in Clinical Psychology Fuller Graduate
> > School of Psychology
> > Email: [EMAIL PROTECTED]
> > Phone: 626.584.5554
> >
> >
> > Weiwei
> >
> > Something is wrong. Coefficient alpha is bounded between 0 and 1, so
> > negative values are outside the parameter space for a reliability
> > statistic. Recall that reliability is the ratio of "true
> > score" variance
> > to "total score variance". That is
> >
> > var(t)/ var(t) + var(e)
> >
> > If all variance is true score variance, then var(e)=0 and the
> > reliability is var(t)/var(t)=1. On the other hand, if all variance is
> > measurement error, then var(t) = 0 and reliability is 0.
> >
> > Here is a function I wrote to compute alpha along with an
> > example. Maybe
> > try recomputing your statistic using this function and see if you get
> > the same result.
> >
> > alpha <- function(columns){
> >   k <- ncol(columns)
> >   colVars <- apply(columns, 2, var)
> >   total   <- var(apply(columns, 1, sum))
> >   a <- (total - sum(colVars)) / total * (k/(k-1))
> >   a
> >   }
> >
> > data(LSAT, package='ltm')
> >  > alpha(LSAT)
> > [1] 0.2949972
> >
> >
> > Harold
> >
> >  > -Original Message-
> >  > From: r-help-bounces at stat.math.ethz.ch
> >  > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> > Weiwei Shi
> >  > Sent: Wednesday, January 24, 2007 1:17 PM
> >  > To: R R
> >  > Subject: [R] Cronbach's alpha
> >  >
> >  > Dear Listers:
> >  >
> >  > I used cronbach{psy} to evaluate the internal consistency and
> >  > some set of variables gave me alpha=-1.1003, while other,
> >  > alpha=-0.2; alpha=0.89; and so on. I am interested in knowing
> >  > how to interpret 1. negativ

[R] Cronbach's alpha

2007-01-24 Thread Weiwei Shi
Dear Listers:

I used cronbach{psy} to evaluate the internal consistency and some set
of variables gave me alpha=-1.1003, while other, alpha=-0.2;
alpha=0.89; and so on. I am interested in knowing how to interpret
1. negative value
2. negative value less than -1.

I also want to re-mention my previous question about how to evaluate
the consistency of a set of variables and about the total correlation
(my 2 cent to answer the question). Is there any function in R to do
that?

Thank you very much!



-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] total correlation

2007-01-23 Thread Weiwei Shi
Hi, there:

I have an idea and it needs to calculate "total correlation" for a set
of variables, because I need to evalate how cohesive or related a
group of variables are (If someone knows other ways to do that, please
be advised! thanks!). After searching the archives and googling, I
just two related functions entropy and entropy.joint while the latter
only deals with two variables.

So, I am wondering if I miss something here during my search (btw, I
am not very good at searching so sometimes I posted some questions
which are simple by searching).

BTW, if there are functions not only dealing with discrete but also
with continuous ones, it will be great !

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Installing packages...

2007-01-23 Thread Weiwei Shi
why not just type in console:
install.packages("neural")

and see what happens.



On 1/23/07, Nüzhet Dalfes <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am a total newbie to R. I am using R (2.4.1) on Mac OS X 10.4.8 and
> trying to install some packages using GUI Packages & Data/Package Installer
> interface...
>
> Every time I get:
>
> trying URL
> 'http://umfragen.sowi.uni-mainz.de/CRAN/bin/macosx/universal/contrib/2.4/neural_1.4.1.tgz'
> Content type 'application/x-tar' length 18920 bytes
> opened URL
> ==
> downloaded 18Kb
>
> Error in gzfile(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open compressed file 'neural/DESCRIPTION'
> >
>
> What am I doing wrong?
>
> Any help will be much appreciated.
>
> Nüzhet Dalfes
>
> Istanbul Tech. Univ.
>
>
> __
> R-help@stat.math.ethz.ch 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.
>
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] which classification package in R can assign sample weight?

2007-01-23 Thread Weiwei Shi
Just checked
?lrm
?nnet
?rpart
?ppr

thanks.

but wondering if the last one can do classification?


On 1/23/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> Almost all methods I know of do: logistic regression, neural nets,
> classification trees, PPR 
>
> Have you looked at the help pages for any of these?
>
> On Tue, 23 Jan 2007, Weiwei Shi wrote:
>
> > Hi,
> >
> > I am looking for some function implemented in R for classification,
> > which has an option to allow me to assign sample weights in learning
> > process? Implementation of a wrapper function is possible but I am
> > curious if it already exists somewhere.
> >
> > Thanks,
> >
> >
>
> --
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road,         +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] which classification package in R can assign sample weight?

2007-01-23 Thread Weiwei Shi
Hi,

I am looking for some function implemented in R for classification,
which has an option to allow me to assign sample weights in learning
process? Implementation of a wrapper function is possible but I am
curious if it already exists somewhere.

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] logistic regression model + Cross-Validation

2007-01-22 Thread Weiwei Shi
why not use lda{MASS} and it has cv=T option; it does "loo", though.
Or use randomForest.

if you have to use lrm, then the following code might help:

n.fold <- 5 # 5-fold cv
n.sample <- 50 # assumed 50 samples
s <- sample(1:n.fold, size=n.sample, replace=T)
for (i in 1:n.fold){
  # create your training data and validation data for each fold
  trn <- YOURWHOLEDATAFRAME[s!=i,]
  val <- YOURWHOLEDATAFRAME[s==i,]
  # now do your own modeling using lrm
  # todo
}

HTH,

weiwei

On 1/21/07, nitin jindal <[EMAIL PROTECTED]> wrote:
> If validate.lrm does not has this option, do any other function has it.
> I will certainly look into your advice on cross validation. Thnx.
>
> nitin
>
> On 1/21/07, Frank E Harrell Jr <[EMAIL PROTECTED]> wrote:
> >
> > nitin jindal wrote:
> > > Hi,
> > >
> > > I am trying to cross-validate a logistic regression model.
> > > I am using logistic regression model (lrm) of package Design.
> > >
> > > f <- lrm( cy ~ x1 + x2, x=TRUE, y=TRUE)
> > > val <- validate.lrm(f, method="cross", B=5)
> >
> > val <- validate(f, ...)# .lrm not needed
> >
> > >
> > > My class cy has values 0 and 1.
> > >
> > > "val" variable will give me indicators like slope and AUC. But, I also
> > need
> > > the vector of predicted values of class variable "cy" for each record
> > while
> > > cross-validation, so that I can manually look at the results. So, is
> > there
> > > any way to get those probabilities assigned to each class.
> > >
> > > regards,
> > > Nitin
> >
> > No, validate.lrm does not have that option.  Manually looking at the
> > results will not be easy when you do enough cross-validations.  A single
> > 5-fold cross-validation does not provide accurate estimates.  Either use
> > the bootstrap or repeat k-fold cross-validation between 20 and 50 times.
> >   k is often 10 but the optimum value may not be 10.  Code for averaging
> > repeated cross-validations is in
> > http://biostat.mc.vanderbilt.edu/twiki/pub/Main/RmS/logistic.val.pdf
> > along with simulations of bootstrap vs. a few cross-validation methods
> > for binary logistic models.
> >
> > Frank
> > --
> > Frank E Harrell Jr   Professor and Chair   School of Medicine
> >   Department of Biostatistics   Vanderbilt University
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] naive bayes help

2007-01-19 Thread Weiwei Shi
change the last line
m.pr<-predict(mydt.nb, mydata[,-1], type="class")

into
m.pr<-predict(mydt.nb, mydata[,-1], type="raw")

see
?naiveBayes
and
?predict.naiveBayes

Your "y" is a continous dependent variable.

HTH,


weiwei


On 1/19/07, leah martell <[EMAIL PROTECTED]> wrote:
>  Hello
>
> I have a rather simple code and for some reason it produces an error
> message.  If someone can tell me why and how to fix it, I would be very
> greatful. Thank you in advance.
>
>
> # create data
> set.seed(10)
> n <- 200 # number of training points
> n.test <- 200   # number of test points
> p<-2# dimension of input space
> z <- matrix(rnorm((n+n.test)*p),ncol=p)
> x <- matrix(0,nrow=n+n.test,ncol=p)
> for (i in 1:p)
>   x[,i] <- z%*%rnorm(p)
> truecoef <- c(1,2)
> prob1 <- exp(x%*%truecoef)/(1+exp(x%*%truecoef))
> # prob is the true probability of class 1
> y <- rbinom(n+n.test,1,prob1)
> # separate the data into train and test sets
> mydata <- data.frame(y=y[1:n],x=x[1:n,])
> mydata.test <- data.frame(y=y[n+(1:n.test)],x=x[n+(1: n.test),])
> ##
> library(e1071)
> mydt.nb<-naiveBayes(y~ ., data=mydata)
> m.pr<-predict(mydt.nb, mydata[,-1], type="class")
>
>
> regards,
> Leah
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Help on variable ranking

2007-01-17 Thread Weiwei Shi
I suggest using permutation on each predictor and see how much the
accuracy drops, no matter what modeling approach you used.


HTH,

weiwei

On 1/17/07, Rupendra Chulyadyo <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I want to assign relative score to the predictor variables on the basis of
> its influence on the dependent variable. But I could not find any standard
> statistical approach appropriate for this purpose.
> Please suggest the possible approaches.
>
> Thanks in advance,
>
> Rupendra Chulyadyo
> Institute of Engineering,
> Tribhuvan University,
> Nepal
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] number of Nodes in Random Forest

2007-01-16 Thread Weiwei Shi
Hi, Goncalo:

did u use compounds as features when building rf? If so, some
compounds are NOT randomly selected in splitting nodes, which might
explain what you observed. But you need to provide more info for us to
help you, like those parameters you used to build rf.

You can use varImpPlot to see what exactly compounds were used by
setting n.var (see ?varImpPlot) or you can use
nrow(YourTrainingX$importance) to get that number too.

HTH,

w.

On 1/16/07, Gonçalo Carrera <[EMAIL PROTECTED]> wrote:
> I'm calculating nodes using Random Forest in R but i only get nodes for a
> fraction of the compounds i want to calculate, the rest is ommited and is not
> printed in the output file, (i'm working with 3012 compounds). What can i do 
> to
> have nodes printed for all the compounds. Thanks
>
> Gonçalo
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] creating a list of lists

2007-01-07 Thread Weiwei Shi
change
 forests <- c(forests, forest);
into
 forests[[level]] <- forest



On 1/6/07, Paul Boutros <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm trying to create a series of randomForest objects, basically in a
> loop like this:
>
> forests <- list();
>
> for (level in 1:10) {
>
>   # do some other things here
>
> # create a random forest
> forest <- randomForest(
> x = x.level,
> y = z.level,
> ntree = trees
> );
>
> forests <- c(forests, forest);
>
> }
>
>
> But instead of creating a list of 10 forests, this creates a list of
> 180 elements, 18 for each forest.  Is there a way to create a list of
> randomForest objects for use later on in code like:
>
> for (forest in forests) {
>  values <- predict(forest, data);
>  # do things with these predicted values
>  }
>
> Sincerely,
> Paul
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] memory limits in R loading a dataset and using the package tree

2007-01-05 Thread Weiwei Shi
IMHO, R is not good at really large-scale data mining, esp. when the
algorithm is complicated. The alternatives are
1. sampling your data; sometimes you really do not need that large
number of records and the accuracy might already be good enough when
you load less.

2. find an alternative (commercial software) to do this job if you
really need to load all.

3. make a wrapper function, sampling your data and load it into R and
build model and repeat this process until you get n models. Then you
can do like meta-learning or simply majority-win if your problem is
classification.

HTH,

On 1/4/07, domenico pestalozzi <[EMAIL PROTECTED]> wrote:
> I think the question is discussed in other thread, but I don't exactly find
> what I want .
> I'm working in Windows XP with 2GB of memory and a Pentium 4 - 3.00Ghx.
> I have the necessity of working with large dataset, generally from 300,000
> records to 800,000 (according to the project), and about 300 variables
> (...but a dataset with 800,000 records could not be "large" in your
> opinion...). Because of we are deciding if R will be the official software
> in our company, I'd like to say if the possibility of using R with these
> datasets depends only by the characteristics of the "engine" (memory and
> processor).
> In this case we can improve the machine (for example, what memory you
> reccomend?).
>
> For example, I have a dataset of 200,000 records and 211 variables but I
> can't load the dataset because R doesn't work : I control the loading
> procedure (read.table in R) by using the windows task-manager and R is
> blocked when the file paging is 1.10 GB.
> After this I try with a sample of 100,000 records and I can correctly load
> tha dataset, but I'd like to use the package tree, but after some seconds (
> I use this tree(variable1~., myDataset) )   I obtain the message "Reached
> total allocation of 1014Mb".
>
> I'd like your opinion and suggestion, considering that I could improve (in
> memory) my computer.
>
> pestalozzi
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] randomForest and missing data

2007-01-04 Thread Weiwei Shi
You can try randomForest in Fortran codes, which has that function
doing missing replacement automatically. There are two ways of
imputations (one is fast and the other is time-consuming) to do that.
I did it long time ago.

the link is below. If you have any question, just let me know.
http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm

In principle, each individual tree is NOT a cart tree since each
splitting predictor is randomly selected. In my impression, rf is more
like nearest neighbor algorithm. The surrogation is NOT used in rf
implementation. That's "why" you have to impute it before using it;
while the imputation is not implemented in r-version, in my best
knowledge.
You can check that from reading the original technical report or some
presentation by original authors. I remember there was some slide
comparing rf and CART somewhere.


HTH,

weiwei

On 1/4/07, Darin A. England <[EMAIL PROTECTED]> wrote:
>
> Does anyone know a reason why, in principle, a call to randomForest
> cannot accept a data frame with missing predictor values? If each
> individual tree is built using CART, then it seems like this
> should be possible. (I understand that one may impute missing values
> using rfImpute or some other method, but I would like to avoid doing
> that.)
>
> If this functionality were available, then when the trees are being
> constructed and when subsequent data are put through the forest, one
> would also specify an argument for the use of surrogate rules, just
> like in rpart.
>
> I realize this question is very specific to randomForest, as opposed
> to R in general, but any comments are appreciated. I suppose I am
> looking for someone to say "It's not appropriate, and here's why
> ..." or "Good idea. Please implement and post your code."
>
> Thanks,
>
> Darin England, Senior Scientist
> Ingenix
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] CV by rpart/mvpart

2006-12-28 Thread Weiwei Shi
n-fold cv is easy to be implemented in R by yourself. you can create
10 folds' samples by yourself and disable cv in rpart. Then you can
use the same sample sets to compare different methods.

HTH

weiwei

On 12/28/06, Pedro Ramirez <[EMAIL PROTECTED]> wrote:
> Dear R-list,
>
> I am using the rpart/mvpart-package for selecting a right-sized regression 
> tree by 10-fold cross-validation. My question: Is there a possibility to find 
> out for every observation in which of the ten folds it is lying? I want to 
> use the same folds for validating another regression method (moving averages) 
> in order to choose the better one.
>
> Thanks a lot,
> Pedro
>
>
> -
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] sapply problem

2006-12-14 Thread Weiwei Shi
> c <- apply(b, c(1,2), unlist)
> c
 A B C
[1,] 1 2 3
[2,] 4 5 6
> class(c[1,1])
[1] "numeric"


On 12/14/06, Joerg van den Hoff <[EMAIL PROTECTED]> wrote:
> I have encountered the following problem: I need to extract from
> a list of lists equally named compenents who happen to be 'one row'
> data frames. a trivial example would be:
>
> a <- list(list(
> df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 
> 6)))
>
> I want the extracted compenents to fill up a matrix or data frame row by row.
> the obvious thing to do seems:
>
> b <- sapply(a, "[[", "df")
> b <- t(b)
>
> now `b' looks all right:
>
> b
> class(b)
>
> but it turns out that all elements in this matrix are one element lists:
>
> class(b[1,1])
>
> which prevents any further standard processing of `b' (like `colMeans', e.g.)
>
> question 1: is their a straightforward way to enforce that `b' contains
> simple numbers as elements right from the start (instead of something like
> apply(b, 1:2, "class<-", "numeric") afterwards)?
>
> question 2: should not sapply do this further 'simplification' anyway in a 
> situation
> like this (matrix elements turn out to be one-element lists)?
>
> regards
>
> joerg
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] implementation of t.test

2006-12-12 Thread Weiwei Shi
I think what i want is code in C or Java.  But thanks though.

On 12/11/06, Charles C. Berry <[EMAIL PROTECTED]> wrote:
> On Mon, 11 Dec 2006, Weiwei Shi wrote:
>
> > Hi, there:
> >
> > for some reason, I need to look at t.test at coding level. Can anyone
> > here suggest a place to start with?
>
> You mean how to read the code??
>
> Like this:
>
> > t.test # print the function
> function (x, ...)
> UseMethod("t.test")
> 
> > # that told me 't.test' has S3 methods
> > methods(t.test)
> [1] t.test.default* t.test.formula*
>
> Non-visible functions are asterisked
> > # that told me what they were
> > # and that I need ':::' to see them
> > page(stats:::t.test.default,"print")
> > page(stats:::t.test.formula,"print")
> > # looks like you want to study t.test.default
>
> see
> ?methods
> ?":::"
>
> HTH
>
> > [...]
>
> Charles C. Berry(858) 534-2098
>       Dept of Family/Preventive Medicine
> E mailto:[EMAIL PROTECTED]UC San Diego
> http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717
>
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] implementation of t.test

2006-12-11 Thread Weiwei Shi
Hi, there:

for some reason, I need to look at t.test at coding level. Can anyone
here suggest a place to start with?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] X-fold cross validation function for discriminant analysis

2006-11-16 Thread Weiwei Shi
Hi, Wade:
Some functions in R have n-fold cv themselves. For example, if you are
looking for a linear discriminant analysis (lda {MASS}), it comes with
a "leave-one-out" cv in which n equals the size of training sample,
and it gives you pretty good estimation of error rate. But be advised,
this estimated error still comes from training data, which sometimes
(in case of overfitting or condition differences b/w training and
prediction) are much bigger than the error rates in your future data.

BTW, if you are using randomForest, then it uses a out-of-bag (OOB)
method to esitmate the prediciton error.

HTH,

Weiwei

On 11/16/06, Wade Wall <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I ran a discriminant analysis with some data and want to get a general idea
> of prediction error rate.  Some have suggested using X-fold cross validation
> procedure.  Anyone know if there is a function for this in R?
>
> Thanks,
>
> Wade
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to check a R object's property

2006-11-14 Thread Weiwei Shi
Hi,
I am writing a generic function and need to check if an arg is a data
frame or not. I could use
is.null(dim(x)) to get what i want. But i want to know if there is a
function which can tell me whether it is a list, a numeric vector, a
data frame, a factor and so on. Can R do that?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] predict.lda is missing ?

2006-11-10 Thread Weiwei Shi
i think you should use
lda_res <- lda(over_win ~ t1_scrd_a + t1_alwd_a, data=train, CV=F)

loo should be disabled for predicting purpose.

On 11/10/06, Larry White <[EMAIL PROTECTED]> wrote:
> I'm trying to classify some observations using lda and I'm getting a
> strange error.  I loaded the MASS package and created a model like so:
>
> >train <- mod1[mod1$rand < 1.7,]
> >classify <- mod1[mod1$rand >= 1.7,]
> >lda_res <- lda(over_win ~ t1_scrd_a + t1_alwd_a, data=train, CV=TRUE)
>
> That works, and all is well until I try to do a prediction for the holdouts:
>
> >lda_pred <- predict(lda_res, classify)$class
> Error in predict(lda_res, classify) : no applicable method for "predict"
>
> If I try predict.lda specifically I get
> > lda_pred <- predict.lda(lda_res, classify)$class
> Error: could not find function "predict.lda"
> > predict.lda
> Error: object "predict.lda" not found
> but i can get help for it by typing help(predict.lda), which says it's
> in the MASS package.
>
> If somebody could point out what I'm doing wrong I'd be grateful.
> thanks
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] history in Mac

2006-11-10 Thread Weiwei Shi
Hi,

my "history" in Mac for R does not work. I found the solution is GNU
readline and re-installation from source. is there any other way to
solve this? i really do not want to re-install: which means I need to
install many packages, blabla...

i used to use JGR (which solved that problem) but found sooo many bugs
with it...

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] [BioC] colnames and get means for the columns with the "same" names

2006-11-06 Thread Weiwei Shi
hi,

I played around with these two functions but did not get what i want.
So I wrote a function by using a loop to do it and it is done in a
reasonable time:
> system.time(t3 <- iconix.convert(processed, 9, 7486, 
> probes2llid.genego[,c(2,5)]))
[1] 12.356  4.494 16.836  0.000  0.000
> dim(t3)
[1]  129 4255

I am more interested in the approach instead of "averaging". I will
look into the archive since it is a very common problem Microarray
analysis has.

I post my function here in case someone needs it in the future.

iconix.convert <- function(orig, st=9, ed=7486, c.table){
t1 <- orig[, st:ed]

# treat missing
t1 <- sapply(t1, function(x){ x[is.na(x)]<-0; x})

x0 <- unique(c.table[,2])
out <- matrix(0, dim(t1)[1], length(x0))
j = 1
for (i in x0){
avg.col <- c.table[c.table[,2]==i, 1]
if (length(avg.col) > 1){ # has 1:multiple ids
t2 <- apply(t1[, avg.col], 1, mean)
}
else{
t2 <- t1[, avg.col]
}
out[,j] <- t2
j <- j + 1
}
out <- as.data.frame(out)
colnames(out) <- x0
out2 <- cbind(orig[, c(1:(st-1))], out, orig[,c((ed+1):dim(orig)[2])])
colnames(out2)[dim(out2)[2]] <- "Group"
out2
}



On 11/6/06, Davis, Sean (NIH/NCI) [E] <[EMAIL PROTECTED]> wrote:
> Hi, Weiwei.
>
> You probably want to look at a combination of merge() to combine your data 
> with your conversion table followed by aggregate().  Read up on the help for 
> those two functions and that should do it, if I understand what you want to 
> do.  However, keep in mind that "averaging" the probesets representing the 
> same gene may not represent the best solution.  Also, if you search the 
> archive a bit, I know this question has come up before.
>
> Sean
>
>
>
> -Original Message-
> From: Weiwei Shi [mailto:[EMAIL PROTECTED]
> Sent: Mon 11/6/2006 4:53 PM
> To: r-help
> Cc: bioconductor
> Subject: [BioC] colnames and get means for the columns with the "same" names
>
> hi,
> I have a conversion table for colnames like this:
>   Probe_ID HUMAN_LLID
> 1  AF106325_PROBE1   7052
> 2 NM_019386_PROBE1   7052
> 3 NM_012907_PROBE1339
> 4  AW917796_PROBE1  84196
> 5L27651_PROBE1  10864
>
> The Probe_ID contains a list of colnames for another data.frame, say x1.
> I need to convert such colnames to another ID's system, HUMAN_LLID by
> using the table. The colnames of x1 with the same names (in
> HUMAN_LLID) need to be averaged. Is there a good way to do it?
>
> I also put this question in bioconductor since I believe it might be
> solved by some package.
>
> thanks.
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>
> ___
> Bioconductor mailing list
> [EMAIL PROTECTED]
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: 
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] colnames and get means for the columns with the "same" names

2006-11-06 Thread Weiwei Shi
hi,
I have a conversion table for colnames like this:
  Probe_ID HUMAN_LLID
1  AF106325_PROBE1   7052
2 NM_019386_PROBE1   7052
3 NM_012907_PROBE1339
4  AW917796_PROBE1  84196
5L27651_PROBE1  10864

The Probe_ID contains a list of colnames for another data.frame, say x1.
I need to convert such colnames to another ID's system, HUMAN_LLID by
using the table. The colnames of x1 with the same names (in
HUMAN_LLID) need to be averaged. Is there a good way to do it?

I also put this question in bioconductor since I believe it might be
solved by some package.

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] margins in heatmap.2 and fond size for x-axis

2006-10-31 Thread Weiwei Shi
Hi,

I am using heatmap.2 and have this problem now:

heatmap.2(as.matrix(t7[,4:8]), col=c("green", "yellow", "red"),
margins=c(35,10)+0.1, RowSideColors=class.colors, trace="none",
ylab="drugs", xlab="network signatures", scale="none")#

I put the following line into a function and call that function
(i.heatmap.1) and R complains:
Error in plot.new() : figure margins too large

I have to manually enlarge this "empty" one and re-call that function
so I can get result. I tried to use par(mar) but it seems it does not
help:

> par(mar=c(25,4,4,4)+0.1)
Warning message:
calling par(new=) with no plot
> i.heatmap.1(t7, "non-ox")
Error in plot.new() : figure margins too large
Error in par(op) : invalid value specified for graphical parameter "pin"
In addition: Warning message:
calling par(new=) with no plot

The reason I need a large margin is my xaxis font is too long, like
"ng_sodium_transport". I googled the r-help and found there is no way
to make it smaller since I am using the smallest = 1. Is there other
way around?

Thanks


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to plot a data.frame?

2006-10-30 Thread Weiwei Shi
hi,
i have a data frame like this:
0.3  0.7
0.4  0.8

i am trying to plot this data frame and each cell is filled with
different colors based on the value. Is there a function which can do
this?

thanks,


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] gui for R

2006-10-30 Thread Weiwei Shi
Hi,

I met with many bugs when I used JGR and am looking for some other
GUI's for Mac. I found SciViews-R by googling but it is only for
windows to my best knowledge. Is there any other good gui like that,
usable for Mac?

Thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] write a help file for my own function

2006-10-25 Thread Weiwei Shi
Hi,

I am wondering how I can write a help page for my own function so when
I type ?myOwnfunc, then the help page will show up?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] how to improve the efficiency of the following lapply codes

2006-10-25 Thread Weiwei Shi
object.size(intersect.matrix)
41314204

but my machine has 4 G memory, so it should be ok since after 12
hours, it finishes 16k out of 60k but still slow non-linearly.

I am thinking to chop 60k into multiple 5k data.frames to run the
program. but just wondering is there a way around it?

> version
   _
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)

[EMAIL PROTECTED] ox]$ more /proc/meminfo
total:used:free:  shared: buffers:  cached:
Mem:  4189724672 3035549696 11541749760 282836992 2057129984
Swap: 4293586944 645042176 3648544768

[EMAIL PROTECTED] ox]$ more /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 15
model   : 4
model name  : Intel(R) Xeon(TM) CPU 3.60GHz
stepping: 3
cpu MHz : 3591.419
cache size  : 2048 KB



thanks.

On 10/25/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a series of lda analysis using the following lapply function:
>
> n <- dim(intersect.matrix)[1]
> net1.lda <- lapply(1:(n), function(k) i.lda(data.list,
> intersect.matrix, i=k, w))
>
> i.lda is function to do the real lda analysis.
>
> intersect.matrix is a nx1026 matrix, n can be a really huge number
> like 60k. The target is perform a random search. Building a n=120k
> matrix is impossible for my machine. When n=5k, the task can be done
> in 30 min while n=60k, it is estimated to take 5 days. So I am
> wondering where my coding problem is, which causes this to be a
> nonlinearity.
>
> If more info is needed, I will provide.
>
> thanks
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] how to improve the efficiency of the following lapply codes

2006-10-25 Thread Weiwei Shi
Hi,
I have a series of lda analysis using the following lapply function:

n <- dim(intersect.matrix)[1]
net1.lda <- lapply(1:(n), function(k) i.lda(data.list,
intersect.matrix, i=k, w))

i.lda is function to do the real lda analysis.

intersect.matrix is a nx1026 matrix, n can be a really huge number
like 60k. The target is perform a random search. Building a n=120k
matrix is impossible for my machine. When n=5k, the task can be done
in 30 min while n=60k, it is estimated to take 5 days. So I am
wondering where my coding problem is, which causes this to be a
nonlinearity.

If more info is needed, I will provide.

thanks

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] multiple consoles for R?

2006-10-24 Thread Weiwei Shi
hi,

I am using JGR these days and I am wondering if there is some good IDE
for R which allows me to open multiple consoles or there is a way
around it?

> version
   _
platform   i386-apple-darwin8.6.1
arch   i386
os darwin8.6.1
system i386, darwin8.6.1
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] Progress Monitor in R

2006-10-24 Thread Weiwei Shi
the way i do is like this

for (i in 1:1000){

  if (i %% 100){ # you can change this number
cat("process monitor: i =", i, "\n");
  }

}

hth,

w.

On 10/24/06, Xiaofan Cao <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm writing a program in R that has a few nested loops. I'd like to
> monitor the progress when the program is running and be able to estimate
> the remaining time.
>
> I'd highly appreciate it if anyone can shed a light on this issue. Thanks
> for your time!
>
> Best Regards,
> Martha Cao
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] lda

2006-10-20 Thread Weiwei Shi
hi,

i am wondering if i could use lda$scaling (i.e. coeff) to evaluate
variables' importance if all the x's are normalized before put into
model?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] pass additional parameters to function

2006-10-19 Thread Weiwei Shi
thanks a lot!

On 10/19/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> f <- function(f1, ...) {
>   args <- list(...)
>   lapply(args, print)
>  f1(...)
> }
> f(sin, pi)
>
>
> On 10/19/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > how do i assign "1" or "2" to some destination variable?
> > i mean, how do i use something to represent ... in the defn. of f?
> >
> > On 10/19/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > > Try this:
> > >
> > > f <- function(f1, ...) f1(...)
> > > f(sin, 1)
> > > f(max, 1, 2)
> > >
> > >
> > > On 10/19/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > I have a function like this:
> > > >
> > > > f <- function(f1) { ...}
> > > >
> > > > f1 is a function name itself.
> > > > I have two candidates for f1, and each of them have different numbers
> > > > of arguments, say
> > > > f2 has 2 while f3 has 3.
> > > >
> > > > then my question is, how to write f function so that I can pass
> > > > different funcation names with different number of parameters?
> > > >
> > > > thanks.
> > > >
> > > > --
> > > > Weiwei Shi, Ph.D
> > > > Research Scientist
> > > > GeneGO, Inc.
> > > >
> > > > "Did you always know?"
> > > > "No, I did not. But I believed..."
> > > > ---Matrix III
> > > >
> > > > ______
> > > > R-help@stat.math.ethz.ch 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.
> > > >
> > >
> >
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


Re: [R] pass additional parameters to function

2006-10-19 Thread Weiwei Shi
how do i assign "1" or "2" to some destination variable?
i mean, how do i use something to represent ... in the defn. of f?

On 10/19/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Try this:
>
> f <- function(f1, ...) f1(...)
> f(sin, 1)
> f(max, 1, 2)
>
>
> On 10/19/06, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a function like this:
> >
> > f <- function(f1) { ...}
> >
> > f1 is a function name itself.
> > I have two candidates for f1, and each of them have different numbers
> > of arguments, say
> > f2 has 2 while f3 has 3.
> >
> > then my question is, how to write f function so that I can pass
> > different funcation names with different number of parameters?
> >
> > thanks.
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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] pass additional parameters to function

2006-10-19 Thread Weiwei Shi
Hi,

I have a function like this:

f <- function(f1) { ...}

f1 is a function name itself.
I have two candidates for f1, and each of them have different numbers
of arguments, say
f2 has 2 while f3 has 3.

then my question is, how to write f function so that I can pass
different funcation names with different number of parameters?

thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch 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.


  1   2   3   >