Hi:
Here's another way to look at the problem. Instead of manually adding
a new column after k datasets have been read in, read your individual
data files into a list, as long as they all have the same variable
names and the same class (in this case, data.frame). Then create a
vector of names for
...or, when trying to read it back into R,
read.csv(header = TRUE, text = '
"no good","no good at all"
1,4
2,5
3,6')
no.good no.good.at.all
1 1 4
2 2 5
3 3 6
read.csv(header = TRUE, check.names = FALSE, text = '
"no good","no good at
I'm sorry, but I have to take issue with this particular use case of
ifelse(). When the goal is to generate a logical vector, ifelse() is
very inefficient. It's better to apply a logical condition directly to
the object in question and multiply the result by 1 to make it
numeric/integer rather
This problem is discussed in Winston Chang's R Graphics Handbook,
section 3.9. Adapting his code to this example:
test - data.frame(variables = c(PE_35, PE_49),
value1=c(13,3),
value2=c(75,31),
value3=c(7,17),
Hi Ranjan:
Try this:
library(sos)
findFn(Wasserstein)
It appears there are three packages that might be relevant:
HistDAWass, transport and TDA.
HTH,
Dennis
On Sat, Apr 18, 2015 at 8:06 PM, Ranjan Maitra
maitra.mbox.igno...@inbox.com wrote:
Dear friends,
Before reinventing the wheel, I was
One way is to use the reshape2 package:
library(reshape2)
dcast(DF, id ~ Year, value.var = Day)
Dennis
On Mon, Feb 9, 2015 at 7:47 AM, jeff6868
geoffrey_kl...@etu.u-bourgogne.fr wrote:
Dear R-users,
I would like to transpose a large data.frame according to a specific column.
Here's a
Hi:
You get a gradient for your response variable because it is numeric.
You need to convert it to factor. (Discrete color sets need to be
mapped to discrete variables - a factor is one way to generate a
discrete variable.) Here is one approach to get what you appear to be
looking for.
DF -
Hi:
Don't know about performance, but this is fairly simple for operating
on atomic vectors:
x - c(A, A, G, T, C, G)
apply(embed(x, 2), 1, paste0, collapse = )
[1] AA GA TG CT GC
Check the help page of embed() for details.
Dennis
On Wed, Jan 28, 2015 at 3:55 PM, Kate Ignatius
Hi Kristi:
I think this paper elucidates the problem Bert mentioned. A thorough
and careful reading of the last two sections should clarify what
post-hoc power is and is not.
http://www.stat.uiowa.edu/files/stat/techrep/tr378.pdf
Dennis
On Sat, Nov 8, 2014 at 11:25 AM, Kristi Glover
Hi:
There are several options, but you shot yourself in the foot by using
cbind() to combine objects of different classes into a matrix, so
everything ends up being a factor because a matrix is an atomic object
with a dim attribute, and atomic objects must have a common class, so
Flows and
1. Look into the ggmap package if you want to overlay your data onto a map.
2. Re your color scale representation, define 'appropriately'. Do you
mean a continuous range expressible in a colorbar or a discrete range,
and if the latter, what intervals did you have in mind?
Dennis
On Fri, Apr 4,
Less coding with plyr:
tab - read.table(text=pop Freq
1 1 30
2 2 25
3 3 30
4 4 30
5 5 30
6 6 30
7 7 30,sep=,header=TRUE)
# Function to do the work on each row
f - function(pop, Freq) data.frame(ind = seq_len(Freq))
library(plyr)
u -
Hi:
You were close...
library(ggplot2)
m - mpg
# Set the factor labels with plotmath code (note the ==)
m$drv - factor(m$drv, labels = c(sigma[0] == sqrt(2),
sigma[0] == 2 * sqrt(2),
sigma[0] == 3 * sqrt(2)))
ggplot(m, aes(x =
Here's a bquote version:
x=c(1,2,3,4); y=c(1,2,3,4); z=c(1.25,1.5,2.5,3.5)
# first stats based on data, used to populate legend
wdt_n = 50; wdt_mbias = 0.58
wdt_mae = 2.1; wdt_R2 = 0.85
# second stats based on data, used to populate legend
spas_n = 50; spas_mbias = 0.58
spas_mae = 2.1;
David:
I privately suggested he post to manipulatr because Hadley is more
likely to see his question there first than in R-help. He originally
posted here, noted the cross-posting and referral at manipulatr and
responded back to this list when he got a successful reply from
Hadley. I don't see
Hi Ranjan:
I think this is an important and well-posed question. AFAIR, sciviews
provides a fairly sophisticated GUI for R, but I haven't looked at it
in a while. The two packages I'd suggest you look at are John Fox's R
Commander (package Rcmdr...and note all the plug-ins!) and Ian
Fellows'
The additional element comes from this code:
geom_point(aes(color = VegType, shape = VegType, size = 10))
Take the size argument outside the aes() statement and the legend will
disappear:
geom_point(aes(color = VegType, shape = VegType), size = 10)
The aes() statement maps a variable to a plot
There are lots of errors in your code. In particular, the optimization
routines do not like functions that ignore the parameters.
I would like to nominate this delicious riposte as a fortune
candidate. Anyone to second the motion?
Dennis
On Sat, Nov 16, 2013 at 1:26 PM, Prof J C Nash (U30A)
Attempting to follow the OP's conditions and assuming I understood
them correctly, here is one way to wrap this up into a function:
makeMat - function(x)
{
stopifnot(is.integer(x))
nr - length(x)
nc - max(x)
# Initialize a matrix of zeros
m - matrix(0, nr, nc)
#
In this case the OP probably does need to reinstall contributed
packages since going from 2.15.x to 3.0.y entails a major version
change in R.
Dennis
On Mon, Sep 30, 2013 at 11:49 AM, Steve Lianoglou
lianoglou.st...@gene.com wrote:
Hi,
On Mon, Sep 30, 2013 at 11:12 AM, Cem Girit
Isn't this just a block diagonal matrix?
library(pracma)
blkdiag(table1, table2)
[,1] [,2] [,3] [,4]
[1,]1100
[2,]1200
[3,]0001
[4,]0004
Dennis
On Wed, May 1, 2013 at 5:41 PM, David Winsemius dwinsem...@comcast.net wrote:
library(ggplot2)
library(gridExtra)
#generate test precipitation data
year-c(2000,2001,2002,2003,2004)
precip-c(46,100,80,74,20)
yp-data.frame(year, precip)
#generate test fecal coliform data
year2-c(2000,2000,2000,2000,2000,2000,2000,2000,2000,2000,
Hi:
Here's a way you could do it entirely within ggplot2. The annotation
functions have a parse = argument which allows you to pass character
string representations of math expressions, but there is no such thing
in the scale functions, so you need a different approach.
library(ggplot2)
df -
Hi:
The other day I ran 100K simulations, each of which returned a 20 x 4
data frame. I stored these in a list object. When attempting to rbind
them into a single large data frame, my first thought was to try plyr:
library(plyr)
bigD - ldply(L, rbind) # where L is the list object
I quit at
the two values of the game, 0 and 1 ,
instead of 0, 0.25, 0.50, 0.75, 1?
I would like to thank you in advanec for your help
Regards
Alex
- Original Message -
From: Dennis Murphy djmu...@gmail.com
To: Alaios ala...@yahoo.com
Cc:
Sent: Friday, February 15, 2013 10:19 AM
Subject
Hi:
No offense, but this is code is inefficient on several levels.
Firstly, a loop is unnecessary (see below); secondly, ifelse() is a
vectorized function and you're attempting to apply it to each row of
DataSet. Try this instead, given
dput(DataSet)
structure(list(Age = c(-0.552450789929175,
Hi:
Try
DF - structure(list(Gene = structure(1:5, .Label = c(NM_001001130,
NM_001001144, NM_001001152, NM_001001160, NM_001001176
), class = factor), T0h = c(68L, 0L, 79L, 1L, 0L), T0.25h = c(95L,
1L, 129L, 1L, 0L), T0.5h = c(56L, 4L, 52L, 2L, 0L), T1h = c(43L,
0L, 50L, 0L, 0L), T2h = c(66L, 1L,
Hi:
The simplest way to do it is to modify the input data frame by taking
out the records not having status live or dead and then redefining the
factor in the new data frame to get rid of the removed levels. Calling
your input data frame DF rather than data,
DF - structure(list(FID = c(1L, 1L,
Hi:
This should give you some idea of what Steve is talking about:
library(data.table)
dt - data.table(x = sample(10, 1000, replace = TRUE),
y = rnorm(1000), key = x)
dt[, .N, by = x]
system.time(dt[, .N, by = x])
...on my system, dual core 8Gb RAM running Win7
Hi:
Here's one approach. I assume that your first 1000 matrices have a
single 1 in each matrix, the next set of 1000 have two 1's, ..., and
the last one has 99 1's. (No point in doing all 1's since they're all
constant.) If that's the case, then try the following.
# Each row represents a
Hi:
This looks like the one:
library('lattice')
data(Oats, package = 'MEMSS')
print(xyplot(yield ~ nitro | Block, Oats, groups = Variety, type = c(g, b),
auto.key = list(lines = TRUE, space = 'top', columns = 3),
xlab = Nitrogen concentration (cwt/acre),
Hi:
Could you supply a small reproducible example with the output that you
expect? For example, what output would you expect from the following:
a - array(1:24, c(2, 2, 3))
?
Dennis
On Mon, Nov 28, 2011 at 12:32 AM, zloncaric
zlonca...@biologija.unios.hr wrote:
Thank you for your time and
Hi:
Here's one way you could do it. I manufactured some fake data with a
simple model to illustrate. This assumes you are using the same model
formula with the same starting values and remaining arguments for each
response.
dg - data.frame(x = 1:10, y1 = sort(abs(rnorm(10))),
Hi:
There may well be a more efficient way to do this, but here's one take.
library('data.table')
# Want to merge by D in the end, so set D as part of the key:
t1 - data.table(ID = 11:20, A = rnorm(10), D = 1:10, key = ID, D)
t2 - data.table(ID2 = 1:10, D = rep(1:5, 2), B = rnorm(10), key = ID2,
Hi:
This is the type of question for which the sos package can come to the rescue:
library('sos')
findFn('Gumbel Clayton copula')
It appears that the QRMlib package would be a reasonable place to start.
Dennis
On Thu, Nov 24, 2011 at 7:29 PM, cahaya iman qaisfay...@gmail.com wrote:
Hi,
Is
Hi:
There are two good reasons why the loop solution is not efficient in
this (and related) problem(s):
(i) There is more code and less transparency;
(ii) the vectorized solution is four times faster.
Here are the two proposed functions:
# Vectorized version
m1 - function(v) paste(v, ' to ', v
See
?AlgDesign::optFederov
and look for the 'Value' section, where these elements of the output
list are defined.
Dennis
On Wed, Nov 23, 2011 at 7:15 PM, 蓁蓁 李 tszhenzh...@hotmail.com wrote:
Hi,
I am wondering how I should interpreate the output of optFederov() in
AlgDesign.
Specially I
A very similar question was asked a couple of days ago - see the
thread titled Removing rows in dataframe w'o duplicated values - in
particular, the responses by Dimitris Rizopoulos and David Winsemius.
The adaptation to this problem is
df[ave(as.numeric(df$group), as.numeric(df$group), FUN =
Well said. +1
Dennis
On Thu, Nov 24, 2011 at 6:43 AM, Bert Gunter gunter.ber...@gene.com wrote:
... and while I am at it, as this is the U.S. Thanksgiving...
My sincere thanks to the many R developers and documenters who
contribute large amounts of their personal time and effort to
Hi:
Try this:
library('lattice')
xyplot(y ~ x,
type = c('g', 'p'),
panel = function(x, y, ...){
panel.xyplot(x, y, ...)
panel.lines(x, predict(fm), col = 'black', lwd = 2)
}
)
HTH,
Dennis
On Wed, Nov 23, 2011 at
Matrix multiplication, maybe?
all_data %*% iu
a b c
[1,] 1 4 0
[2,] 2 5 0
[3,] 3 6 0
I have no idea if this is a general solution or not, but it works in
this case. If you need something else, perhaps a more realistic
example would help.
Dennis
On Wed, Nov 23, 2011 at 11:41 AM, Ben quant
Hi:
Here's one way:
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
id value value2
1.1 1 5 1
1.2 1 6 4
1.3 1 7 3
3.5 3 5 4
3.6 3 4 3
HTH,
Dennis
On Tue, Nov 22, 2011 at 9:43 AM, AC Del Re de...@wisc.edu wrote:
Hi,
Is
Sorry, you need this first:
L - split(dat, dat$id)
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
D.
On Tue, Nov 22, 2011 at 10:38 AM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
Here's one way:
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
id value
Hi:
Strictly a guess, but the following might be helpful. The call below
assumes that the referent data frame is test1, which consists of a
single column named x. Modify as appropriate.
test_lab - with(test1, cut(x, c(0, 18954, 37791, 56951, 75944, 84885, 113835),
labels =
Hi:
Does this work for you?
yy
Q20 Q21 Q22 Q23 Q24
1 0 1 2 3 4
2 1 NA 2 3 4
3 2 1 2 3 4
rowSums(yy, na.rm = TRUE)
1 2 3
10 10 12
# Use a subset of the variables in yy:
selectVars - paste('Q', c(20, 21, 24), sep = '')
rowSums(yy[, selectVars], na.rm = TRUE)
1
Hi:
Start by writing a small utility function to compute the CCR (not to
be confused with the rock band):
ccr - function(x) 100 * (log(x[-1]) - log(x[-length(x)]))
# Small test:
x - round(rnorm(10, 5, 0.5), 2)
ccr(x) # Works on vectors...
# Load up the stock data:
library(quantmod)
Without a reproducible example this is just a guess, but try
Matrix[apply(Matrix, 1, function(x) any(x 1.11)), ]
This will retain all rows of Matrix where at least one value in a row
is above the threshold 1.11. If that doesn't do what you want, please
provide a small reproducible example and a
Hi:
Here are two ways to do it; further solutions can be found in the doBy
and data.table packages, among others.
library('plyr')
ddply(daf, .(id), colwise(mean, c('v1', 'v2', 'v3', 'v4')))
aggregate(cbind(v1, v2, v3, v4) ~ id, data = daf, FUN = mean)
# Result of each:
id v1 v2 v3 v4
1 1 6
Hi:
Here's a Q D solution that could be improved. It uses the plyr
package. Starting from your data1 data frame,
library('plyr')
dseq - seq(as.Date('2010-01-01'), as.Date('2011-06-05'), by = '30 days')
# Use the cut() function to create a factor whose levels are demarcated
# by the dates in
This is very straightforward using the reshape2 package:
library('reshape2')
dc - dcast(a, name ~ year, value_var = 'amount')
name 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984
1a123456789 10 NA NA NA NA
2b 11 12
Hi:
Here's one way:
apply(matrix(var.names, ncol = 2, byrow = TRUE), 1, function(x)
paste(x[1], x[2], sep = ','))
[1] a,b c,d e,f
HTH,
Dennis
On Wed, Nov 16, 2011 at 9:46 PM, B77S bps0...@auburn.edu wrote:
hi,
If i have a list of things, like this
var.names - c(a, b, c, d, e, f)
how can
Hi:
This worked for me - I needed to modify some of the strip labels to
improve the appearance a bit and also reduced the strip font size a
bit to accommodate the lengths of the strings. The main thing was to
change \\n to \n.
Firstly, I created a new variable called Indic as a character
Looking at the help pages in the ineq package, the Theil() function
simply returns the value of the index. You can look at the source code
of the relevant functions to see what they actually compute:
library('ineq')
ineq # the main function
Theil# for the Theil index
Neither function is
Hi:
Here's one way, but it puts the two countries side by side rather than
stacked (I'm not a big fan of stacked bar charts except in certain
contexts). The first version uses the original data, but one can see
immediately that there is no distinction between NA and 0:
ggplot(g, aes(x = Date, y
Hi:
I think you're overthinking this problem. As is usually the case in R,
a vectorized solution is clearer and provides more easily understood
code.
It's not obvious to me exactly what you want, so we'll try a couple of
variations on the same idea. Equality of floating point numbers is a
Hi:
Try dict[[a]] rather than dict$a, and read the section on lists in the
Introduction to R manual to learn how to properly index them.
HTH,
Dennis
On Wed, Nov 16, 2011 at 7:16 AM, Antje Gruner n...@allesjetzt.net wrote:
Dear list,
I'd like to access the elements of a list within another
,
labels = levs) ))
Dennis
On Wed, Nov 16, 2011 at 10:27 AM, Andy Bunn andy.b...@wwu.edu wrote:
-Original Message-
From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Tuesday, November 15, 2011 8:54 PM
To: Andy Bunn
Cc: r-help@r-project.org
Subject
And you got a reply on the ggplot2 list, which is why you're asked not
to cross-post.
For those who are wondering, geom_boxplot() in the ggplot2 package
will by default plot outside points along the same line as the boxplot
whiskers at their actual values. The gentleman jittered the original
Hi:
Does this work?
# library('lattice')
levs - as.vector(quantile(volcano,c(0,0.1,0.5,0.9,0.99,1)))
levelplot(volcano, at = levs,
colorkey = list(labels = list(at = levs,
labels = levs) ))
HTH,
Dennis
On Tue, Nov 15, 2011 at 1:12
Hi:
(1) Here is why your e-mails look mangled on this list:
[[alternative HTML version deleted]]
R-help is a text-only list, so please change your mailer's
settings to send ASCII text rather than HTML.
(2) The print method you see displayed in dd1 is equivalent to the following:
ddm *
(1) Please do not hijack another thread to ask an off-topic question -
start a new one instead.
(2) Your question refers to a topic called 'restricted least squares'.
Search the R-help archives on that subject and you should get a number
of answers. Someone answered a similar question here within
Groupwise data summarization is a very common task, and it is worth
learning the various ways to do it in R. Josh showed you one way to
use aggregate() from the base package and Michael showed you one way
of using the plyr package to do the same; another way would be
ddply(df, .(Patient, Region),
You don't show code or a reproducible example, so I guess you want a
general answer. Use the draw.colorkey() function inside the
levelplot() call. It takes an argument key =, which accepts a list of
arguments, including space, col, at, labels, tick.number, width and
height (see p. 155 of the
Google is an amazing resource for getting information. Try Googling
'simulation in R' - I got several useful hits on the first page.
HTH,
Dennis
On Sun, Nov 13, 2011 at 7:41 AM, Anban nino.z...@gmail.com wrote:
Hi everyone,
i really need some help with one task. I simply cant understand what
I'm guessing you have nine replicates of a 2^5 factorial design with a
couple of missing values. If so, define a variable to designate the
replicates and use it as a blocking factor in the ANOVA. If you want
to treat the replicates as a random rather than a fixed factor, then
look into the nlme or
Hi:
Try the log = argument to beanplot(). Here's an example:
library('beanplot')
v - exp(runif(1000, 0, 10))
beanplot(v)
beanplot(v, log = ')
HTH,
Dennis
On Thu, Nov 10, 2011 at 1:27 PM, Twila Moon twi...@uw.edu wrote:
Is it possible to force beanplot not to use a log scale? I want to be
Hi:
R-Bloggers picked up on this web site that contains several
interesting posts re usage of R, including this one on using a
Bayesian approach to multivariate mixed effects models using the
MCMCglmm package:
Hi:
This doesn't sort the data by strain level, but I think it does what
you're after. It helps if strain is either a factor or character
vector in each data frame.
h - function(x, y) {
tbx - table(x$strain)
tby - table(y$strain)
# Select the strains who have more than one member
Hi:
Here's an example of how one might do this in a specific example using
geom_text().
# Some fake data:
df - data.frame(x = 1:10, y = 0.5 + (1:10) + rnorm(10))
# Fit a linear model to the data and save the model object:
mod - lm(y ~ x, data = df)
# Create a list of character strings - the
Hi:
Add a background = 'color' argument to key():
library('lattice')
xyplot(1~1,
panel = function(x,y, ...) {
panel.xyplot(x,y)
panel.abline(v=seq(0,1.4,by=0.1))
panel.abline(h=seq(0,1.4,by=0.1))
}
,key = list (x=0.2,
Hi:
Here's a toy example:
# Default var names are V1-V20:
u - as.data.frame(matrix(rpois(100, 3), ncol = 20))
u - transform(u,
ngt1 = apply(u[, c('V1', 'V4', 'V9', 'V15')], 1, function(x) sum(x 1)) )
u
HTH,
Dennis
On Thu, Nov 10, 2011 at 7:24 AM, JL Villanueva jlpost...@gmail.com wrote:
Hi:
Borrowing from this thread, courtesy of Brian Diggs:
http://groups.google.com/group/ggplot2/browse_thread/thread/478f9e61d41b4678/ed323c497db61156?lnk=gstq=stat_function#ed323c497db61156
...here's a small reproducible example:
ddf - data.frame(x = 1:10, y = 0.4 + 0.6 * (1:10) + rnorm(10))
#
Hi:
There are two ways you could go about this: lists or arrays. It's
pretty easy to generate an array, a little more work to get the list.
I'm assuming the objective is to extract a chi-square statistic from
each table, so I'll show a couple of ways to do that, too.
library('plyr')
## Start
: Dennis Murphy djmu...@gmail.com
To: array chip arrayprof...@yahoo.com
Sent: Monday, November 7, 2011 9:29 PM
Subject: Re: [R] why NA coefficients
Hi John:
What is the estimate of the cell mean \mu_{12}? Which model effects
involve that cell mean? With this data arrangement, the expected
Hi:
(1) Here is one way to reorganize the levels of a factor:
plotData[['infection']] - factor(plotData[['infection']],
levels = c('InfA', 'InfC', 'InfB', 'InfD'))
Do this ahead of the call to ggplot(), preferably after plotData is defined.
relevel() resets the
Hi:
Here's another way of doing this on the simplified version of your example:
L - vector('list', 3) # initialize a list of three components
## populate it
for(i in seq_along(L)) L[[i]] - rnorm(20, 10, 3)
## name the components
names(L) - c('Monday', 'Tuesday', 'Wednesday')
## replace
In addition to Dan's quite valid concern, the final sample is not
truly 'random' - the first k - 1 elements are randomly chosen, but the
last is determined so that the constraint is met.
Dennis
On Tue, Nov 8, 2011 at 9:59 AM, Nordlund, Dan (DSHS/RDA)
nord...@dshs.wa.gov wrote:
-Original
Hi:
The problem is that you use different sets of labels in each
scale_*_manual. To get all of the scales to merge into one, you need
to have the same title, same breaks and same labels for the legend.
This gets you a single legend:
ggplot(data = df, aes(x = year, y = total, colour = treatment,
The ets() function in the forecast package requires either a numeric
vector or a Time-Series object (produced from ts()). The frequency
argument in ts() refers to the time duration between observations;
e.g., frequency = 7 means that the data are weekly; frequency = 12
means that the data are
As I mentioned earlier, if you use different labels/breaks/titles for
the legends, you'll get separate legends in a ggplot. I'm assuming you
want to keep your original labels in scale_shape_manual(); there's no
problem if you do that. The code I provided showed you how to align
all three legends;
Here's another approach using the plyr and data.table packages, where
df is the name I gave to your example data:
# plyr
library('plyr')
ddply(df, .(TIME), mutate, L1 = sort(S1))
# Another way with the data.table package:
library('data.table')
dt - data.table(df, key = 'TIME')
dt[, list(X1, S1,
Hi:
Here are a couple of ways using the plyr and ggplot2 packages:
library('plyr')
library('ggplot2')
# Create a summary data frame that computes the mean
# and standard deviation at each time/group combination
xsumm - ddply(x, .(Time, Group), summarise, m = mean(Score), s = sd(Score))
#
Since you didn't provide a reproducible example, here are a couple of
possibilities to check, but I have utterly no idea if they're
applicable to your problem or not:
* does costdis1 consist of 0's and 1's?
* is costdis1 a factor?
In the first model, you treat costdis1 as a pure
Hi:
In your function call, x[1, 1] = theta = 0. In the first line of the
loop, your rbinom() call works out to be
x[2, 1] - rbinom(x[1, 3], 1, x[1, 1]) = rbinom(10, 1, 0)
That likely accounts for the error message:
Error in x[t, 1] - rbinom(x[t - 1, 3], 1, x[t - 1, 1]) :
replacement
into a **ply() function in plyr can be
tricky. If you continue to have problems, please provide a
reproducible example as you did here.
HTH,
Dennis
On Sun, Nov 6, 2011 at 12:53 PM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
I don't think you want to keep these objects separate; it's better
Hi:
I don't think you want to keep these objects separate; it's better to
combine everything into a data frame. Here's a variation of your
example - the x variable ends up being a mouse, but you may have
another variable that's more appropriate to plot so take this as a
starting point. One plot
Hi:
You're doing the right thing in R by pre-allocating memory for the
result, but ifelse() is a vectorized function and your loop is
operating elementwise, so if-else is more appropriate. Try
for (i in 2:100){
b_vec[i] - if(abs(b_vec[i-1] + a_vec[i]) 1) a_vec[i] else
b_vec[i-1] + a_vec[i]
Works in the newly released 2.14.0:
X = c(60593.23, 71631.17, 75320.1)
round(X, -4)
[1] 6 7 8
Dennis
On Tue, Nov 1, 2011 at 10:07 AM, Wendy wendy2.q...@gmail.com wrote:
Hi all,
I have a list of numbers, e.g., X = c(60593.23, 71631.17, 75320.1), and want
to round them so the
Does this work?
library('plyr')
# Function to return a data frame if it has one row, else return NULL:
f - function(d) if(nrow(d) == 1L) d else NULL
ddply(RV09, .(set, month), f)
record.t trip set month stratum NAFO unit.area time dur.set distance
15 913 110 351 3O
Hi:
After cleaning up your data, here's one way using the plyr and
reshape packages:
d - read.csv(textConnection(
Individual, A, B, C, D
Day1, 1,1,1,1
Day2, 1,3,4,2
Day3, 3,,6,4), header = TRUE)
closeAllConnections()
d
library('plyr')
library('reshape')
# Stack the variables
dm - melt(d, id =
Hi:
Here's what I got when I ran your code:
library('glmnet')
x=matrix(rnorm(100*20),100,20)
y=rnorm(100)
cv.fit=cv.glmnet(x,y)
predict(cv.fit,newx=x[1:5,])
1
[1,] 0.1213114
[2,] 0.1213114
[3,] 0.1213114
[4,] 0.1213114
[5,] 0.1213114
coef(cv.fit)
21 x 1 sparse Matrix of class
Here's a hack, but perhaps you might want to rethink what type of
output you want.
# Function:
g - function(arr, lastSubscript = 1) {
n - length(dim(arr))
commas - paste(rep(',', n - 1), collapse = '')
.call - paste('arr[', commas, lastSubscript, ']', sep = '')
eval(parse(text =
Hi:
I'd double check the form of the upper bound of the sequence. In the
first case (i = 1), it uses the subvector loghozamok[1:220]; when i =
2, it uses the subvector loghozamok[21:260], etc. In the last case, it
uses loghozamok[1181:1420]. If instead you want to split the vector
into 60 groups
Hi:
Here are a few ways (untested, so caveat emptor):
# plyr package
library('plyr')
ddply(df, .(Plant, Tissue, Gene), summarise, ntest =
shapiro.test(ExpressionLevel))
# data.table package
library('data.table')
dt - data.table(df, key = 'Plant, Tissue, Gene')
dt[, list(ntest =
dat
[,1] [,2] [,3]
[1,]001
[2,]010
[3,]011
[4,] NA11
1 - is.na(dat)
[,1] [,2] [,3]
[1,]111
[2,]111
[3,]111
[4,]011
D.
On Fri, Oct 28, 2011 at 11:40 AM, Evgenia ev...@aueb.gr wrote:
I have
Hi:
A trip to package sos reveals that simple.lm() is in the UsingR
package. Looking at the code of this function, it plots the (x, y)
pairs and the fitted least squares line without an option to suppress
the plot. Here's a slight hack of the function; it adds a new argument
plot with default
Did you load the class package before calling lda()?
Dennis
On Thu, Oct 27, 2011 at 10:14 AM, 1Rnwb sbpuro...@gmail.com wrote:
my modification gives me error
rows- c(1:nrow(mat))
scores - c()
labels -c()
itr-1000
chnksz-ceiling(itr/getDoParWorkers())
smpopt=list(chunkSize=chnksz)
Try this, based on your small example:
tds.a - read.table(textConnection(
+ site sampdate param quant
+ 1UDS-O 2006-12-06 TDS 10800
+ 4 STC-FS 1996-06-14 Cond 280
+ 7UDS-O 2007-10-04Mg 1620
+ 9UDS-O 2007-10-04 SO4 7580
+ 19 JCM-10B 2007-06-21Ca79
+ 20
Hi:
The sort of thing you appear to want is fairly straightforward to in
lattice and ggplot2, as both have ways to automate conditioning plots.
Since you were looking at ggpot2, let's consider that problem. You
don't really show enough data to provide a useful demonstration, but
let's see if we
Let's see: there is a dotPlot() function in each of the following packages:
BHH2, caret, mosaic, qualityTools
Would you be kind enough to share which of these packages (if any) you
are using?
Dennis
On Wed, Oct 26, 2011 at 4:25 AM, Jörg Reuter jo...@reuter.at wrote:
Hi,
I want draw a dotPlot.
1 - 100 of 1170 matches
Mail list logo