[R] eval function with javascript-semantics possible in R?

2010-02-10 Thread Chaehan So
Dear r-helpers, I am looking for an R-equivalent for the eval-function in javascript which can interpret a string as code on runtime, thereby allowing things like for (i in c(1:2)) { eval(items + "i") <- read.csv(eval(filename+ i), dec=","); } which would execute (with filename="testfile"): i

Re: [R] eval function with javascript-semantics possible in R?

2010-02-10 Thread Chaehan So
;testfile%s" > lapply(sprintf(fileName, 1:2), read.csv, dec = ",") > > On Wed, Feb 10, 2010 at 5:28 PM, Chaehan So wrote: > > Dear r-helpers, > > > > I am looking for an R-equivalent for the eval-function in javascript > which > > can &

[R] mean calculation within dataframe corrupted

2010-02-10 Thread Chaehan So
Dear R-helpers, my little function below calculates the group score (tmpGroupMean) of an item, appends a "_mean" on its name and stores its value on this name. However, it does not calculate the mean of these scores (LVMean) in the same row correctly, as you can see in the below output which stran

Re: [R] eval function with javascript-semantics possible in R?

2010-02-10 Thread Chaehan So
mes) { doSomethingWith(currentName) } } On Wed, Feb 10, 2010 at 11:34 PM, David Winsemius wrote: > > On Feb 10, 2010, at 5:12 PM, Chaehan So wrote: > > Thank you, it works for the first problem! >> >> Yet for the second problem, how can I solve that in one dataframe (here: >>

Re: [R] eval function with javascript-semantics possible in R?

2010-02-10 Thread Chaehan So
Dear Joe - that was wonderful :-) -Chaehan On Thu, Feb 11, 2010 at 12:44 AM, Joe Cheng wrote: > On Wed, Feb 10, 2010 at 3:37 PM, Chaehan So wrote: > >> how can I access currentName in my loop - evaluated as a variable although >> it is a string? >> > > I think yo

[R] Unexpected output in first iteration of for-loop

2010-02-10 Thread Chaehan So
Dear r-helpers, why do I get an output in the first iteration of the for-loop which contains the string values of the input vector, and how can I avoid that? Here's the output (only line 1 is wrong) latentVariable Indiv Group 1 rPlanning rIterat rTDD 2 rPlanning0.79 0.84 3

Re: [R] Unexpected output in first iteration of for-loop

2010-02-11 Thread Chaehan So
e), groupingVariable) result <- rbind(result,data.frame(latentVariable=currentName, Indiv=tmp1,Group=tmp2)) } return(result) } On Thu, Feb 11, 2010 at 3:31 AM, jim holtman wrote: > It doing exactly what you asked it to do. You have the assignment: > > result <- latentVar

Re: [R] Unexpected output in first iteration of for-loop

2010-02-11 Thread Chaehan So
calculateGroupCronbach(get(latentVariableNames[i]), > groupingVariable) > } > > result <- > data.frame(latentVariable=latentVariableNames,Indiv=tmp1,Group=tmp2) > > names(result) <- c("latentVariable", "Indiv", "Group") > result

[R] Missing index in vector assignment

2010-03-16 Thread Chaehan So
Dear r-helpers, I am getting a mismatch error between two variables: svp <- ksvm(x, y, type="nu-svc") Error in .local(x, ...) : x and y don't match. and I suspect that it might be due to missing index in the y variable which I defined as: y <- (LVvar[,1]) I tried various methods to make

Re: [R] Missing index in vector assignment

2010-03-17 Thread Chaehan So
ns LV <- c("rPerform","rCoordCap", "rKnowGrow", "rGoalcom", "rSupport", "rOpcomm", "rT2Cadap" ) # creates a dataframe LVvar <- na.omit(loopLV_IndexScores(LV, u_proj)) x <- (LVvar[,-1]) y <- (LVvar[,1]) svp <- ks

Re: [R] Missing index in vector assignment

2010-03-17 Thread Chaehan So
structure(40L, .Names = "40", class = "omit"), class = > > "data.frame") > > > > > > > > > > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html<http://www.r-project.org/ > >