similar to: slicing list with matrices

Displaying 20 results from an estimated 3000 matches similar to: "slicing list with matrices"

2009 Nov 22
3
Define return values of a function
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 has been created,
2009 Mar 11
3
chisq.test: decreasing p-value
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 fixed sample, the p-value decreases dramatically (looks as if converge to zero). (1) Why? (2) (If
2009 Mar 08
1
Summary of data.frame according to colnames and grouping factor
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"), 10) ### end:example How do I get the
2009 Mar 07
2
Recode factor into binary factor-level vars
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"
2009 Nov 13
1
shrink list by mathed entries
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
2010 Dec 03
1
Linear separation
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 alternative, take the findings from my analysis and report them. And if so, how can I find the linear
2009 Nov 13
0
Craddock-Flood Test in R?
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://www.eawag.ch, http://sozmod.eawag.ch
2009 Mar 06
4
Summary grouped by factor
### 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 columns and the interesting statistics as lines? Thx,
2010 Dec 27
0
Nagelkerke R square for Prediction data
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 R from a fitted model. I am no professional programmer by far, yet, I hope, that
2010 Jul 23
0
ROpenOffice (which requires Rcompression)
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 plugin or an application which does this batch in OOorg. Is there new development on a direct import
2008 Sep 07
2
Regression with nominal data
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
2010 Jan 29
2
cbind, row names
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? Thank you S?ren
2010 Apr 16
2
Return a variable name
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
2010 May 08
2
Adding NAs to data.frame
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 much? for (i in 1:length(df)){ df[unlist(v[i]), i] <- NA; } summary(df); This
2009 Feb 27
2
add absolute value to bars in barplot
Hello, r-help at 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
2008 Oct 09
2
Plot grouped histograms
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 independence showing that the reason does not differ depending on the
2000 Nov 16
2
newbee question
Dear All Where can I lookup good methods to compute p from q=bin(m,n)p^n*(1-p)^(m-n) such that q<=alfa, alfa small. Are there such libs, code and source in R? Best Regards -- Jan Burse SIAM, EAWAG Scheuchzerstr. 67 ?berlandstr. 133 8006 Z?rich 8600 D?bendorf tel: +41-1-364 17 66 tel: +41-1-823 55 34
2009 Mar 25
2
pca vs. pfa: dimension reduction
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: Calculate the factor underlying these three vars. Use the loadings and the original var
2008 Oct 07
1
read.spss: variable.labels
Hi, how can I attach variable labels originally read by read.spss() to the resulting variables? <pre> 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) </pre> Thank you S?ren
2009 Feb 27
1
cross tabulation: convert frequencies to percentages
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 like an extra column and an extra row with absolute sums. I know, Excel or the