I would like to apply some function on each row of a dataframe in R.
The function can return a single-row dataframe or nothing (I guess 'return ()' return nothing?).
I would like to apply this function on each of the rows of a given dataframe, and get the resulting dataframe (which is possibly shorter, i.e. has less rows, than the orig...
Hi,
can I insert a vector as a row in a data.frame? How?
...
I have the following dataframe (df)
start end
1 14379 32094
2 151884 174367
3 438422 449382
4 618123 621256
5 698271 714321
6 973394 975857
7 980508 982372
8 994539 994661
9 1055151 1058824
. . .
. . .
. . .
And a long vector with numeric values (vec).
I would like to add to eac...
I have the following dataframe (df)
start end
1 14379 32094
2 151884 174367
3 438422 449382
4 618123 621256
5 698271 714321
6 973394 975857
7 980508 982372
8 994539 994661
9 1055151 1058824
. . .
. . .
. . .
And a long boolean vector with boolean values (vec).
I would like to fi...
hello
How can I use a zoo object with the PerformanceAnalytics package?
It says that I need a timeseries but I can convert it properly.
thanks
...
Has anyone worked with NY police stops data mentioned in Gelman, Hill book Data Analysis Using Reg. and Multi/Hier Modeling (ARM). The data is under
http://www.stat.columbia.edu/~gelman/arm/examples/police/
the file is frisk_with_noise.dat. I removed the description part of this data, renamed past.arrests as arrests, saved it as frisk....
Possible Duplicate:
Given a random variable with probability density function f(x), how to compute the expected value of this random variable in R?
Given a random variable with probability density function f(x), how to compute the expected value of this random variable in R?
...
Given a random variable with probability density function f(x), how to compute the expected value of this random variable in R?
...
I noticed that sometimes I get errors in my R scripts when I forget checking whether the dataframe I'm working on is actually empty (has zero rows).
For example, when I used apply like this
apply(X=DF,MARGIN=1,FUN=function(row) !any(vec[ row[["start"]]:row[["end"]] ]))
and DF happened to be empty, I got an error about the subscripts.
...
I'm used to work on my R scripts with some GUI, so I can easily run commands line-by-line, then pause and inspect my objects as they are created and changed.
I currently need to work with some data on a remote server. Is it possible to run line-by-line using R console or some other application (please, not vi) that does not require real...
In the statistics programming language R, the following formula (as used in lm() or glm())
z ~ (x+y)^2
is equivalent to
z ~ x + y + x:y
Assuming, I only have continuous predictors, is there a concise way to obtain
z ~ I(x^2) + I(y^2) + I(x) + I(y) + I(x*y)
A formula that does the right thing for factor predictors is a plus.
O...
I´m trying to produce a sorted table and export in to latex. However it seems xtable cannot cope with sorted tables. Suggestions?
a<-sample(letters,500,replace=T)
b<-table(a)
c<-sort(table(a),decreasing=T)
xtable(b)
xtable(c)
//M
...
I'm using the package glmulti to fit models to several datasets. Everything works if I fit one dataset at a time.
So for example:
output <- glmulti(y~x1+x2,data=dat,fitfunction=lm)
works just fine.
However, if I create a wrapper function like so:
analyze <- function(dat)
{
out<- glmulti(y~x1+x2,data=dat,fitfunction=lm)
return (out...
I'm trying to work on data from .csv files of known general format but varying group and measure names. I can get a data.frame using:
mydata=read.csv(file.choose(),header=T)
mydata
GroupNames Measure1 Measure2 Measure3 etc
1 group1 value1 value1
2 group1 value2 value2
3 group2 value3 ...
I have two sets of data (3 columns: x=categorical, y = numerical, l = location) and I would like to create a bar chart with the categories on the x axis and, for each value of the category, two vertical bars, coloured differently, with the y values for each location. By the default, Excel/OpenOffice produce this kind of chart.
I tried
...
From the (simplified) data below that represents a user choosing between three options, I want to create a set of boxplots of the percentage of times a user chose a value, based upon the factor of value. So I want three boxplots, the percentage users chose 0, 1 and 2.
I'm sure I'm missing something obvious, as I often do with R. I can g...
I've started to produce the charts for a paper. For some of them which are bar charts I've used the "Pastel1" palette (as recommended in the book on ggplot2, pastel colours are better than saturated ones for fill areas, such as bars).
The problem with Pastel1 at least is that when printed on a B&W laser printer, the colours are indistin...
Hi,
I have a server client system where the server is a vc++ program and the client is in R.
Can I use a shared memory between these two? with boost::interprocess at the vc++ end and R bigmemory at the R end?
the server and the client are on the same pc
...
I have written a shebang R script and would like to execute it from a Perl script. I currently use system ($my_r_script_path, $r_script_arg1, $r_script_arg2, ...) and my question is how can I verify the R script terminates normally (no errors or warnings).
guess I should make my R script return some true value at the end, only if everyt...
How can I add a list of vectors to a preallocated data.frame such that the vectors form the rows of the data.frame?
eg.
ll<-list(c(1,2,3),c(2,3,4))
dd<-data.frame(matrix(nrow=10,ncol=3))
I need dd to look like
1 2 3
2 3 4
...