Displaying 20 results from an estimated 4000 matches similar to: "Sweave: change tab size"
2011 Mar 04
3
S. function calculating x +- y
Hello, I am looking for an elegant one-liner for the following
operation:
x <- rnorm(10)
y <- runif(10)
c(mean(x)-mean(y), mean(x)+mean(y))
I thought about
apply(data.frame(x, y), 2, mean)
but I don't know how to apply the +- operation on the result of
apply. Thanks, *S*
--
Sascha Vieweg, saschaview at gmail.com
2011 Jan 28
6
R-/Text-editor for Windows?
Tinn-R (http://www.sciviews.org/Tinn-R/) is one of the topmost
suggestions when googling an R-(text-)editor for Windows. However,
to me it appears dissappointing that Tinn-R does not handle utf-8
(mac-roman, or any other) encoded R-scripts or, in general, text
files. Besides Emacs and the R built-in editor, could you
recommend a good editor for Windows, even some commmercial for a
small
2012 Aug 15
2
sample() from (un-)sorted vectors
Hello,
Vector y is an alphabetically sorted version of vector x. Will both
samples, X and Y, be "absolutely" random or will they have systematic
differences? And: Should I sort or shuffle a vector before sampling?
Thank you, *S*
x <- as.factor(LETTERS[sequence(10:1)])
y <- sort(x)
X <- sample(x, 5)
Y <- sample(y, 5)
--
Sascha Vieweg, saschaview at gmail.com
2011 Apr 08
1
multinom() residual deviance
Running a binary logit model on the data
df <- data.frame(y=sample(letters[1:3], 100, repl=T),
x=rnorm(100))
reveals some residual deviance:
summary(glm(y ~ ., data=df, family=binomial("logit")))
However, running a multinomial model on that data (multinom, nnet)
reveals a residual deviance:
summary(multinom(y ~ ., data=df))
On page 203, the MASS book says that "here the
2011 Mar 08
2
plotCI() with ggplot2
Hello
Currently, I plot some coefficients with some intervals using
function "plotCI()" (package "gplots") using the following code:
(m1 <- matrix(0:5, nrow=2, byrow=T, dimnames=list(c("v1", "v2"),
c("lo", "m", "hi"))))
m2 <- m1 + 1
library(gplots)
plotCI(
x=1:length(m1[, 1]),
pch="",
2011 Jan 20
1
predict() for bootstrapped model coefficients
I run a multinomial regression on a data set with an outcome that
has three values. First, I build an initial model, b.mod. Then I
run a loop to bootstrap the coefficients. For the initial model,
using "predict()", I can print the wrong/false predictions table.
But how do I get this table (that is, the predictions) for the
bootstrapped model? Thanks for hints, *S*
df <-
2011 Nov 18
3
Apply functions along "layers" of a data matrix
Hello
How can I apply functions along "layers" of a data matrix?
Example:
daf <- data.frame(
'id' = rep(1:5, 3),
matrix(1:60, nrow=15, dimnames=list( NULL, paste('v', 1:4, sep='') )),
rep = rep(1:3, each=5)
)
The data frame "daf" contains 3 repetitions/layers (rep) of 4 variables
of 5 persons (id). For some reason, I want to calculate
2011 Nov 29
1
md.pattern ('mice') failure with more than 31 variables
Hello
How come that the function md.pattern() from package 'mice' delivers a
warning when run over data sets with more than 31 variables?
library( 'mice' )
x <- as.data.frame(
matrix(
sample( c(1:3, 1:3, 1:3, NA), 7000, repl=TRUE ),
ncol=35,
dimnames=list(NULL,
paste('V', 11:45, sep="")
)
)
)
md.pattern(x) # Warning message:
2011 Dec 01
1
transform data.frame holding answers --> data.frame holding logicals
Hello
Hello
I have a data frame, x, holding 5 persons answering the question which
cars they have used:
# the data frame
x <- as.data.frame(
matrix(
c('BMW', '', '',
'Mercedes', 'VW', '',
'Skoda', 'VW', 'BMW',
'', '', '',
'VW', 'Skoda',
2011 Feb 06
1
boot() versus loop, and statistics option
Hello R users
I am quite new to bootstrapping. Now, having some data x,
----
R: set.seed(1234)
R: x <- runif(300)
----
I want to bootstrap simple statistics, mean and quantiles (.025,
.975). Currently, I run a loop
----
R: res <- as.data.frame(matrix(ncol = 3, dimnames = list(NULL,
... c("M", "Lo", "Hi"))))
R: for (i in 1:100) {
... y <-
2011 Apr 20
2
Include C++ DLL, error in ...: C symbol name not in load table
Hello R experts
I am googling and reading around, however, I can't get it working
(perhaps because I do not understand much C, however, I'll give it
a try). I am trying to include C++ code into an R routine, where
the C++ code looks:
#include <iostream>
using namespace std;
void foo (double* x, double* y, double* out)
{
out[0] = x[0] + y[0];
}
Back in R, the command
R CMD
2012 Feb 19
3
Non-parametric test for repeated measures and post-hoc single comparisons in R?
Some attribute x from 17 individuals was recorded repeatedly on 6 time
points using a Likert scale with 7 distractors. Which statistical
test(s) can I apply to check whether the changes along the 6 time points
were significant?
set.seed( 123 )
x <- matrix( sample( 1:7, 17*6, repl=T ),
nrow = 17, byrow = TRUE,
dimnames = list(1:17, paste( 'T', 1:6, sep='' ))
)
I found
2011 Mar 14
2
code for "permutative" operation
Hello, I need some form of a "permutative" operation on a numeric
vector x
x = (v1, v2, v3, ..., vN)
that produces
x.r = (v1, v1+2, v1+v2+v3, ... v1+v2+...+vN)
If the operation is sum() I can run
x <- 5:8
m <- matrix(rep(x, length(x)), ncol=length(x))
(x.r <- rowsum(m * upper.tri(m, diag=TRUE), rep(1, length(x))))
But there's two things I don't know and kindly
2011 Apr 20
1
S: expert mailing list for general statistical questions
Hello R users and experts
Once in a while I have got questions that are not so much
R-related but related to (social scientific) statistics in
general. R-help would be the wrong list for such posts, and I am
looking for a similar mailing list or newsgroup (nntp). (It is
just a personal taste that I don't like web forums.) I have
googled and found a variety here:
2011 Mar 01
0
unicode&pdf font problem RESOLVED
Just to add to this (I've been looking through the archive) problem with display unicode fonts in pdf document in R
If you can use the Cairo package to create pdf on Mac, it seems quite happy with pushing unicode characters through (probably still font family dependant whether it will display)
probstring <- c(' \u2264 0.2',' \u2268 0.4',' \u00FC 0.6',' \u2264
2011 Feb 13
6
From numeric vector to string vector
Hi there, I have a numeric vector let say:
Vect <- c(12.234, 234.5675, 1.5)
Now I want a string vector like:
changedVec <- c("012.234", "234.568", "001.500")
Would be grateful if somebody help me how can I do that.
Thanks and regards,
[[alternative HTML version deleted]]
2011 Jan 27
5
Help needed
Hello I am trying to solve these problems and I am not allowed to use loops or ifs.
1st Question
My first question is that I have generated 100 random numbers from the uniform distribution then
A)add only the negative integers.
B)add elements until the first appearance of a negative element.
I know how to choose the negative elements for A but how to find integers?
And I dont know what to do
2011 Jan 27
4
Writing program for these
Hello I am trying to solve these problems and I am not allowed to use loops or ifs.
1st Question
My first question is that I have generated 100 random numbers from the uniform distribution then
A)add only the negative integers.
B)add elements until the first appearance of a negative element.
I know how to choose the negative elements for A but how to find integers?
And I dont know what to do
2011 Apr 09
2
glm with multiple vars
I am looping through various models with different combinations of
independent variables which are stored as columns in x
glm(y ~ ??, data=x)
How can I pass the colnames of the selected columns of x into ?? seperating
them with a +
ie I want to generate
glm(y ~ x1 + x2, data=x)
glm(y ~ x2 + x3, data=x)
glm(y ~ x1 + x2 + x4, data=x)
...
I have tried the sedit function
2012 Nov 01
1
How to nicely display R code with the LaTeX package 'listings'?
Dear expeRts,
What's a 'good' (nice-looking, easy-to-read) setup for the LaTeX package
'listings' to display R code?
The two versions below are partly inspired by the settings of the package
SweaveListingUtils and
http://r.789695.n4.nabble.com/R-How-to-format-R-code-in-LaTex-documents-td816055.html
Any suggestions, comments, or improvements are welcome.
Cheers,
Marius
###