similar to: If and apply?

Displaying 20 results from an estimated 30000 matches similar to: "If and apply?"

2012 Jan 27
1
Looping column names
Hello, I have a data file that I want to run loess on for 36 columns, divide the original data by the new data, then dividing columns that end in A and B by those that end in C. However, I have something wrong in my first step and am completely stuck on the third. Could someone help me please? Here's a snippet of the data file: Order Target GC AA_001_A AA_001_B AA_001_C 1 a 0.584507042
2000 Sep 23
3
bug in apply with median
I have found a problem in R version 1.1.1 when using apply with the median function. The problem can be illustrated with the following data matrix: X1 X2 X3 1 2 3 4 5 6 7 8 NA Enter this data matrix as X and then try apply(X,2,median,na.rm=T) The problem here is that the median function returns a named scalar if the number of observations is odd, but returns an
2007 Apr 13
3
apply problem
Dear R-Help I am running apply on a data.frame containing factors and numeric columns. It appears to convert are columns into as.character? Does it convert data.frame into matrix? Is this expected? I wish it to recognise numerical columns and round numbers. Can I use another function instead of apply, or should I use a for loop in the case? > summary(xmat) A B
2012 Feb 13
2
Error in apply(x2, 1, diff) : dim(X) must have a positive length
Anyone knows hat might be the cause of this error? Thanks for any help! >library(MASS) > dif.mns = function(x2,tr1=.2,tr2=.3){ + #generates four different 'means' using + #difference scores from x2, an n x 2 matrix + #for use w/ bootstrap comparisons + diffs = apply(x2,1,diff) + mn1=mean(diffs) + mn2=mean(diffs,tr=.2) + mn3=mean(diffs,tr=.3) +
2006 Jun 04
2
surprising dates
I wonder if this is an intentional feature or an oversight. in some column summaries or in ifelse operations, apparently I am losing the date property of my vector. > a <- c(198012, 198101, 198102) > b <- a*100+31 > c <- as.Date( as.character(b), "%Y%m%d" ) > summary(c) Min. 1st Qu. Median Mean 3rd Qu. Max.
2010 Jul 20
2
best way to apply a list of functions to a dataset ?
Assuming I have a matrix of data (or under some restrictions that will become obvious, possibly a data frame), I want to be able to apply a list of functions (initially producing a single number from a vector) to the data and produce a data frame (for compact output) with column 1 being the function results for the first function, column 2 being the results for the second function and so on - with
2005 May 31
1
apply the function "factor" to multiple columns
I have a case where I would like to change multiple columns containing numbers to factors. I can change each column one at a time as in: TEMP.FACT$EXPOS01<-factor(TEMP.FACT$EXPOS01,levels=c(1,2,3),labels=c("No ne","Low Impact","MedHigh Imp")) TEMP.FACT$EXPOS02<-factor(TEMP.FACT$EXPOS02,levels=c(1,2,3),labels=c("No ne","Low
2007 May 02
1
Get the difference of values to their own median value
Hello, I've got a matrix (mail end) with the colnames x, y, z. In this matrix are different measurements. x and y are risign coordinates. With the following line I got the median value of z for all "x" AND "y" witch are the same (not every measurment in my list hast the same number of "x" and "y" values. Sometimes lines are missing. >MEDIAN <-
2009 Jul 20
2
calculating median with a condition
Hello, I am trying to calculate the median of numbers across each row for the data shown below , with the condition that if the number is negative, that it should be ignored and the median should be taken of only the positive numbers. For eg: data is in Column A,B,C. Column D and E demonstrates what I want to get as answer A B C Median median value -13.6688115 -32.50914055
2010 Dec 26
1
Question about mars() -function
Hi! I have some questions about MARS model's coefficient of determination. I use the MARS method in my master's thesis and I have noticed some problems with the MARS model's R^2. You can see the following example that the MARS model's R^2 is too big when i have used mars() -function for MARS model building, and when I have made MARS-model using a linear regression, it
2017 Aug 10
0
Creating New Variable Using Ifelse
Hi see in line > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Courtney > Benjamin > Sent: Thursday, August 10, 2017 5:55 AM > To: r-help at r-project.org > Subject: [R] Creating New Variable Using Ifelse > > Hello R Help List, > > I am an R novice and trying to use the ifelse function to create a new binary >
2012 Oct 30
6
standard error for quantile
Dear all I have a question about quantiles standard error, partly practical partly theoretical. I know that x<-rlnorm(100000, log(200), log(2)) quantile(x, c(.10,.5,.99)) computes quantiles but I would like to know if there is any function to find standard error (or any dispersion measure) of these estimated values. And here is a theoretical one. I feel that when I compute median from given
2013 May 07
2
recode categorial vars into binary data
Dear R-List, I would like to recode categorial variables into binary data, so that all values above median are coded 1 and all values below 0, separating each var into two equally large groups (e.g. good performers = 0 vs. bad performers =1). I have not succeeded so far in finding a nice solution to do that in R. I thought there might be a better way than ordering each column and recoding the
2013 May 07
2
recode categorial vars into binary data
Dear R-List, I would like to recode categorial variables into binary data, so that all values above median are coded 1 and all values below 0, separating each var into two equally large groups (e.g. good performers = 0 vs. bad performers =1). I have not succeeded so far in finding a nice solution to do that in R. I thought there might be a better way than ordering each column and recoding the
2006 Feb 21
1
feature not available
Hi I am working with this data: my data summary is: > summary(spi) open high low close volume Min. :4315 Min. :4365 Min. :4301 Min. :4352 Min. : 0 1st Qu.:4480 1st Qu.:4497 1st Qu.:4458 1st Qu.:4475 1st Qu.:11135 Median :4609 Median :4631 Median :4594 Median :4614 Median :14439 Mean :4620
2008 May 08
2
poisson regression with robust error variance ('eyestudy
Ted Harding said: > I can get the estimated RRs from > RRs <- exp(summary(GLM)$coef[,1]) > but do not see how to implement confidence intervals based > on "robust error variances" using the output in GLM. Thanks for the link to the data. Here's my best guess. If you use the following approach, with the HC0 type of robust standard errors in the
2006 Mar 16
1
running median and smoothing splines for robust surface f itting
loess() should be able to do robust 2D smoothing. There's no natural ordering in 2D, so defining running medians can be tricky. I seem to recall Prof. Koenker talked about some robust 2D smoothing method at useR! 2004, but can't remember if it's available in some packages. Andy From: Vladislav Petyuk > > Hi, > Are there any multidimenstional versions of runmed() and >
2012 Apr 07
6
Drawing a line in xyplot
i am trying to replicate the following graph using xyplot : attach(x) plot ( jitter(type), mortality, pch=16, xlim = c(0.25, 3.75)) lines ( c(1-0.375,1.375) , c ( median(mortality[type==1]), median(mortality[type==1])), lwd=5,col=2) lines ( c(2-0.375,2.375) , c ( median(mortality[type==2]), median(mortality[type==2])), lwd=5,col=2) lines ( c(3-0.375,3.375) , c ( median(mortality[type==3]),
2007 Mar 07
5
how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work
Hello R users, Problem.......I do not understand how to use "aggregate","by", or the appropriate "apply" to perform a function on data with more than one factor on unbalanced data... I have a data frame in the long format that does not contain balanced data. The ID is a unique identifier corresponding to the experimental unit that will later be examined by ANOVA,
2011 Nov 05
2
como ponderar casos en R
Hola a tod en s. Se trata de un tema que lleva tiempo rondándome la cabeza, pero que nunca he encontrado una solución. Se que existe el paquete survey, pero me gustaría saber si existe algo más sencillo. Por ejemplo, estaba analizando los últimos datos de la encuesta de equipamientos tecnológicos del INE y dicho fichero tiene dos variables con factores de elevación, una para hogares y otra para