Displaying 20 results from an estimated 1000 matches similar to: "Row number of minimum value?"
2007 Jan 09
5
a question of substitute
Hi all,
I want to write a wrapper for an analysis of variance and I face a curious
problem. Here are two different wrappers:
fun.1 <- function(formula) {
summary(aov(formula))
}
fun.2 <- function(formula) {
oneway.test(formula)
}
values <- c(15, 8, 17, 7, 26, 12, 8, 11, 16, 9, 16,
24, 20, 19, 9, 17, 11, 8, 15, 6, 14)
group <- rep(1:3, each=7)
# While the first
2007 Jan 30
6
jump in sequence
Dear list,
This should be a simple one, I just cannot see it.
I need to generate a sequence of the form:
4 5 6 13 14 15 22 23 24
That is: starting with 4, make a 3 numbers sequence, jump 6, then another 3
and so on.
I can create a whole vector with:
myvec <- rep(rep(c(F, T, F), rep(3, 3)), 3)
Then see which are TRUE:
which(myvec)
[1] 4 5 6 13 14 15 22 23 24
I'd like to avoid
2009 Apr 10
4
split a character variable into several character variable by a character
Dear Mao Jianfeng,
"r-help-owner" is not the place for help, but:
r-help at r-project.org
(CC-ed here)
In any case, strsplit() does the job, i.e.:
> unlist(strsplit("BCPy01-01", "-"))
[1] "BCPy01" "01"
You can work with the whole variable, like:
splitpop <- strsplit(df1$popcode, "-")
then access the first part with
>
2012 Jun 19
1
R and C pointers
Dear R devel,
Apologies for these (most probably trivial) questions, doing my first
attempt to call C from R (and actually learning C in the process).
I need to pass a matrix to C, and after reading R-exts.pdf (many
times), I was unable to find how to handle matrices at C-level...
except for, what probably is the answer, that matrices are in fact
vectors with dimensions.
This is a sample code I
2012 Apr 05
2
"NA" vs. NA
Dear All,
I assume this is an R-devel issue, apologies if I missed something
obvious. I have a dataframe where the row names are country codes,
based on ISO 3166, something like this:
------------
"v1" "v2"
"UK" 1 2
"NA" 2 3
------------
It happens that "NA" is the country code for "Namibia", and that
creates problems on
2012 Jun 21
2
debug R objects at C level
Dear R-devel,
I am now at a debugging phase, and would like to inspect the
(individual) values in an arbitrary R vector. It should be simple, but
after hours of reading I am simply unable to find the right
information.
A possible C code is:
?????????????????
# include <R.h>
# include <Rinternals.h>
# include <R_ext/Rdynload.h>
SEXP foo(SEXP x) // where x is a vector passed by
2006 Aug 09
3
objects and environments
Dear list,
I have two functions created in the same environment, fun1 and fun2.
fun2 is called by fun1, but fun2 should use an object which is created in fun1
fun1 <- function(x) {
ifelse(somecondition, bb <- "o", bb <- "*")
## mymatrix is created, then
myresult <- apply(mymatrix, 1, fun2)
}
fun2 <- function(idx) {
if (bb == "o) {
#
2014 Jun 16
1
index.search
Dear r-devel,
I am trying to automatically check if two successive versions of a
package have the same results (i.e. code not broken), by parsing the
example sections for each function against a previously tested
version.
While trying to replicate the code from example(), I am facing an
error related with te "index.search" function (line 7 in the example()
code).
This is the code I am
2010 May 18
5
looking for .. dec if vector if element > x
Hi to all,
I am just looking for more efficient ways ;-)
is there a better way instead a loop to decrease x if greater y
test <- c(1,3,5,7,9)
decrease if greater 1 to
test2 <- c(1,2,4,6,8)
Kind regards
Knut
2009 Feb 23
1
New package: exams - Automatic Generation of Standardized Exams
Dear useRs,
the new R package exams provides Sweave-based automatic generation of
exams with multiple-choice questions and arithmetic problems. The
package is available from CRAN:
http://CRAN.R-project.org/package=exams
It includes a vignette giving an overview of the main design aims and
principles as well as strategies for adaptation and extension.
Hands-on illustrations - based on example
2009 Feb 23
1
New package: exams - Automatic Generation of Standardized Exams
Dear useRs,
the new R package exams provides Sweave-based automatic generation of
exams with multiple-choice questions and arithmetic problems. The
package is available from CRAN:
http://CRAN.R-project.org/package=exams
It includes a vignette giving an overview of the main design aims and
principles as well as strategies for adaptation and extension.
Hands-on illustrations - based on example
2007 Jan 21
2
multiple bases to decimal (was: comparing two matrices)
Hi again,
I was contemplating the solution using base 3:
set.seed(3)
mat2 <- matrix(sample(0:2, 15, replace=T), 5, 3)
Extracting the line numbers is simple:
bases <- c(3, 3, 3)^(2:0) # or just 3^(2:0)
colSums(apply(mat2, 1, function(x) x*bases)) + 1
[1] 7 23 25 8 1
The problem is sometimes the columns have different number of levels, as in:
mat1 <- expand.grid(0:2, 0:2,
2007 May 29
2
pie initial angle
Dear all,
I'd like to produce a simple pie chart for a customer (I know it's bad but
they insist), and I have some difficulties setting the initial angle.
For example:
pie(c(60, 40), init.angle=14)
and
pie(c(80, 20), init.angle=338)
both present the slices in the same direction, where:
pie(c(60, 40))
pie(c(80, 20))
present the slices in different directions.
I read everything I
2009 Mar 24
2
Random sampling based on the observations
Hello!I am having a problem with Random sampling in R. I have used a syntax:
mydata.sub=sample(mydata,7,replace=FALSE,prob=NULL) which allows me to
choose a random sample based on the variables(correct me if I am wrong!).
Suppose I have 10 variable and if I use the above mentioned command then it
will choose 7 variables out of the 10 randomly. My problem is that I want to
have a random sample
2014 Feb 06
3
C headers
Dear list,
Just upgraded to MacOS Mavericks, fresh install of R 3.0.2 and trying to
install a previous version of my QCA package (the most recent one source
file, which passed the R CMD check --as-cran with R 3.0.1)
I seem to have some difficulties in the C code, apparently it doesn't find
some headers (please see below):
============
$ R CMD INSTALL --no-multiarch
2007 Nov 15
3
generate combination set
I have a set data={A,B,C,D,E,F,G}
I want to choose 2 letter from 8 letters, i.e. generate the combination set
for choose 2 letters from 8 letters.
I want to get the liking:
combination set={AB,AC,AD,....}
Does anyone konw how to do in R.
thanks,
Aimin
2007 Feb 22
4
Sorting rows of a binary matrix
Hallo,
The command:
x <- 3
mat <- as.matrix(expand.grid(rep(list(0:1), x)))
generates a matrix with 2^x columns containing the binary representations
of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not
sorted in this order.
How can sort the rows the ascending order of the decimals they represent,
preferably without a function which converts binaries to decimals
2013 Apr 09
4
quotes in cat() within function
Hello all,
Sorry if this question has been answered in the past, but I could not find
an answer.
I am trying to print quotes within a cat output. The arguments are:
file= "Data labels"
directory= "/home/mylaptop/"
The function returns:
cat("The file", file, "is located in directory", directory, sep=" ")
The output R prints is
The file Data
2008 Nov 24
1
RQDA-0.1.5 is released
RDQA is a package for Qualitative Data Analysis built upon R. It works
both on the Windows and Linux/FreeBSD platforms. RQDA is an
easy-to-use tool to assist in the analysis of textual data. At the
present, it supports only plain text format data. All the information
is stored in SQLite database via the R package of RSQLite. The GUI is
based on RGtk2, via the aid of gWidgetsRGtk2. It includes a
2008 Nov 24
1
RQDA-0.1.5 is released
RDQA is a package for Qualitative Data Analysis built upon R. It works
both on the Windows and Linux/FreeBSD platforms. RQDA is an
easy-to-use tool to assist in the analysis of textual data. At the
present, it supports only plain text format data. All the information
is stored in SQLite database via the R package of RSQLite. The GUI is
based on RGtk2, via the aid of gWidgetsRGtk2. It includes a