similar to: sum(hist$density) == 2 ?!

Displaying 20 results from an estimated 1000 matches similar to: "sum(hist$density) == 2 ?!"

2012 Oct 18
3
how to concatenate factor vectors?
How do I concatenate two vectors of factors? --8<---------------cut here---------------start------------->8--- > a <- factor(5:1,levels=1:9) > b <- factor(9:1,levels=1:9) > str(c(a,b)) int [1:14] 5 4 3 2 1 9 8 7 6 5 ... > str(unlist(list(a,b),use.names=FALSE)) Factor w/ 9 levels "1","2","3","4",..: 5 4 3 2 1 9 8 7 6 5 ...
2012 Aug 30
3
apply --> data.frame
Is there a way for an apply-type function to return a data frame? the closest thing I think of is foo <- as.data.frame(sapply(...)) names(foo) <- c(....) is there a more "elegant" way? Thanks! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://palestinefacts.org http://dhimmi.com http://honestreporting.com
2012 Mar 20
2
igraph: decompose.graph: Error: protect(): protection stack overflow
I just got this error: > library(igraph) > comp <- decompose.graph(gr) Error: protect(): protection stack overflow Error: protect(): protection stack overflow > what can I do? the digraph is, indeed, large (300,000 vertexes), but there are very many very small components (which I would rather not discard). PS. the doc for decompose.graph does not say which mode is the default. --
2013 Sep 18
2
strsplit with a vector split argument
Hi, I find this behavior unexpected: --8<---------------cut here---------------start------------->8--- > strsplit(c("a,b;c","d;e,f"),c(",",";")) [[1]] [1] "a" "b;c" [[2]] [1] "d" "e,f" --8<---------------cut here---------------end--------------->8--- I thought that it should be identical to this:
2006 May 11
3
cannot turn some columns in a data frame into factors
Hi, I have a data frame df and a list of names of columns that I want to turn into factors: df.names <- attr(df,"names") sapply(factors, function (name) { pos <- match(name,df.names) if (is.na(pos)) stop(paste(name,": no such column\n")) df[[pos]] <- factor(df[[pos]]) cat(name,"(",pos,"):",is.factor(df[[pos]]),"\n")
2012 Aug 27
1
write.matrix.csr data conversion
> write.matrix.csr(mx, y = y, file = file) > table(y) 0 1 5194394 23487 $ cut -d' ' -f1 f | sort | uniq -c 23487 2 5194394 1 i.e., 0 is written as 1 and 1 is written as 2. why? is there a way to disable this? -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://palestinefacts.org
2012 Feb 08
4
"unsparse" a vector
Suppose I have a vector of strings: c("A1B2","A3C4","B5","C6A7B8") [1] "A1B2" "A3C4" "B5" "C6A7B8" where each string is a sequence of <column><value> pairs (fixed width, in this example both value and name are 1 character, in reality the column name is 6 chars and value is 2 digits). I need to
2012 Feb 10
2
naiveBayes: slow predict, weird results
I did this: nb <- naiveBayes(users, platform) pl <- predict(nb,users) nrow(users) ==> 314781 ncol(users) ==> 109 1. naiveBayes() was quite fast (~20 seconds), while predict() was slow (tens of minutes). why? 2. the predict results were completely off the mark (quite the opposite of the expected overfitting). suffice it to show the tables: pl: android blackberry ipad
2012 Feb 13
1
entropy package: how to compute mutual information?
suppose I have two factor vectors: x <- as.factor(c("a","b","a","c","b","c")) y <- as.factor(c("b","a","a","c","c","b")) I can compute their entropies: entropy(table(x)) [1] 1.098612 using library(entropy) but it is not clear how to compute their mutual information
2011 Jul 12
3
when to use `which'?
when do I need to use which()? > a <- c(1,2,3,4,5,6) > a [1] 1 2 3 4 5 6 > a[a==4] [1] 4 > a[which(a==4)] [1] 4 > which(a==4) [1] 4 > a[which(a>2)] [1] 3 4 5 6 > a[a>2] [1] 3 4 5 6 > seems unnecessary... -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031 http://jihadwatch.org http://palestinefacts.org http://mideasttruth.com
2011 Dec 21
4
qqnorm & huge datasets
Hi, When qqnorm on a vector of length 10M+ I get a huge pdf file which cannot be loaded by acroread or evince. Any suggestions? (apart from sampling the data). Thanks. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://mideasttruth.com http://honestreporting.com http://camera.org http://openvotingconsortium.org http://pmw.org.il
2017 Nov 09
2
[R-pkgs] Release of ess 0.0.1
> * Jorge Cimentada <pvzragnqnw at tznvy.pbz> [2017-11-09 00:02:53 +0100]: > > I'm happy to announce the release of ess 0.0.1 a package designed to > download data from the European Social Survey Given the existence of ESS (Emacs Speaks Statistics - https://ess.r-project.org/) the package name "ess" seems unfortunate. -- Sam Steingold (http://sds.podval.org/) on
2012 Nov 19
2
generated list element names
How can I create lists with element names created on the fly? --8<---------------cut here---------------start------------->8--- > list (foo = 10) $foo [1] 10 > list ("foo" = 10) $foo [1] 10 > list (paste("f","oo",sep="") = 10) Error: unexpected '=' in "list (paste("f","oo",sep="") ="
2012 Aug 27
1
matrix.csr %*% matrix --> matrix
When a sparse matrix is multiplied by a regular one, the result is usually not sparse. However, when matrix.csr is multiplied by a regular matrix in R, a matrix.csr is produced. Is there a way to avoid this? Thanks! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://palestinefacts.org http://truepeace.org
2012 Nov 05
1
no method for coercing this S4 class to a vector
all of a sudden, after a SparseM upgrade(?) I get this error: > str(z) Formal class 'matrix.csr' [package "SparseM"] with 4 slots ..@ ra : num [1:85372672] -0.4288 0.0397 0.0104 -0.1843 -0.1203 ... ..@ ja : int [1:85372672] 1 2 3 4 5 6 7 8 9 10 ... ..@ ia : int [1:699777] 1 123 245 367 489 611 733 855 977 1099 ... ..@ dimension: int [1:2] 699776 122
2011 Feb 15
2
strptime format = "%H:%M:%OS6"
I read a dataset with times in them, e.g., "09:31:29.18761". I then parse them: > all$X.Time <- strptime(all$X.Time, format = "%H:%M:%OS6"); and get a vector of NAs (how do I check that except for a visual inspection?) then I do > options("digits.secs"=6); > all$X.Time <- strptime(all$X.Time, format = "%H:%M:%OS"); and it, apparently, works:
2012 Apr 04
2
recover lost global function
Since R has the same namespace for functions and variables, > c <- 1 kills the global function, which can be restored by > c <- get("c",mode="function") Is there a way to prevent R from overriding globals or at least warning when I do that or at least warning when I replace a functional value with non-functional? thanks. -- Sam Steingold (http://sds.podval.org/)
2012 Oct 07
2
a merge() problem
I know it does not look very good - using the same column names to mean different things in different data frames, but here you go: --8<---------------cut here---------------start------------->8--- > x <- data.frame(a=c(1,2,3),b=c(4,5,6)) > y <- data.frame(b=c(1,2),a=c("a","b")) >
2012 Apr 04
2
plot with a regression line(s)
I am sure a common need is to plot a scatterplot with some fitted line(s) and maybe save to a file. I have this: plot.glm <- function (x, y, file = NULL, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), main = NULL) { m <- glm(y ~ x) if (!is.null(file)) pdf(file = file) plot(x, y, xlab = xlab, ylab = ylab, main = main) lines(x, y =
2012 Feb 24
1
count.fields inconsistent with read.table?
Hi, batch is a vector of lines returned by readLines from a NL-line-terminated file, here is the relevant section: ========================================================= AA BB CC DD EE FF GG H H JJ KK LL MM ========================================================= as you can see, a line is corrupt; two CRLF's are inserted. This is okay, I drop the bad lines, at least I hope I do: