similar to: Using sapply to build a count matrix

Displaying 20 results from an estimated 6000 matches similar to: "Using sapply to build a count matrix"

2009 Jan 19
1
Question about contributed packages
I am working on a methodology for qualifying R, for GLP and GCP. If I quailfy only the base R install, with no contributed packages, it seems relatively simple to qualify R. However, from time to time I will want to use a contributed package. If I use a contributed package, does it leave anything behind that will be loaded with the next invocation of R? Suppose I run R and use a contributed
2010 Jan 11
0
Exponential regression
There are a couple of points to keep in mind when doing a log-transform of an exponential model, such as -- y = a*exp(b*x) 1. The implicit statistical model is multiplicative in the error. The implied statistical model of the log transform is -- log(y) = log(a) + b*x + u which implies -- y = a*exp(b*x)*exp(u) A linear regression in the log
2010 Feb 20
1
Problem with installing "genetics" package
I have tried to install the "genetics" package and am getting and error. The log is below. For information, I am using R 2.10.1 on the Windows XP operating system. The mirror site I'm using is Michigan Technological University. Your help in this matter will be greatly appreciated. Murray M Cooper, PhD Richland Statistics 9800 North 24th St Richland, MI, USA 49083
2009 Feb 13
1
Bootstrap or Wilcoxons' test?
Hi! I'm comparing the differences in contaminant concentration between 2 different groups of people ( N=36, N=37). When using a simple linear regression model I found no differences between groups, but when evaluating the diagnostic plots of the residuals I found my independent variable to have deviations from normality (even after log transformation). Therefore I have used bootstrap on
2010 Jan 08
2
R exponential regression
Hi all, I have a dataset which consists of 2 columns. I'd like to plot them on a x-y scatter plot and fit an exponential trendline. I'd like R to determine the equation for the trendline and display it on the graph. Since I am new to R (and statistics), any advice on how to achieve this will be greatly appreciated. Many thanks, Chris -- View this message in context:
2009 May 10
1
Function recommendation for this study...
Hi, I'm not used to thinking along these lines, and wanted to ask your advice: Suppose you have a sample of around 100, consisting of patients according to doctors, in which patients and doctors are given a questionnaire with categorical responses. Each patient somehow has roughly 3 doctors, or 3 rows of data. The goal is to assess by category of each question or DV the agreement between
2009 Feb 05
1
Chi-squared test adjusted for multiple comparisons? Harbe's test?
Hi! I have some data that looks like this up down percentaje uew_21 20 14 58.82 uew_20_5 27 40 40.29 uew_20 8 13 38.09 uew_19_5 17 42 28.81 So I have 4 experimental conditions and I am counting number of animals in the up and down compartment and the calculating the percentage, I want to know which one of the conditions is different from each other. If the data wouldn't be percentage
2009 Feb 06
4
Upgrade R program (version 2.6.2) ???
Hi All, I downloaded the R program (version 2.6.2) in last Jan 2008. I now want to upgrade the program to its latest version, but I don't want to go through the process of deleting the existing version and downloading the new version. This is because my existing R program has numerous packages that I downloaded for my research work. I want to upgrade my R program with those packages in it. Is
2009 Apr 22
5
large factorials
I am working on a project that requires me to do very large factorial evaluations. On R the built in factorial function and the one I created both are not able to do factorials over 170. The first gives an error and mine return Inf. Is there a way to have R do these larger calculations (the calculator in accessories can do 10000 factorial and Maple can do even larger) -- View this message in
2009 Feb 05
2
eliminating control characters from formatted data files
I have a few hundred files of formatted data. Unfortunately most of them end with a spurious CONTROL-Z. I want to rewrite the files without the spurious character. Here's what I've come up with so far, but my code is unsafe because it assumes without justification that the last row of df contains a control character (and some NAs to fill up the record). options(warn=-1) #turn off
2009 Feb 05
4
eval and as.name
I'm sure there is a more general way to ask this question but how do you use the elements of a character vector as names of objects in an expression? For example, say you have: a = c(1,3,5,7) b = c(2,4,6,8) n=c("a","b") and you want to use the names a and b in a function (e.g. sum) sum(eval(as.name(n[1])),eval(as.name(n[2]))) works but what is a simpler way to
2012 Feb 14
1
method using several (and different) arguments in turn
Dear R-developers community, I have the following generic: setGeneric( name="newsample", def=function(x,y,z,a,b,c,...){standardGeneric("newsample")} And I can build several methods for this generic. One useful thing is to use "newsample" with only one of the 6 arguments listed. At the moment this is what I do: setMethod(
2004 Jan 15
3
Extracting multiple elements from a list
For a long time I've wanted a way to conveniently extract multiple elements from a list, which [[ doesn't allow. Can anyone suggest an efficient function to do this? Wouldn't it be a sensible addition to R? For example, alist <- list() alist[[1]] <- list() alist[[1]]$name <- "first" alist[[1]]$vec <- 1:4 alist[[2]] <- list() alist[[2]]$name <-
2001 Nov 28
2
shell()/system() question
Hi folks: How do I get shell() or system() to run external programs in a particular directory (different from the current R working directory)? > version _ platform i386-pc-mingw32 arch x86 os Win32 system x86, Win32 status major 1 minor 3.0 year 2001 month 06
2010 Dec 13
1
Multivariate binary response analysis
Greetings ~ I need some assistance determining an appropriate approach to analyzing multivariate binary response data, and how to do it in R. The setting: Data from an assay, wherein 6-hours-post-fertilization zebrafish embryos (n=20, say) are exposed in a vial to a chemical (replicated 3 times, say), and 5 days later observed for the presence/absence (1/0) of defects in several organ systems
2002 Aug 26
5
updating n within for(i in 1:n) loop
Hi folks: I think I'm having problems with figuring this one out: test1 <- function() { n <- 2 for(i in 1:n) { cat(paste("i =", i, "\n")); flush.console() n <- 5 # version 1 #n <<- 5 # version 2 #assign("n", 5, envir = environment(test1)) # version 3 } } I need the for(.) loop to run (say) n=5 times within the
2006 Jun 20
2
strange use of sapply
I've tried and give up. I have a matrix of say 200 columns and 400 rows. For each odd ( or even i suppose if i wanted to )column, I want to know the number of rows in which the value is greater than zero. So, I did sapply(tempMatrix,2,function(x) sum( x > 0 )) this almost works but i don't know how to tell it to only do the odd columns. my guess is , like everything else in R, this
2004 Jul 13
1
summary() doesn't work with Date class objects
The handy function summary() doesn't work correctly with Date class objects: > R.version.string [1] "R version 1.9.1, 2004-06-21" > b <- as.Date(c("2002-12-26", "2002-12-27", "2002-12-28", "2002-12-29", "2002-12-30")) > b [1] "2002-12-26" "2002-12-27" "2002-12-28" "2002-12-29"
2002 Mar 05
3
reading 2-byte integers using readBin and connections
Hi folks: This may be a stupid question, but I cannot seem to find a way to tell readBin that I want to read 2-byte integers from the connection. The input file is 150,720 bytes long containing 75,360 short (2-byte) integers. But specifying "integer" or "int" for what in readBin only returns me a vector of length 37680, leading me to believe that sizeof(integer) or
2007 Mar 08
1
sink with R-code
I have the same question that Eusebio had: Is there a function similar to "sink" that redirect also R code to a file that is: sink("R001") x <- c(2,-6,-4,8,5,4,1,3,4,-9,0,1) A <- matrix(x, ncol=3) A A.prima <- t(A) A.prima dim(A) dim(A.prima) sink() create a file "R001" with contents: ------------------------------------------ [,1] [,2] [,3] [1,]