Thanks, Bill, I should have googled more carefully:
http://stackoverflow.com/questions/9561053/assign-values-to-a-list-element-in-r
So, remove
assign(nm, tmp, parent.frame())
and add
txt <- paste( nm, '<-', tmp, sep='' )
eval( parse(text=txt), parent.frame() )
in `foo(
Hello,
When I use function `foo` with list elements (example 2), it defines a new
object named `b[[1]]`, which is not what I want. How can I change the function
code to show the desired behaviour for all data structures passed to the
function? Or is there a more appropriate way to sort of "pa
Hello, (how) can I download/re-retrieve/order previous R-** digest
volumes/issues to my mailbox for local browsing? Thank you, Sören
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http:
On 28.04.2011, at 12:18, soeren.vo...@uzh.ch wrote:
> On 27.04.2011, at 11:59, soeren.vo...@uzh.ch wrote:
>
>> We are working on a class in C++. The files compile fine (R CMD SHLIB ...)
>> and run in R. A bzipped tar archive with source code can be downloaded from
>> here:
>>
>> http://sovo.md
On 27.04.2011, at 11:59, soeren.vo...@uzh.ch wrote:
> We are working on a class in C++. The files compile fine (R CMD SHLIB ...)
> and run in R. A bzipped tar archive with source code can be downloaded from
> here:
>
> http://sovo.md-hh.com/files/GUTS3.tar.bz
>
> In R, dyn.load("GUTS.so") gene
Hello
We are working on a class in C++. The files compile fine (R CMD SHLIB ...) and
run in R. A bzipped tar archive with source code can be downloaded from here:
http://sovo.md-hh.com/files/GUTS3.tar.bz
In R, dyn.load("GUTS.so") generates an instance of the GUTS class. (How) Is it
possible to
Hello
I found some small postings dated to 22 Oct 2008 on the message subject.
Recently, I have been working with binary logistic regressions. I didn't use
the design package. Yet, I needed the "fit" indices. Therefore, I wrote a small
function to output the Nagelkerke's R, and the Cox-&-Snell
I want to analyse data with an unordered, multi-level outcome variable, y. I am
asking for the appropriate method (or R procedure) to use for this analysis.
> N <- 500
> set.seed(1234)
> data0 <- data.frame(y = as.factor(sample(LETTERS[1:3], N, repl = T,
+ prob = c(10, 12, 14))), x1 = sample
In https://stat.ethz.ch/pipermail/r-help/2008-March/156868.html I found what
linear separability means. But what can I do if I find such a situation in my
data? Field (2005) suggest to reduce the number of predictors or increase the
number of cases. But I am not sure whether I can, as an alterna
A list contains several matrices. Over all matrices (list elements) I'd like to
access one matrix cell:
m <- matrix(1:9, nrow=3, dimnames=list(LETTERS[1:3], letters[1:3]))
l <- list(m1=m, m2=m*2, m3=m*3)
l[[3]] # works
l[[3]][1:2, ] # works
l[[1:3]][1, 1] # does not work
How can I slice all C-c
Thanks Greg for the additional remarks. Basically I have two questions, let me
try to specify them as follows:
(1) Height and intelligence may correlate at, say, X, but speed and finger
length may correlate at Y. Despite any sense of such a statement, is X
significantly larger than Y? How can I
Hello
(1) How can I compare two Pearson correlation coefficients for significant
differences without the use of the raw data?
(2) How can I compare two linear regression coefficients for significant
differences without the use of the raw data?
(3) How can I compare two multiple correlation coe
Hello, when I print x in Sweave, the lines do not wrap. However, I want them to
wrap (perhaps at a specified width). How? Thanks, *S*
<>=
x <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
q
Hello, for my data preparation and administration (data, labels, etc.) I use
OpenOffice.org ODS spreadsheet files with several sheets in one file. However,
I find it inconvenient to export every single sheet to a csv file whenever I
apply changes to the labelling or so, and I haven't found a plu
Hello
How can I set a default for the 'list.len' argument in 'str'?
x <- as.data.frame(matrix(1:1000, ncol=1000))
str(x)
formals(str) <- alist(object=, ...=, list.len=1000)
args(str); formals(str)
str(x)
Does not display errors, but does not work either.
Thanks for help
Sören
Hello
Could you recommend a printed/electronic book that teaches time series analysis
(using R) for students? I am searching for something similar to the MASS book,
with a level lower but close, for TSA. Easy examples would be fine to
understand deeper statistical procedures. Functions, results
Hello, after the creation of a data.frame I like to add NAs as follows:
n <- 743;
x <- runif(n, 1, 7);
Y <- runif(n, 1, 7);
Ag6 <- runif(n, 1, 7);
df <- data.frame(x, Y, Ag6);
# a list with positions:
v <- apply(df, 2, function(x) sample(n, sample(1:ceiling(5*n/100), 1), repl=F));
# a loop too muc
Thanks for the code, that was exactly what I was looking for. Regards,
Sören
On 30.04.2010, at 14:04, David Winsemius wrote:
On Apr 30, 2010, at 6:59 AM, Mohamed Lajnef wrote:
Hi Soeren
Apply or aggregate functions
Probably needs combn as well. Could do it all with numeric indices,
b
Hi Mohamed, thanks for your answer. Anyway, the "how to" is exactly my
problem, since ...
fun2 <- function(x){
please_use_aggregate_and_apply_in_some_way_and_return_the_output_of_my_example_as_requested
(fun(x));
}
fun2(df);
... unfortunately returns an error ;-). Could you please give a
Hello, a data.frame, df, holds the numerics, x, y, and z. A function,
fun, should return some arbitrary statistics about the arguments, e.g.
the sum or anything else. What I want to do is to apply this function
to every pair of variables in df, and the return should be a matrix as
found wit
Hello,
how can I return the name of a variable, say "a$b", from a function?
fun <- function(x){
return(substitute(x));
}
a <- data.frame(b=1:10);
fun(a$b)
... returns a$b, but this is a type language, thus I can't use it as a
character string, can I? How?
Thanks for help,
Sören
___
Hello,
I read the help as well as the examples, but I can not figure out why
the following code does not produce the *given* row names, "x" and "y":
x <- 1:20
y <- 21:40
rbind(
x=cbind(N=length(x), M=mean(x), SD=sd(x)),
y=cbind(N=length(y), M=mean(y), SD=sd(y))
)
Could you please help?
Hello!
Bortz, Lienert, & Boehnke (2008, pp. 140--142) suggest an exact
polynomial test for low frequency tables. I used it recently, and
thus, created the code attached. Maybe someone would use (and likely
modify) it or incorporate it into their package.
Sören
References:
Bortz, J., Lie
For a given numeric vector v of length n and sum s, is there a ready-
to-run code that returns every combination of v in n summing up to s?
Example for n=3 and s=2:
v <- c(2, 0, 0)
# find some coding here that returns
[1] 2 0 0
[2] 1 1 0
[3] 1 0 1
[4] 0 2 0
[5] 0 1 1
[6] 0 0 2
Thanks
Sören
I have created a function to do something:
i <- factor(sample(c("A", "B", "C", NA), 793, rep=T, prob=c(8, 7, 5,
1)))
k <- factor(sample(c("X", "Y", "Z", NA), 793, rep=T, prob=c(12, 7, 9,
1)))
mytable <- function(x){
xtb <- x
btx <- x
# do more with x, not relevant here
cat("The table
On 14.11.2009, at 03:58, David Winsemius wrote:
On Nov 13, 2009, at 11:19 AM, soeren.vo...@eawag.ch wrote:
a <- c("Mama", "Papa", "Papa; Mama", "", "Sammy; Mama; Papa")
a <- strsplit(a, "; ")
mama <- rep(F, length(a))
mama[sapply(a, function(x) { sum(x=="Mama") }, simplify=T) > 0] <- T
[...]
Hello:
# some code to assign with and without "which"
q <- 1:20; q[c(9, 12, 14)] <- NA
r <- 1:20; r[c(8:9, 12:15)] <- NA
s <- 1:20; s[c(8:9, 12:15)] <- NA
r[q < 16] <- 0
s[which(q < 16)] <- 0
r;s # both: 0 0 0 0 0 0 0 0 NA 0 0 NA 0 NA 0 16 17 18 19 20
r <- 1:20; r[c(8:9, 12:15)] <- NA
Hello
a <- c("Mama", "Papa", "Papa; Mama", "", "Sammy; Mama; Papa")
a <- strsplit(a, "; ")
mama <- rep(F, length(a))
mama[sapply(a, function(x) { sum(x=="Mama") }, simplify=T) > 0] <- T
papa <- rep(F, length(a))
papa[sapply(a, function(x) { sum(x=="Papa") }, simplify=T) > 0] <- T
# ... more varia
Hello
The "Craddock-Flood Test" is recommended for large tables with small
degrees of freedom and low-frequency cells. Is there an R procedure
and/or package which does the test?
Thank you for your help!
Sören Vogel
--
Sören Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag, Dept. SIAM
http
Quite often, I need those tables:
x <- sample(c("a", "b", "c"), 40, rep=T)
y <- sample(c("X", "Y"), 40, rep=T)
(tbl <- table(x, y))
(z <- as.factor(paste(as.vector(tbl), " (",
round(prop.table(as.vector(tbl)) * 100, 1), "%)", sep="")))
matrix(as.factor(z), nrow=3, dimnames=dimnames(tbl))
But
Can't make sense of calculated results and hope I'll find help here.
I've collected answers from about 600 persons concerning three
variables. I hypothesise those three variables to be components (or
indicators) of one latent factor. In order to reduce data (vars), I
had the following idea:
A sunflowerplot crossing two categorial variables with NAs fails:
### sample: start ###
set.seed(20)
a <- c(letters[1:4])
z <- c(letters[23:26])
fa <- factor(sample(rep.int(a, 1000), 100, replace=T), levels=a,
ordered=T)
fz <- factor(sample(rep.int(z, 1000), 100, replace=T), levels=z,
ordered
Thanks to Peter, David, and Michael! After having corrected the coding
error, the p values converge to particular value, not necessarily
zero. The whole story is, 634 respondents in 6 different areas marked
their answer on a 7-step Likert scale (very bad, bad, ..., very good
-- later recode
A Likert scale may have produced counts of answers per category.
According to theory I may expect equality over the categories. A
statistical test shall reveal the actual equality in my sample.
When applying a chi square test with increasing number of repetitions
(simulate.p.value) over a f
A dataframe holds 3 vars, each checked true or false (1, 0). Another
var holds the grouping, r and s:
### start:example
set.seed(20)
d <- data.frame(sample(c(0, 1), 20, replace=T), sample(c(0, 1), 20,
replace=T), sample(c(0, 1), 20, replace=T))
names(d) <- c("A", "B", "C")
e <- rep(c("r", "s
How to I "recode" a factor into a binary data frame according to the
factor levels:
### example:start
set.seed(20)
l <- sample(rep.int(c("locA", "locB", "locC", "locD"), 100), 10,
replace=T)
# [1] "locD" "locD" "locD" "locD" "locB" "locA" "locA" "locA" "locD"
"locA"
### example:end
What I
On 06.03.2009, at 16:48, soeren.vo...@eawag.ch wrote:
### example:start
v <- sample(rnorm(200), 100, replace=T)
k <- rep.int(c("locA", "locB", "locC", "locD"), 25)
tapply(v, k, summary)
### example:end
... (hopefully) produces 4 summaries of v according to k group
membership. How can I transf
### example:start
v <- sample(rnorm(200), 100, replace=T)
k <- rep.int(c("locA", "locB", "locC", "locD"), 25)
tapply(v, k, summary)
### example:end
... (hopefully) produces 4 summaries of v according to k group
membership. How can I transform the output into a nice table with the
croups as co
Pls forgive me heavy-handed data generation -- newby ;-)
### start ###
# example data
g <- rep.int(c("A", "B", "C", "D"), 125)
t <- rnorm(5000)
a <- sample(t, 500, replace=TRUE)
b <- sample(t, 500, replace=TRUE)
# what I actually want to have:
boxplot(a | b ~ g)
# but that does obviously not pr
Hello,
might be rather easy for R pros, but I've been searching to the dead
end to ...
twsource.area <- table(twsource, area, useNA="ifany")
gives me a nice cross tabulation of frequencies of two factors, but
now I want to convert to pecentages of those absolute values. In
addition I'd l
Hello,
r-h...@r-project.orgbarplot(twcons.area,
beside=T, col=c("green4", "blue", "red3", "gray"),
xlab="estate",
ylab="number of persons", ylim=c(0, 110),
legend.text=c("treated", "mix", "untreated", "NA"))
produces a barplot very fine. In addition, I'd like to get the bars'
absolute
r11 -- r16 are variables showing a reason for usage of a product in 6
different situations. Each variable is a factor with 4 levels imported
from a SPSS sav file with labels ranging from "not important" to "very
important", and NA's for a sample of N = 276.
(1) I need a chi square test of i
Hi,
how can I attach variable labels originally read by read.spss() to the
resulting variables?
X <- read.spss('data.sav', use.value.labels = TRUE, to.data.frame =
TRUE, trim.factor.names = TRUE, trim_values = TRUE, reencode = "UTF-8")
names(X) <- tolower(names(X))
attach(X)
Thank you
Hi,
y is nominal (3 categories), x1 to 3 is scale. What I want is a
regression, showing the probability to fall in one of the three
categories of y according to the x. How can I perform such a
regression in R?
Thanks for your help
Sören
__
R-h
44 matches
Mail list logo