Displaying 20 results from an estimated 2000 matches similar to: "correct way to subset a vector"
2011 Feb 10
2
for loop to merge .csvs
So I needed to merge 17 .csv files, and did so by brute force, but I might
need to do so again. Anyone have suggestions for a for loop that might do
the below for me (where a:r are separate .csv files)
ab<-merge(a,b,all=TRUE)
cd<-merge(c,d,all=TRUE)
ef<-merge(e,f,all=TRUE)
gh<-merge(g,h,all=TRUE)
ij<-merge(i,j,all=TRUE)
kl<-merge(k,l,all=TRUE)
no<-merge(m,n,all=TRUE)
2009 Aug 20
2
How to extract row values?
Dear All!
I'm trying to extract one specific row from a data frame without columnnames being included. I only want a 1-dimensional vector that consists of the specific data on this row. Here's an example:
existing data:
column names: v1v2v3
Row 1 ab cd ef
Row 2 gh ij kl
Row 3 mn op qr
This is what I want to extract:
ab cd ef
I do not want: v1v2v3
2017 Oct 23
2
A list of data frames and a list of colnames.
I have a list of file names, and a list of data frames contained in those files.
mynames <- list.files()
mydata <- lapply(mynames, read.delim)
Every file contains two columns.
> colnames(mydata[[1]])
[1] "Name" "NumReads"
> colnames(mydata[[2]])
[1] "Name" "NumReads"
I can set the colnames easily enough with a for loop.
for (i in
2011 May 21
3
Simple R Question...
Let's say I have the data frame 'dd' below. I'd like to select one
column from this data frame (say 'a') and keep its name in the
resulting data frame. That can be done as in #2. However, what if I
want to make my selection based on a vector of names (and again keep
those names in the resulting data frame). My attempt is #4 but doesn't
work.
dd <- data.frame(a =
2010 Jun 14
2
list matching
Hello,
I could not find a clear solution for the follow question. please allow me to ask. thanks
mynames=cbind(c('a','b'),c(11,22))
lst=list(a=c(1,2), b=5)
now I try to combine mynames and lst:
a 1 11
a 2 11
b 5 22
thanks
jian
[[alternative HTML version deleted]]
2011 Apr 18
1
using "aggregate" when variable names contain spaces
Hello!
my data set has many variables. Unfortuantely, many of those variables
contain spaces in their names.
I need advice on: how to refer to variable names in the formula for
"aggregate". See example below:
### Generating example data set:
mydate = rep(seq(as.Date("2008-12-01"), length = 3, by = "month"),4)
value1=c(1,10,100,2,20,200,3,30,300,4,40,400)
2018 Jan 17
3
asterisk mysql contacts
Hi. i have an asterisk 11 installation that i run in my soho environment.
My system has mysql to store all the cdrs.
I would like make use of the mysql and store numbers and names. eg
+4922123456789 "Atux Null". So when the +4922123456789 calls in my system
the name "Atux Null" will pop up next to the number.
at the moment i have a database called MyNames in mysql that has this
2010 Jul 01
2
Sweave function
Dear list,
I have a question about the interaction between R code and Latex language trough the Sweave function in the package "utils".
What I'm trying to do is to write a report. Contrary to the examples shown in the Sweave Manual in which table already constructed by R are "exported" on Latex files, what I would like to do is to build a table in which I combine text and
2007 Feb 21
1
Trying to get an apply to work with a list in applying names to tables
I am trying to use apply and a list to supply names
to a set of tables I want to generate. Below is an
example that I hope mimics the larger original
problem.
EXAMPLE
aa <- c( 2,2,1,1,2)
bb <- c(5,6,6,7,4)
aan <- c("yes", "no")
bbn <- c("a", "b", "c", "d")
mynames <- c("abby", "billy")
mylist <-
2003 Jul 18
1
confused about x-coordinates and bar charts
Thanks for all the help on my previous histogram problem. I intend to
summarize the solutions back to the list Real Soon Now, but first, I've
got another problem.
I've made a bar chart that reports means. I'd like to put the number
of observations on top of each bar. Here's what I've got:
barplot((subset$x),
col=grey(.5),
ylab="Mean Engagement
2009 Jan 08
1
cosinor analysis
Hallo,
I didn´t found any facilities for Halbergs cosinor analysis in R. This analysis is well known in the Chronobiology as the least square approximation of time series using cosine function of known period (in my case of 24hours-period). I tried to write a script but crashed...
Can you give me some advices, please!?
Thanks
Anne Berger
Institute of Zoo- and Wildlife Research, Berlin, Germany
2004 Nov 23
2
IFELSE across large array?
Dear all,
As our previous email did not get any response, we try again with a
reformulated question!
We are trying to do something which needs an efficient loop over a huge
array, possibly functions such as apply and related (tapply,
lapply...?), but can't really understand syntax and examples in
practice...i.e. cant' make it work.
to be more specific:
we are trying to apply a mask
2011 Aug 26
1
matrix bands
Dear R developers,
I was looking for a function analogous to base::diag() for getting and
setting bands of a matrix. The closest I could find was Matrix::band(),
but this was not exactly what I wanted for two reasons. Firstly,
Matrix::band() returns a matrix rather than just the specified band.
Secondly, Matrix::band() cannot be used for setting the values for a
matrix band.
Setting or
2011 Apr 27
6
Assignments inside lapply
Dear all I would like to ask you if an assignment can be done inside a lapply statement.
For example
I would like to covert a double nested for loop
for (i in c(1:dimx)){
for (j in c(1:dimy)){
Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f)
}
}
to something like that:
ij<-expand.grid(i=seq(1:dimx),j=(1:dimy))
unlist(lapply(1:nrow(ij),function(rowId) { return
2009 Oct 27
1
Rjava, RImageJ, and/or S4 question.
I am out of my league with this question. The following code starts the java imaging program ImageJ from within R, and displays an image (assuming ImageJ is installed on your computer).
library(RImageJ)
img <- IJ$openImage( file.choose() ) #pick an available .tif file
img$show() # make the image object visible
# An image is now displayed
# find out about the objects involved
>
2009 Oct 17
2
Recommendation on a probability textbook (conditional probability)
I need to refresh my memory on Probability Theory, especially on
conditional probability. In particular, I want to solve the following
two problems. Can somebody point me some good books on Probability
Theory? Thank you!
1. Z=X+Y, where X and Y are independent random variables and their
distributions are known.
Now, I want to compute E(X | Z = z).
2.Suppose that I have $I \times J$ random number
2011 Mar 15
2
Calculate monthly means
I am trying to calculate monthly means by year of phosphates and nitrates from a multi year data set. Can anybody help me out with the most effective way to do this?
My data looks like this:
Collection_Date Test.Name Value
2000-01-24 17:00:00 Phosphate 0.108
2000-01-24 17:00:00 Nitrate 0.037
2001-11-12
2003 Apr 02
2
lme parameterization question
Hi,
I am trying to parameterize the following mixed model (following Piepho
and Ogutu 2002), to test for a trend over time, using multiple sites:
y[ij]=mu+b[j]+a[i]+w[j]*(beta +t[i])+c[ij]
where:
y[ij]= a response variable at site i and year j
mu = fixed intercept
Beta=fixed slope
w[j]=constant representing the jth year (covariate)
b[j]=random effect of jth year, iid N(0,sigma2[b])
a[i]=random
2010 Feb 08
3
Hypercube in R
Dear all,
Does anybody have an idea or suggestion how to construct (plot)
4-dimensional hypercube in R.
Thanks in advance for any pointers.
Regards, Andrej
2007 May 25
1
Speeding up resampling of rows from a large matrix
I'm trying to:
Resample with replacement pairs of distinct rows from a 120 x 65,000
matrix H of 0's and 1's. For each resampled pair sum the resulting 2
x 65,000 matrix by column:
0 1 0 1 ...
+
0 0 1 1 ...
_______
= 0 1 1 2 ...
For each column accumulate the number of 0's, 1's and 2's over the
resamples to obtain a 3 x 65,000 matrix G.
For those