Hi Karim,
you should learn ?Map to iterate along the list and supply mutliple list
arguments (there is also parallel:::mcMap for multicore).
The magic of the color code generation you figure out yourself, I guess...
Here 'i' intends to be the value, 'n' the name, e.g.
# returns color by
In '?rep' find out about the 'each' argument.
Also there is the function 'gl' which creates a factor and offers a shorter
syntax for your problem.
If n equals 5 use one of:
rep(seq(5), each = 4)
gl(5,4)
On 19 April 2015 at 15:44, John Sorkin jsor...@grecc.umaryland.edu wrote:
Windows 7 64-bit
Hi Dimitri,
str_replace_all is not in the base libraries, you could use 'gsub' as well,
for example:
a = What a nice day today! - Story of happiness: Part 2.
b = What a nice day today: Story of happiness (Part 2)
sa = gsub([^A-Za-z0-9], , a)
sb = gsub([^A-Za-z0-9], , b)
a==b
# [1] FALSE
sa==sb
#
If you don't mind an extra column, you could use something similar to:
data.frame(r=seq(8),foo=NA,bar=NA)
If you do, here is another approach (see function body):
empty.frame - function (r = 1, n = 1, fill = NA_real_) {
data.frame(setNames(lapply(rep(fill, length(n)), rep, times=r), n))
}
On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
colnames(e) - paste0('pop',1:12)
isn't a function and doesn't return anything.
But
function(e){colnames(e) - paste0('pop', 1:2)}
is a function and it returns something (the last evaluated expression! -
here the paste0
convention to always copy the reply to the last
person who responded?
I guess it depends on which answer you refer to.
On Mon, Mar 30, 2015 at 10:56 AM, Sven E. Templer sven.temp...@gmail.com
wrote:
On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
colnames(e) - paste0
:56 AM, Sven E. Templer sven.temp...@gmail.com
wrote:
On 30 March 2015 at 16:47, Sarah Goslee sarah.gos...@gmail.com wrote:
colnames(e) - paste0('pop',1:12)
isn't a function and doesn't return anything.
But
function(e){colnames(e) - paste0('pop', 1:2)}
is a function
On 30 March 2015 at 17:50, Sarah Goslee sarah.gos...@gmail.com wrote:
On Mon, Mar 30, 2015 at 11:43 AM, Sven E. Templer
sven.temp...@gmail.com wrote:
On 30 March 2015 at 17:31, Bert Gunter gunter.ber...@gene.com wrote:
Sarah's statement is correct.
So is yours
Q3: any other recommendations?
You might be interested in the very easy to use R markdown, see:
http://rmarkdown.rstudio.com/
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
Hi,
you didn't specify values in A, and you first wanted to compare bi
with Aij, but then also which bi is less/equal to zero.
For the first case, with
A - matrix(0:3,2)
b - seq(-1,5)
and a comparison function for bi less/equal to Aij like
f - function (bi) {as.integer(bi=A)}
you can iterate
Without (example) code it is hard to follow... use ?dput to present
some data (subset).
But if it is data.frames you are dealing with (for sure with read.csv,
but not so sure at all with raster maps), give this a try:
?merge
On 19 February 2015 at 17:44, Simon Tarr simon.t...@adtrak.co.uk wrote:
Make use of the plyr and reshape2 package (both on CRAN):
library(plyr)
d-adply(ArrayDiseaseCor, 1:2)
# adply calls function identity by default
d-melt(d)
d-subset(d,value.5)
head(d)
You will have to rename columns, or adjust arguments in melt/adply.
Note: use set.seed before sampling for
see inline
On 12 February 2015 at 09:10, Sven E. Templer sven.temp...@gmail.com wrote:
Make use of the plyr and reshape2 package (both on CRAN):
I forgot:
library(reshape2)
library(plyr)
d-adply(ArrayDiseaseCor, 1:2)
# adply calls function identity by default
d-melt(d)
d-subset(d,value
Maybe this is due to the usage of rep() in ifelse():
f.rep - function(ans){ans - rep(ans,1);return(ans)}
f - function(ans){return(ans)}
f(a - 123) # no print here
f.rep(a - 123) # prints:
# [1] 123
On 27 January 2015 at 11:54, Bert Gunter gunter.ber...@gene.com wrote:
Huh??
ifelse(TRUE, a -
you can also define 'na.rm' in sum() by 'NA state' of x (where x is
your vector holding the data):
sum(x, na.rm=!all(is.na(x)))
On 26 January 2015 at 13:45, Martin Maechler
maech...@lynne.stat.math.ethz.ch wrote:
Jim Lemon drjimle...@gmail.com
on Mon, 26 Jan 2015 11:21:03 +1100 writes:
Another solution:
CaseID - c(1015285, 1005317, 1012281, 1015285, 1015285, 1007183,
1008833, 1015315, 1015322, 1015285)
Primary.Viol.Type - c(AS.Age, HS.Hours, HS.Hours, HS.Hours,
RK.Records_CL,
OT.Overtime, OT.Overtime, OT.Overtime, V.Poster_Other,
V.Poster_Other)
library(reshape2)
# fixed formula part:
f - dat ~ a0 * exp(-S*(x - 250)) + K
# convert to character
f - as.character(f)
# component:
C - (p0*exp(-0.5*((x-p1)/p2)^2))
# number of components (defined randomly):
n - sample(1:3, 1)
C - rep(C, n)
# collapse:
C - paste(C, collapse = +)
# combine
f - paste(f[2], f[1],
Hi.
You can't.
But using a second file where you first write your header and then
append the original file is a solution. ?cat and ?write.table with a
focus on the 'append' argument should help. you can then use ?unlink
to delete the original file and ?file.rename to rename the second, if
, 2014 12:33 AM, Sven E. Templer sven.temp...@gmail.com wrote:
Hi.
You can't.
But using a second file where you first write your header and then
append the original file is a solution. ?cat and ?write.table with a
focus on the 'append' argument should help. you can then use ?unlink
With melt and rep you are close. If you combine them it works:
library(reshape)
# your data:
df1 - data.frame(area=c(1,2),group1=c(2,3),group2=c(1,5),group3=c(4,0))
df2-data.frame(person_id=seq(1:15),area=c(rep(1,7),rep(2,8)),group_num=c(1,1,2,3,3,3,3,1,1,1,2,2,2,2,2))
# first melt
d -
seems like a transpose, so use
?t
t(your.data.frame)
On 22 October 2014 11:34, Matthias Weber matthias.we...@fntsoftware.com wrote:
Hello together,
i have a little problem. Maybe anyone can help me.
I have a data. frame which look like this one:
1000 1001 10021003
15
. http://fsf.org/
[5] Everyone is permitted to copy and distribute verbatim copies
[6] of this license document, but changing it is not allowed.
On 15 October 2014 10:51, r...@openmailbox.org wrote:
On 2014-10-14 15:40, Sven E. Templer wrote:
Prevent graphic menues with:
options(menu.graphics
use:
which(p=.05)
this will not yield logical, but integer indices without NA
On 14 October 2014 11:51, Rainer M Krug rai...@krugs.de wrote:
Hi
I want to evaluate NA and NaN to FALSE (for indexing) so I would like to
have the result as indicated here:
,
| p - c(1:10/100, NA, NaN)
|
Prevent graphic menues with:
options(menu.graphics = FALSE)
or and define repositories:
options(repos = c(CRAN = http://cran.r-project.org;))
On 14 October 2014 17:00, r...@openmailbox.org wrote:
Subscribers,
A version of R is installed in a virtual machine, which has complete
internet
follow instructions on
https://stat.ethz.ch/mailman/listinfo/r-help
at
To unsubscribe from R-help, get a password reminder, or change your
subscription options enter your subscription email address:
...
On 10 October 2014 16:16, Tasnuva Tabassum t.tasn...@gmail.com wrote:
I want to get rid of
Dear Barry,
some thoughts:
1) e in your function status_fnc is a vector when applied on a matrix
like object, but you index it as a matrix (e[,i] should be e[i]).
2) You can simplify the if statement by using the function any
(replacing all the OR statements) on the vector, so use any(e=='Y')
Hello,
how can I open (by an R command) the index page in html mode, as obtained by:
options(browser=firefox) # or any other
options(help_type=html)
?help
# and then following the html reference on the page bottom named Index
In text mode I know library(help='utils') to open the utils package
in ?which read about arr.ind
following jims assumption (column instead of row indices is what you
want) this also works:
m - matrix(1:20,4)
unique(which(m11, arr.ind = T)[,col])
On 27 September 2014 12:23, Jim Lemon j...@bitwrit.com.au wrote:
On Fri, 26 Sep 2014 10:15:14 PM Fix Ace wrote:
see inline for another vectorized example.
On 25 September 2014 23:05, David L Carlson dcarl...@tamu.edu wrote:
Another approach
fun - function(i, dat=x) {
grp - rep(1:(nrow(dat)/i), each=i)
aggregate(dat[1:length(grp),]~grp, FUN=sum)
}
lapply(2:6, fun, dat=TT)
One way I know to do this is (in bash) to use a dummy variable and make the
comment a multiline character string:
dummy - c(
This is my multiline
comment or code block.
)
or if printing does not disturb you, just use:
...
Use ' if you have in the block.
Other workarounds are here, which you
30 matches
Mail list logo