search for: somedataframe

Displaying 5 results from an estimated 5 matches for "somedataframe".

2008 Feb 29
1
Optional data argument for a function
...but I just can't quite figure out how to make this work. So, for a simple example, suppose I want to do this with the following function: dosomething <- function(x, data) { temp <- x^2 + 5 return(temp) } How does the function need to be changed, so that dosomething(somevariable, data=somedataframe) will find somevariable within the dataframe somedataframe and if dosomething(somevariable) is called, the function should find somevariable in the parent frame (or anywhere else in the search path)? Thanks for any help! -- Wolfgang Viechtbauer ?Department of Methodology and Statistics ?Univer...
2007 Aug 23
0
indexing and regression testing
...ental packages to CRAN (hope it will be there soon): rindex: quick indexing of large objects (currently only character, see ?index) regtest: some first support for automated regression testing (heavily used in \dontshow{} section of ?index) With rindex you can for example i <- index(rownames(someDataFrame)) # then this someDataFrame[match(fewRowNames, i),] # is much faster than that someDataFrame[match(fewRowNames, rownames(someDataFrame)),] # which still is much faster than someDataFrame[fewRowNames, ] # the latter being surprisingly slow as it can be worked around by match (even without indexing)...
2009 Oct 28
3
variable labels to accompany data.frame
...me. Furthemore: In Stata, if "myvariable" is labeled numeric (in R lingo, a factor), and I type codebook myvariable then Stata tells me, among other things, the "levels" of myvariable. Does a tool of this sort exist in R? The prompt() function is related to this, but prompt(someDataFrame) creates a text file on disk. The text file is associated with, but not unambiguously linked to, someDataFrame. The epicalc function codebook() provides a summary of a dataframe similar to that created by summary() but easier to read. But this is not a way to define and keep track of labels that a...
2006 Jun 22
2
.Call and data frames
...fetch a data frame through the C API, and have no problem doing this when all columns are numbers, but when there is a column of strings I have a problem. On the C-side the function looks like: SEXP myfunc(SEXP df), and it is called with a dataframe from the R side with: .Call("myfunc", somedataframe) On the C side (actually C++ side) I use code like this: SEXP colnames = getAttrib(df, R_NamesSymbol) cname = string(CHAR(STRING_ELT(colnames,i)) SEXP coldata = VECTOR_ELT(df,i) (data for i-th column) if(isReal(colData)) x = REAL(colData)[j]; else if(isInteger(colData)) i = INTEGER(colDat...
2004 Sep 23
7
decompose a correlation matrix
Is there a simple way to decompose the upper triangle of a correlation matrix to a linear list; For example: X Y Z X 1 2 3 Y 2 1 4 Z 3 4 1 so you get a list like: xy 2 XZ 3 YZ 4 I suspect you can do it with a matrix transformation, but that beyond me at present. Many thanks Mark _________________________ Department of Molecular and Human Genetics, Baylor College of Medicine,