An alternative using runif.
x <- round(runif(1, 0, 1), 2)
y <- round(runif(1, 0, 1-x), 2)
z <- round(1-x-y, 2)
sum1 <- cbind(x, y, z)
any(!(sum1[,1] + sum1[,2] + sum1[,3]))
Richard
On Tue, Jan 28, 2014 at 9:36 AM, S Ellison wrote:
> > I'd like to create a matrix with three columns
rle(is.na(a))
> max(rl$lengths[rl$values])
> #[1] 4
>
> A.K.
>
>
>
>
> On Wednesday, January 8, 2014 12:56 PM, Richard Kwock
> wrote:
> Another way:
>
> a = c(1,NA,NA,4,3,NA,NA,NA,NA,5)
>
> # find position of the non-NAs in the vector
> pos = which(
Another way:
a = c(1,NA,NA,4,3,NA,NA,NA,NA,5)
# find position of the non-NAs in the vector
pos = which(!is.na(a))
# this calculates the length by taking the differences between the
non-NA positions.
diff(pos)-1
#get the max
max(diff(pos)-1)
Richard
On Tue, Jan 7, 2014 at 7:36 PM, arun wrote:
As Duncan suggested, this will probably get you what you want.
You can set the transparency using alpha.f in adjustcolor().
x <- c(1:5)
color <- c(2,2,3,4,5)
color_transparent <- adjustcolor(color, alpha.f = 0.3)
plot(x, col = color, pch = 20, cex = 4)
plot(x, col = color_transparent, pch = 20,
Hi Elham,
>From the (\t), It looks like the data in your data.txt file is
tab-delimited. To take care of that, set the separator string to be: "sep =
'\t' " instead of "," when you read in the file.
text <- read.table(file = "data.txt", sep = "\t")
text
write.table(text, "textfile.csv", row.names
2, col = 4)
> foo <- placeGrob(foo,
> textGrob(lab = "The Beatles"),
> row = 1, col = 6)
>
> xyplot(1 ~ 1, legend = list(top = list(fun = foo)))
>
> In my case I changed "strwidth" to "cm" for the text as I
Hi All,
I am having some trouble getting lattice to display the legend names by row
instead of by column (default).
Example:
library(lattice)
set.seed(456846)
data <- matrix(c(1:10) + runif(50), ncol = 5, nrow = 10)
dataset <- data.frame(data = as.vector(data), group = rep(1:5, each = 10),
time
Use "saveold" instead of "save" when you save your dataset in stata.
I don't think foreign library in R supports stata 13 yet.
Richard
On Wed, Oct 2, 2013 at 3:11 PM, Pablo Menese Camargo wrote:
> foreign package does not support dataset saved at stata 13.
> anyone knows any wayt to make it wor
Hi,
Check out:
https://stat.ethz.ch/pipermail/r-help/2010-December/262626.html
> demo(error.catching)
> tryCatch.W.E
mylist <- list(NULL)
mylist_warns <- list(NULL)
old.warn <- options(warn=1)
x <- c(1:5)
for (i in 1:2) {
assign("last.warning", NULL, envir = baseenv())
temp <- tryCatch.W.E
..." in the panel function.
Hope that helps.
Richard
On Mon, Sep 23, 2013 at 11:23 AM, Richard Kwock wrote:
> Hi,
>
> To answer your second question you can do something like this:
>
> p<-xyplot(dvy ~ sessidx | case, group = numph, data=d66df, col = c(1:4),
> layout=
Hi,
To answer your second question you can do something like this:
p<-xyplot(dvy ~ sessidx | case, group = numph, data=d66df, col = c(1:4),
layout=c(1, 3), xlab= "Sessions",
ylab = "Number of Seconds",
type="l")
update(p, panel=function(...){
panel.xyplot(...)
panel.a
Hi,
I believe the function you are looking for is:
which("yourdata" == 0, arr.ind = T)
The "arr.ind" parameter in the "which" function will return you a
matrix with row, column indices for where there are 0's in your
dataset.
set.seed(6584)
data <- matrix(sample(c(0,1), 36, replace = T), nc = 6
Hi Tony,
The dimnames parameter is only in the matrix() function, not in the
as.matrix() function.
#So you can do:
A <- matrix(rbind(Fert,M), nrow = nrow(rbind(Fert,M)))
A
#This for example will allow you to name your row and colums.
B <- matrix(rbind(Fert,M), nrow = nrow(rbind(Fert,M)), dimname
Try this:
data <- data.frame(x1=rnorm(5),x2=rnorm(5),x3=rnorm(5),x4=rnorm(5))
data <- round(data,digits=3)
#get the total counts
n = prod(dim(data))
#set up a dummy array/matrix
dummy <- rep(F, n/2)
dummy[sample(1:(n/2), n*.2)] <- T
# 5x2 dummy matrix with T and F
matrix(dummy, nc = 2)
#subset
14 matches
Mail list logo