Displaying 20 results from an estimated 1000 matches similar to: "summary in functions"
2011 Feb 15
1
all.equal: subscript out of bounds
When I do
> all(all$X.Time == all$Y.Time);
[1] TRUE
as expected, but
> all.equal(all$X.Time,all$Y.Time);
Error in target[[i]] : subscript out of bounds
why?
thanks!
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
http://mideasttruth.com http://honestreporting.com http://dhimmi.com
http://jihadwatch.org http://pmw.org.il http://ffii.org
The dark past once was the
2006 Mar 17
6
removing NA from a data frame
Hi,
It appears that deal does not support missing values (NA), so I need to
remove them (NAs) from my data frame.
how do I do this?
(I am very new to R, so a detailed step-by-step
explanation with code samples would be nice).
Some columns (variables) have quite a few NAs, so I would rather drop
the whole column than sacrifice all the rows (observations) which have
NA in that column.
How do I
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
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
2011 Jul 12
1
how to find out whether a string is a factor?
I have two data frames:
> str(ysmd)
'data.frame': 8325 obs. of 6 variables:
$ X.stock : Factor w/ 8325 levels "A","AA","AA-",..: 2702 6547 4118 7664 7587 6350 3341 5640 5107 7589 ...
$ market.cap : num -1.00 2.97e+10 3.54e+08 3.46e+08 -1.00 ...
$ X52.week.low : num 40.2 22.5 27.5 12.2 20.7 ...
$
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 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/)
2011 Jul 11
1
plot means ?
Hi,
I need this plot:
given: x,y - numerical vectors of length N
plot xi vs mean(yj such that |xj - xi|<epsilon)
(running mean?)
alternatively, discretize X as if for histogram plotting and plot mean y
over the center of the histogram group.
is there a simple way?
thanks!
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://thereligionofpeace.com
2013 Jan 18
5
select rows with identical columns from a data frame
I have a data frame with several columns.
I want to select the rows with no NAs (as with complete.cases)
and all columns identical.
E.g., for
--8<---------------cut here---------------start------------->8---
> f <- data.frame(a=c(1,NA,NA,4),b=c(1,NA,3,40),c=c(1,NA,5,40))
> f
a b c
1 1 1 1
2 NA NA NA
3 NA 3 5
4 4 40 40
--8<---------------cut
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 Sep 20
1
aggregate help
I want to count attributes of IDs:
--8<---------------cut here---------------start------------->8---
z <- data.frame(id=c(10,20,10,30,10,20),
a1=c("a","b","a","c","b","b"),
a2=c("x","y","x","z","z","y"),
2011 Feb 15
4
string parsing
I am trying to get stock metadata from Yahoo finance (or maybe there is
a better source?)
here is what I did so far:
yahoo.url <- "http://finance.yahoo.com/d/quotes.csv?f=j1jka2&s=";
stocks <- c("IBM","NOIZ","MSFT","LNN","C","BODY","F"); # just some samples
socket <-
2011 Feb 14
3
help with aggregate()
Hi,
I am trying to aggregate some data and I am confused by the results.
I load a data frame "all" from a csv file, and then I do:
(FOO,BAR,X,Y come from the header line in the csv file,
BTW, how do I rename a column?)
byFOO <- aggregate(list(all$BAR,all$QUUX,all$X/all$Y),
by = list(FOO=all$FOO),
FUN = mean);
I expect a data frame with 4
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 Jul 06
2
Mixed Models providing a correlation structure.
Hi folks,
I was wondering how to run a mixed models approach to analyze a linear
regression with a user-defined covariance structure.
I have my model
y = xa +zb +e and
b ~ N (0, C*sigma_square). (and a is a fixed effects)
I would like to provide R the C (variance-covariance) matrix
I can easily provide an example, but at this point I am first trying to know
what is the best package the
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
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.
--
2012 Feb 10
2
the value of the last expression
Is there an analogue of common lisp "*" variable which contains the
value of the last expression?
E.g., in lisp:
> (+ 1 2)
3
> *
3
I wish I could recover the value of the last expression without
re-evaluating it.
thanks
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://camera.org http://ffii.org
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
2013 Jan 04
4
non-consing count
Hi,
to count vector elements with some property, the standard idiom seems to
be length(which):
--8<---------------cut here---------------start------------->8---
x <- c(1,1,0,0,0)
count.0 <- length(which(x == 0))
--8<---------------cut here---------------end--------------->8---
however, this approach allocates and discards 2 vectors: a logical
vector of length=length(x) and an