similar to: how to quote "factors" in a function?

Displaying 20 results from an estimated 20000 matches similar to: "how to quote "factors" in a function?"

2011 Sep 22
2
Proportions of a vector
> > Hi all, > I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) > > I want to return a vector with the corresponding probabilities based on the > amount of times the numbers occurred. For example, I should get the > following vector for xm: > prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9) > Using prop.table gives: Usage (with table) > prob.xm <-
2008 Aug 11
1
question about knn
Hello all, am a newby in R, am trying the knn function, and am doing just a stupid test : > knn(c(1,2,3,4,5,6), c(3), k=4 ,prob=TRUE,factor(c(1:6))) the result is unstable !! i have each time different result : [1] 5 attr(,"prob") [1] 0.1666667 Levels: 1 2 3 4 5 6 [1] 4 attr(,"prob") [1] 0.1666667 Levels: 1 2 3 4 5 6 [1] 1 attr(,"prob") [1] 0.1666667 Levels:
2012 Apr 03
1
Create Model Object (setClass?setMethod?)
Hi all, I have a self written likelihood as a model and functions to optimize and get fitted values, confidence intervals ect. I wonder if there is a way to define a 'class', or a 'model' (or a certain object)? so that I can use 'summary' to produce a summary like it does for a lm object. Also, it should be able to use 'predict' and 'plot' and other
2003 May 01
2
What' wrong?
I try to do single proportion test on my category data. Here is my R script: library("ctest") catSignifTest <- function( catFile ) { ############################################################### ## Get the data sets from text file catData <- read.table( catFile ) ncols <- length(catData) nrows <- length(catData[,1]) ncol1 <- ncols - 1 probeNbr
2011 Nov 11
1
Random-walk Metropolis-Hasting
Following is my code, can some one help on the error at the bottom? > mh<-function(iterations,alpha,beta){ + data<-read.table("epidemic.txt",header = TRUE) + attach(data, warn.conflicts = F) + k<-97 + d <- (sqrt((x-x[k])^2 + (y-y[k])^2)) + p <- 1-exp(-alpha*d^(-beta)) + p.alpha<-1 - exp(-3*d^(-beta)) + p.beta <- 1 - exp(alpha*d^(-2)) +
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi, I have a matrix, say m=matrix(c( 983,679,134, 383,416,84, 2892,2625,570 ),nrow=3 ) i can find its row/col sum by rowSums(m) colSums(m) How do I divide each row/column by its rowSum/colSums and still return in the matrix form? (i.e. the new rowSums/colSums =1) Thanks. Casper -- View this message in context:
2008 Nov 08
3
Fitting a modified logistic with glm?
Hi all, Where f(x) is a logistic function, I have data that follow: g(x) = f(x)*.5 + .5 How would you suggest I modify the standard glm(..., family='binomial') function to fit this? Here's an example of a clearly ill-advised attempt to simply use the standard glm(..., family='binomial') approach: ######## # First generate some data ######## #define the scale and location of
2019 Mar 03
2
bug: sample( x, size, replace = TRUE, prob= skewed.probs) produces uniform sample
When `length( skewed.probs ) > 200' uniform samples are generated in R-devel. R-3.5.1 behaves as expected. `epsilon` can be a lot bigger than illustrated and still the uniform distribution is produced. Chuck > set.seed(123) > > epsilon <- 1e-10 > > ## uniform to 200 then small > p200 <- prop.table( rep( c(1, epsilon), c(200, 999-200))) > ## uniform to 201
2008 May 08
1
scrime Package simulatedSNP function
Hello, I need some help with the simulatedSNPs function from scrime package. I am trying to simulate some genotype of a case/control disease locus. The allele frequence are cases/controls Sample cases controls 2000 .5 .10 1500 .6 .40 In each of the row, i need to simulate 100 snp and calculate the pvalue ##############Download Scrime
2010 Oct 11
2
dot plot by group
Hi all, I have the folloing data table %%%%%%%%%%%%%%%%%% Type BATCH RESPONSE SHORT A 22 SHORT A 3 SHORT A 16 SHORT A 14 SHORT A 8 SHORT A 27 SHORT A 11 SHORT A 17 SHORT B 12 SHORT B 17 SHORT B 11 SHORT B 10 SHORT B 16 SHORT B 18 SHORT B 15 SHORT B 13 SHORT B 9 SHORT B 20 SHORT C 4 SHORT C 16 SHORT C 32 SHORT C 11 SHORT C 9 SHORT C 25 SHORT C 27 SHORT C 12 SHORT C 26 SHORT C 7 SHORT C 14 LONG A
2011 Aug 24
4
Column of probabilities
Hi all, I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) I want to return a vector with the corresponding probabilities based on the amount of times the numbers occurred. For example, I should get the following vector for xm: prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9) Any help greatly appreciated. -- Thanks, Jim. [[alternative HTML version deleted]]
2006 Dec 30
2
Error: cannot take a sample larger than the population
Hi, In Splus7 this statement xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 )) worked fine, but in R the interpreter reports that the length of the vector to chose c(0,1,2) is shorter than the size of many times I want to be selected from the vector c(0,1,2). Any good reason? See below the error. > xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 )) Error in
2012 May 16
3
triangular matrices input/output
Hi, Is there any package that deals with triangular matrices? Say ways of inputting an upper (lower) triangular matrix? Or convert a vector of length 6 to an upper (lower) triangular matrix (by row/column)? Thanks! ----- ###################### PhD candidate in Statistics Big R Fan Big LEGO Fan Big sTaTs Fan ###################### -- View this message in context:
2012 Oct 26
1
Openbugs- Array Index
Hi, I'm working on the codes below however every time I run them when they get to OpenBUGS I keep getting the error message: array index is greater than array upper bound for hab. Any help would be greatly appreciated, Suzie Codes: ungulate <- read.csv(file.choose ()) #ungulate ungulate <- as.matrix(ungulate);colnames(ungulate)<-NULL;rownames(ungulate)<-NULL
2012 Mar 10
3
function input as variable name (deparse/quote/paste) ??
Hi all Say I have a function: myname=function(dat,x=5,y=6){ res<<-x+y-dat } for various input such as myname(dat1) myname(dat2) myname(dat3) myname(dat4) myname(dat5) how should I modify the 'res' line, to have new informative variable name correspondingly, such as dat1.res dat2.res dat3.res dat4.res dat5.res stored in the workspace. This is only an example of a complex
2010 Mar 07
3
barplot with factors problem
http://www.harding.edu/fmccown/R/#autosdatafile http://www.harding.edu/fmccown/R/#autosdatafile I am tring to get a barchat by factors, following the example in that link above. =========================== x=c(145,40,40,120,180, 140,155,90,160,95, 195,150,205,110,160, 45,40,195,65,145, 195,230,115,235,225, 120,55,50,80,45 ) y2=c( rep(as.character(1),5), rep(as.character(2),5),
2006 Jul 04
1
problem getting R 2.3.1 svn r38481 to pass make check-all
Hi, I noticed this problem on my home desktop running FC4 and again on my laptop running FC5. Both have previously compiled and passed make check-all on 2.3.1 svn revisions from 10 days ago or so. On both these machines, make check-all is consistently failing (4 out of 4 attempts on the FC 4 desktop and 3 out of 3 on the FC 5 laptop) in the p-r-random-tests tests. This is with both default
2010 Feb 05
1
Incompatible types error
I'm trying to write a loop for a series of nested functions. and I get an incompatible types error when trying to run it. It's supposed to be a simulation (1000 iterations) with a random value for "rand" being chosen each time. After each rand value is chosen, the rest of the functions are evaluated with this given rand value and their "Fitness" sum value is saved and
2008 Jun 05
4
do i need posix users/groups in ldap
Hi all, i'm a bit confused, can i setup samba (3.0.30) with LDAP backend, and have the "posix/local linux" users and groups reside in the /etc/groups /etc/shadow ect. ect (the standard linux files) ??? or do i have to put them in ldap also ?? (is there a choice?) Greets, Collen
2011 Jul 17
3
?Accuracy of prop.test
I have just joined this list (and just started using R), so please excuse any etiquette breaches as I do not yet have a feel for how the list operates. I am in the process of teaching myself statistics using R as my utility as my ultimate goals cannot be satisfied by Excel or any of the plug-ins I could afford. I am currently looking at chap12 page 552 of Weiss's Introductory Statistics