Displaying 20 results from an estimated 30 matches for "marketfusionanalytics".
2011 Aug 05
2
summing columns with NAs present
...a frame with some NAs.
test<-data.frame(a=c(1,2,NA),b=c(10,NA,20))
I need to sum up values in 2 variables. However:
test$a+test$b
procudes NAs in rows that have NAs.
How could I sum up columns while ignoring NAs (the way the function
sum(..., na.rm=T) works?
Thank you!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Sep 16
2
"rounding" to a number that is LOWER than my number
...ould allow me to "round" down, rather than up?
For example, x<-1.98
I'd like to get 1.9 - rather than 2.0.
Reason - I am creating a minimum for an axis for a plot, and I need it
to be lower than x (which, in turn, is the lowest number already).
Thank you!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2013 Feb 01
2
expand.grid on contents of a list
Hello!
I have a list of variable length. One example is:
X=vector("list",3)
X[[1]]=1:2
X[[2]]=1:2
X[[3]]=1:2
How could I run expand.grid on the elements of X so that the results would
be the same as expand.grid(1:2,1:2,1:2)?
Thank you!
Dimitri
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
2011 Aug 01
1
Identifying US holidays
...2010)
holidayNYSE()
However, I don't need all the NYSE holidays (like Good Friday). Just
the major US holidays - New Years, MLK, Memorial Day, Independence
Day, Labor Day, Halloween, Thanksgiving, Christmas.
Is there any way to identify major US holidays?
Thanks a lot!
-
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Nov 10
3
optim seems to be finding a local minimum
...nsf,myDV=DV)
return(sumofdevs)
}
# Optimizing using optim:
myopt <- optim(fn=myfunc, par=c(0.1,max(IV)), method="L-BFGS-B", lower=0)
(myopt)
myfunc(myopt$par)
## Comparing this solution to Excel Solver solution:
myfunc(c(0.888452533990788,94812732.0897449))
--
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Aug 04
2
Efficient way of creating a shifted (lagged) variable?
...for(i in 1:length(temp)){
names(temp)[i]<-paste(names(x),".lag",i,sep="")
}
return(temp)
}
### Running mylag to get my result:
myvars<-c("var1","var2")
for(i in myvars) {
y<-cbind(y,mylag(y[i]),max.lag=2)
}
(y)
--
Dimitri Liakhovitski
marketfusionanalytics.com
2012 Jan 27
1
Overimposing one map in ssplot onto another
...ot;]]<-groups
can2 at data$groups<-as.factor(can2 at data$groups)
classcolors <- rainbow(6)
spplot(can2,zcol="groups",col.regions=classcolors,colorkey =
FALSE,lwd=.4,col='white',
par.settings = list(axis.line = list(col='transparent')))
--
Dimitri Liakhovitski
marketfusionanalytics.com
2013 Jan 29
4
Fastest way to compare a single value with all values in one column of a data frame
...f(y$a>min(x$a)){
whichmin<-which(x$a==min(x$a))
x[whichmin,]<-y[1,]
}
I am wondering if there is a faster way of doing it. What would be the
fastest possible way? I'd have to do it, unfortunately, many-many times.
Thank you very much!
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
2013 Feb 12
3
grabbing from elements of a list without a loop
...]]
}
newlist<-do.call(cbind,newlist)
(newlist)
I was wondering if there is any way to avoid the loop above and make it
faster.
In reality, I have a much longer list, each of my data frames is much
larger and I have to do it MANY-MANY times.
Thanks a lot!
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
2011 Jul 21
4
squared "pie chart" - is there such a thing?
...es, L-shapes, etc.). I realize there are many possible
positions and shapes - even for 3 components. But I don't really care
where components are located within the square - as long as they are
there.
Is there a package that could do something like that?
Thanks a lot!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Jul 19
1
calculating mean excluding zeros
Sorry if it's been discussed before - don't seem to find it.
I'd like to calculate a mean while ignoring zeros.
"mean" doesn't seem to have an option for that.
Any other function/package that could do it?
Thanks for a pointer!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Jul 29
1
splitting a string based on the last underscore
...ach string:
1. Its unique part that comes before the last "_", i.e.: "a1","a2","a3_bla".
2. The part that comes after the last "_" and before ".o" at the end,
i.e.: 2.5, 2.53, 1.
Thank you so much for your help!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2011 Sep 13
1
using vif from package "car" - "aliased coefficients in the model"
...en I tried to run vif(myreg) from the package "car".
However, it's giving me an error: in vif.lm(regr.f) : there are
aliased coefficients in the model
Very sorry for my question: Is there any way to get the vif's for all
predictors?
Thank you very much!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2013 Feb 07
1
Select only unique rows from a data frame
...r example:
x=as.data.frame(matrix(c(1,2,3,
1,2,3,
1,2,2,
1,2,2,
1,1,1),ncol=3,byrow=T))
I would like to find y - a data frame that only has the unique rows from x,
i.e.:
1,2,3
1,2,2
1,1,1
Thanks a lot for your hints!
Dimitri
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
2011 Aug 02
3
identifying weeks (dates) that certain days (dates) fall into
...1]][1]-7),
which(weekly$week==weekly$week[weekly$week>july4[2]][1]-7))
weekly$flag<-0
weekly$flag[myrows]<-1
It's clumsy - because actually, my vector of dates of interest (july4
above) is much longer.
Is there maybe a more elegant way of doing it?
Thank you!
--
Dimitri Liakhovitski
marketfusionanalytics.com
2013 Feb 03
1
Looping through rows of all elements of a list that has variable length
...t;list",nrow(mygrid))
for(gridrow in 1:nrow(mygrid)){ # gridrow<-1
row.a<-mygrid[gridrow,1]
row.b<-mygrid[gridrow,2]
out[[gridrow]]<-sum(l.long[[1]][row.a,])+sum(l.long[[2]][row.b,])
}
Thank you very much for any suggestions!
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
2011 Aug 12
1
Which Durbin-Watson is correct? (weights involved) - using durbinWatsonTest and dwtest (packages car and lmtest)
...R-VARofY))
n<-200
set.seed(123)
cases.for.sample<-sample(100000,n,replace=F)
mysample<-mypop[cases.for.sample,]
mysample<-cbind(mysample[k+2],mysample[1:(k+1)]) #dim(sample)
weight<-rep(1:10,20);weight<-weight[order(weight)]
mysample$weight<-weight
--
Dimitri Liakhovitski
marketfusionanalytics.com
2012 Feb 03
1
incomplete final line found on <name of my sourced function file>
...atesvar]],myagg[[invars[1]]],type="l",lwd=3,lty=i,col=all.colors[1])
for(i in 2:length(invars)){
points(myagg[[datesvar]],myagg[[invars[i]]],type="l",lwd=2,lty=1,col=all.colors[i])
# or lty=i
mycolors<-c(mycolors,(i))
}
return(myagg)
}
--
Dimitri Liakhovitski
marketfusionanalytics.com
2012 Jul 11
2
help with merging 2 data frames
...T,all.y=F)
out2<-merge(x,y[-1],by.x=c("a","b"),by.y=c("a3","b"),all.x=T,all.y=F)
(out1); (out2)
# Now I need to merge these 2 - however, the next line doubles the
number of entries:
merge(out1,out2,by=names(out1),all.x=T,all.y=T)
--
Dimitri Liakhovitski
marketfusionanalytics.com
2012 Dec 07
2
Assigning cases to groupings based on the values of several variables
...for(i in 1:nrow(groupings)){ # i<-1
mysex<-groupings[i,"sex"]
myage<-groupings[i,"age"]
mydata[(mydata$sex %in% mysex)&(mydata$age %in%
myage),"mygroup.m3"]<-groupings[i,"mygroup"]
}
(mydata)
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]