Displaying 7 results from an estimated 7 matches for "tmpdf".
Did you mean:
tmpd
2004 Jan 21
2
subset select within a function
Dear all,
I'd like to subset a df within a function, and use select for choosing
the variable. Something like (simplified example):
mydf <- data.frame(a= 0:9, b= 10:19)
ttt <- function(vv) {
tmpdf <- subset(mydf, select= vv)
mean(tmpdf$vv)
}
ttt(mydf$b)
But this is not the correct way. Any help?
Thanks in advance
Juli
2010 Oct 04
1
Splitting a DF into rows according to a column
...ro, molestie laoreet metus dapibus eu. Mauris justo ante,
mattis et pulvinar a, varius pretium eros. Curabitur fringilla dui ac dui
rutrum pretium. Donec sed magna adipiscing nisi accumsan congue sed ac est.
Vivamus lorem urna, tristique quis accumsan quis, ullamcorper aliquet
velit."
> tmpDF <- data.frame(Column1=rep(unlist(strsplit(loremIpsum,"
")),length.out=510),Column2=runif(510,min=0,max=1e8))
is to be split into DFs with 50 entries in an ordered manner according to
column2 (first DF ist o contain the rows with the 50 largest numbers, ...).
Here is what I have bee...
2005 Jul 07
1
Tables: Invitation to make a collective package
...ol[logCol]
names(tmpList) <- names(valCol)
return(tmpList)
}
# User defines one factor
else {
namesdf <- names(df)
pos <- which(namesdf == by)
stopifnot(is.factor((df[[pos]])))
numF <- table(df[[pos]])
for(i in 1:length(numF)) {
tmpdf <- subset(df, df[[pos]] == names(numF[i]))
logCol <- sapply(tmpdf, is.numeric)
for (j in 1:ncol(tmpdf)) {
if (logCol[j]) {
x <- as.matrix(tmpdf[ ,j])
tbl <- tb.make.table.II(x, k, breaks, right)
newFY &l...
2011 Jul 11
3
Stacked bar plot of frequency vs time
Hi All,
New to R, but committed. I looked in a number of places but can't figure out
my current problem. I have date of the type:
Time Type1 Type2 Type3
1 .50 .25 .25
4 .55 .25 .20
5 .65 .20 .15
etc
which describe the frequency of types 1, 2 and 3 (adding up to 100%) over
time. I would like to create a stacked bar chart showing these
2010 Dec 07
2
Efficient way to use data frame of indices to initialize matrix
I have a data frame with three columns, x, y, and a. I want to create a matrix from these values such that for matrix m:
m[x,y] == a
Obviously, I can go row by row through the data frame and insert the value a at the correct x,y location in the matrix. I can make that slightly more efficient (perhaps), by doing something like this:
> for (each.x in unique(df$x)) m[each.x, df$y[df$x ==
2012 Feb 06
1
ggplot2 geom_polygon fill
...polyhi = 2 - barwidth/2
xs = rep(c(polylo,polyhi,polyhi,polylo), 7)
# make the ys of the polygon
tmp1 = c(0, smalldummy$lineposx[1:7])
tmp2 = c(0, smalldummy$lineposx[8:14])
ys = c()
for(i in 1:7) {
nu = c(tmp1[i], tmp2[i], tmp2[i+1], tmp1[i+1])
ys = c(ys, nu)
}
m = as.factor(rep(0:6, each=4))
tmpdf = data.frame(xs, ys, mRS = m)
bigdummy = merge(smalldummy, tmpdf, by = "mRS")
ggplot(data = bigdummy, aes(x = treatment, y = rsfreq, fill = mRS)) +
geom_bar(aes(width = barwidth),stat="identity",position="fill") +
geom_text(aes(label=as.character(mRS),
y = i...
2012 Feb 07
2
Vectorizing a loop
Hello Folks,
I'm trying to vectorize a loop that processes rows of a dataframe. It
involves lots of conditionals, such as "If column 10 == 3, and if column
3 is True, and both column 5 and 6 are False, then set column 4 to True".
So, for example, any ideas about vectorizing the following?
df = data.frame( list(a=c(1,2,3,4),