Is sapply really necessary here?
exc = !names(d) %in% "d3"
d[,exc] = round(d[,exc])
d
d1 d2 d3 d4
1 10 6 2.3749642 -4
2 11 6 -0.2081097 -2
3 10 4 1.2675955 -4
4 10 8 1.2468859 -2
5 10 6 2.7193027 -4
6 9 6 1.9195531 -5
7 9 6 2.8188036 -6
8 10 7 2.5755148 -4
9
nls in the stats package.
?nls
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of
Erik Thulin [ethu...@gmail.com]
Sent: 15 January 2011 16:16
To: r-help@r-project.org
Subject: [R] Weighted least squares regression for an exponen
Hello,
I have a data set of data which is best fit by an exponential decay
function. I would like to use a nonlinear weighted least squares regression.
What function should I be using?
Thank you!
[[alternative HTML version deleted]]
__
R-help
Hi Pete,
Here is one option. The first part of sapply() just serves to get all
names of d except those you excluded in 'exc'. If you were including
fewer variables than you were excluding, just get rid of the logical !
operator.
d <- data.frame(d1 = rnorm(10, 10), d2 = rnorm(10, 6),
d3 = rnor
If you can specify the omitted columns as numbers there is a quick way to do
it. e.g.
> d
d1 d2d3d4
1 9.586524 4.833417 0.8142588 -3.237877
2 11.481521 6.536360 2.3361894 -4.042314
3 10.243192 5.506440 2.0443788 -3.478543
4 9.969548 6.159666 3.0449121 -4.827
Hi All
I am trying to use the round function on some columns of a dataframe while
leaving others unchanged. I wish to specify those columns to leave
unchanged.
My attempt is below - here, I would like the column d3 to be left but
columns d1, d2 and d4 to be rounded to 0 decimal places. I would w
Happy New Year, R users! I write about R every weekday at the Revolutions blog:
http://blog.revolutionanalytics.com
and every month I post a summary of articles from the previous month
of particular interest to readers of r-help.
In case you missed them, here are some articles related to R from t
dear all,
The package segmented allows to estimate piecewise linear relationships
(*connected*
lines, i.e. a gradual change in the slope) with several breakpoints (known or
unknown)
within (generalized) linear models..
The package also includes some functions for plotting and testing..
Have a l
I am a bit confused by this. You are doing a transfer from Excel (.xls
or .xlsx) to .csv, then a subset in R and ending up with a couple of
entries which are " Open" rather than "Open". So where are they coming
from? You say they are not in the original Excel, so that suggests the
transfer to .
Do you have R2wd installed and working? Is the Rcomm system working for you?
Do you receive any errors or warnings?
I just tested it using the R gui under windows and when I do wdtxtStart()
without any word documents open a new one starts and the output gets sent
there. So there must be some
Thank you so much!
jonathan
> Date: Fri, 14 Jan 2011 10:47:57 -0800
> From: spec...@stat.berkeley.edu
> To: jonathan.hughes...@live.com
> CC: r-help@r-project.org
> Subject: Re: [R] filtering a dataframe with a vector of rownames
>
> Jonathan -
> To make your approach work, you'd need to re
Hi, somebody can help me. Idon't understand very well the manual of the this
package, I suppose I must enter "wdtxtStart", before I start working, but is
supposed that this command should open Word, but nothing happens.
I use Rgui, not Rcmdr.
Thanks
-
Mario Garrido Escudero
PhD student
Dpto.
David,
Perfect. Thank you!
Jim
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Friday, January 14, 2011 2:26 PM
To: Jim Moon
Cc: r-help@r-project.org
Subject: Re: [R] read in data, maintain decimal places
On Jan 14, 2011, at 5:22 PM, Jim Moon wrote:
> Go
Hello David,
Thank you for pointing me to the GeneralizedHyperbolic package. I've been
playing around with hyperbFit with my data, but get:
Warning Messages:
In besselK(zeta, nu = 1) : value out of range in 'bessel_k' 10
Next, just to see if I could get something to plot I tried the
On Jan 14, 2011, at 5:22 PM, Jim Moon wrote:
Good day, All,
Is there any way to maintain the number of decimal places in the
type of situation below?
I would like to maintain the number of decimal places in 0.667,
despite the fact that its column-mates have a fourth decimal place.
You
Good day, All,
Is there any way to maintain the number of decimal places in the type of
situation below?
I would like to maintain the number of decimal places in 0.667, despite the
fact that its column-mates have a fourth decimal place.
Thank you for your time.
Jim
dat.txt contents:
MARK
Hello list,
I need to keep track of objects that are related to particular
observations. In this case, I need to keep track of polygons that are
associated with observations. What I would ideally have is one column
of a dataframe hold a "polygonal" object (from the spatstat package).
My questio
If you know the knot and want linear segments, lm (or any other "normal"
regression software) can perform the analysis. For example if you want to
regress y on x and have a knot a 20 the following code will work:
x <- runif(500,0,40)
plot(x)
for (i in 1:500) {
if (x[i] < 20) y[i] <- (-0.5*x[
On 14.01.2011 19:25, Jonathan Hughes wrote:
Hello,
Here's my problem. I have a large data frame and a vector with some of its row
names. I'd like to have a new data frame only with those rows that match this
vector of row names.
I tried this:
data<-cbind(c(1,2,3,4,5,6),c(2,3,4,5,6,7))
ro
subset(data, row.names(data) %in% name.to.keep
HTH,
Anjan
On Fri, Jan 14, 2011 at 1:25 PM, Jonathan Hughes <
jonathan.hughes...@live.com> wrote:
>
>
> Hello,
>
> Here's my problem. I have a large data frame and a vector with some of its
> row names. I'd like to have a new data frame only with tho
Jonathan -
To make your approach work, you'd need to replace ==
with %in%:
rows.to.keep<-which(rownames(data) %in% names.to.keep)
[1] 1 3 4
But to answer you're original question, remember that the
point of rownames is that they can be used to index a
data frame:
data[rows.to.keep,]
Hello,
Here's my problem. I have a large data frame and a vector with some of its row
names. I'd like to have a new data frame only with those rows that match this
vector of row names.
I tried this:
data<-cbind(c(1,2,3,4,5,6),c(2,3,4,5,6,7))
rownames(data)<-c("a", "b", "c","d","e","f")
names
When I import a data file in stata format using read.dta, the full variable
labels (e.g. variable= "inc2000"; variable label= "Total household income in
year 2000"). When I then export the same data file using write.dta, the
variable labels are not included in the new .dta file. Is there any way to
Hello,
I'm trying to estimate a Cox proportional hazard model with time-varying
covariates using coxph. The parameter estimates are fine but there is something
wrong with the survival curves I get with survfit (results are not plausible).
Let me explain why I think something's wrong.
To make s
YouTube video available:
http://www.youtube.com/watch?v=VuSaP-vwSpI
In this video, I start by building a decision tree model in R. I then export it
as a PMML file and deploy it in the ADAPA Scoring Engine. For that, I use the
ADAPA trial subscription available for free on the Zementis website
Looking at your results suggests that differences are probably based on
expected minor numerical inaccuracies and the possibly alternating sign
of the support vectors.
Best,
Uwe Ligges
On 13.01.2011 01:28, muto...@chugai-pharm.co.jp wrote:
Dear all,
I executed svm calculation using e1071 l
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Hans W Borchers
> Sent: Friday, January 14, 2011 8:55 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Help on a Display function
>
> >
> I wanted to simulate the Matlab DISPLAY
Works for my examples. But you have not specified what you actual call
to ar() was.
Uwe Ligges
On 12.01.2011 21:17, Raymond Wong wrote:
I was using ar(stats) to calculate autoregressive coefficient. It works on vector z, but it
will not work on vector rz<-rank (z, ties.method="average").
You failed to specify 2 crucial issues: Are the join points known
(linear rgression, splines) or unknown (nonlinear regression)? And as
several have already indicated, what are the smoothness constraints?
-- Bert
On Fri, Jan 14, 2011 at 6:42 AM, Federico Bonofiglio
wrote:
> Hello everybody
>
>
I wanted to simulate the Matlab DISPLAY function for some time now.
After seeing a recent proposal by Gabor Grothendieck I came up with the
following solution,
display <- function(...) {
my_names <- lapply(substitute(placeholderFunction(...))[-1], deparse)
for (my in my_names) cat(my, "=",
oh yes, and the structchange package.
After a day of experimentation I couldn't figure out how to get the
structchange package to work for my problems. Although it is probably user
error on my part, the package seems to be specific to time series problems.
Also, I think it needed regularly spaced
More or less untested without using package.skeleton after preparing the
package directories:
datapath <- "c:/packagename/data"
within(LL3,
for(i in ls()) save(list=i, file=file.path(datapath, paste(i, ".RData",
sep=""
or with package.skeleton:
package.skeleton("packagename", path="c:/"
No, all is fine, for this one-sided test, you want to calculate the
upper part of the confidence interval. If it is less than zero you have
shown that the alternative is probably right -> the true value is below
the upper confidence interval boarder with probability 1-\alpha.
Uwe Ligges
On 1
I wish I had a better answer.
There are two things that I know of that use a direct approach:
The segmentation package seems to work well if you are doing a few fits, but
I had problems when I tried running it on loads of data. It's a bit tricky
to parametrize. When I tried investigating the in
Hello:
I just found 58 help pages in 32 contributed packages containing
the terms "piecewise" and "regression", as follows:
library(sos)
pr <- ???'piecewise regression' # for "piecewise" with "regression"
summary(pr) # 58 matches in 32 packages
pr # view the 58 links sorted by package
Dear R,
I am using this R version:R version 2.11.1 (2010-05-31)(Cran Mirror Berlin)
It seems to me, that R constructs a wrong confidence intervall if you try to
get a one sided t-test.
If the true mean is 1 and my alternative hypothesis (H1) says that mu is
smaller ("less")than zero the conf
At 14.01.2011 07:09 -0800, Peter Ehlers wrote:
On 2011-01-14 02:09, bgr...@dyson.brisnet.org.au wrote:
Brian,
Thanks. My response to David follows. I should add that this problem has
never occurred previously as far as I know (I have now checked the
previous report I was sent):
This problem o
Searching the archives would surely be a better way to assemble a list
of candidate packages but the "segmented" package is surely in the list.
On Jan 14, 2011, at 9:42 AM, Federico Bonofiglio wrote:
Hello everybody
Quick question, if you'd like to throw a little tip:
does anyone knows a
Hello everybody
Quick question, if you'd like to throw a little tip:
does anyone knows a function that runs piecewise regression models with
coefficients estimation and inferences ?
Thank you
[[alternative HTML version deleted]]
__
R-help
Silvano wrote:
Hi,
I used subset command, like this:
grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses,
percevejos, p))
and the variables in select option are numeric.
They may *look* numeric, but are they really? You don't give us
enough information to determine that.
Yes, I just realised this
Apologies for the inconvenience
Thanks
From: Uwe Ligges [lig...@statistik.tu-dortmund.de]
Sent: 14 January 2011 15:20
To: Erica Donnelly-Swift
Cc: r-help@R-project.org
Subject: Re: [R] R2WinBUGS-Windows 7
Would you please min
Would you please mind to read ?bugs and see that the argument called
"bugs.directory" may be relevant?
Uwe Ligges
On 14.01.2011 15:53, Erica Donnelly-Swift wrote:
Dear all,
I'm having a slight issue with R2WinBugs it cannot detect where WinBUGS is
located.
Q: How can I change the defa
On 2011-01-14 02:09, bgr...@dyson.brisnet.org.au wrote:
Brian,
Thanks. My response to David follows. I should add that this problem has
never occurred previously as far as I know (I have now checked the
previous report I was sent):
This problem occurs to me frequently. Like Philipp and David,
On 2011-01-14 06:20, Sarah Goslee wrote:
Are you certain they are numeric? Have you tried
str() on your data?
Sarah
Silvano:
As Sarah says, do str(dados) to see that 'doses' is
NOT numeric. The error message is very clear; it tells you
that 'doses' is a factor. My guess is that you imported
Dear all,
I'm having a slight issue with R2WinBugs it cannot detect where WinBUGS is
located.
Q: How can I change the default path?
Any advice is greatly appreciated. Thanks.
Regards
Erica
I'm using R2WinBUGs (R version 2.21.1) on windows platform (Windows 7).
I have downloaded WinBU
On Fri, Jan 14, 2011 at 07:58:07PM +1000, bgr...@dyson.brisnet.org.au wrote:
>
> Thanks for your e-mail. The data was a report derived from a statewide
> database, saved in EXCEL format, so the usual issue of the vagaries of
> human data entry variation wasn't the issue as the data was an automate
Dear all,
I have a seemingly easy question but couldn´t find a solution so far:
I´d like to have all datasets from Crawley´s "R Book" in an own package, so
that I can easily access them.
Let´s assume they are all saved on C: in the following directory:
setwd("C:\\Crawleydata")
Now I am loadin
Are you certain they are numeric? Have you tried
str() on your data?
Sarah
On Fri, Jan 14, 2011 at 9:08 AM, Silvano wrote:
> Hi,
>
> I used subset command, like this:
>
> grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses,
> percevejos, p))
>
> and the variables in select option
Hi,
I used subset command, like this:
grupoP = subset(dados, grupos=='P', select=c(mortos, vivos,
doses, percevejos, p))
and the variables in select option are numeric.
I tried fit a model with command:
ajuste.logit = glm(cbind(mortos,percevejos)~log10(doses),
family=binomial(logit), data
Here is a more elegant solution using the plyr package.
my.data <- expand.grid(Thesis = 1:3, Day = c(0, 14), Run = 1:10)
my.data$A <- rpois(nrow(my.data), 10)
my.data$B <- rpois(nrow(my.data), 10)
my.data$C <- rpois(nrow(my.data), 10)
library(plyr)
ddply(my.data, .(Thesis, Day), function(x){
Dear Romezo,
a solution maybe not that elegant and effective, but seems to work:
test_calculate<-function() {
tarrow<-1
TARGET<-data.frame("Thesis"=0, "Day"=0,"A"=0,"B"=0,"C"=0)
for (i in c(unique(my.data$Thesis))) {
for (j in c(unique(my.data$Day[ my.data$Thesis==i ]))) {
TEMPDF
apply(your_matrix, 1, range)
or
apply(your_matrix, 1, min)
apply(your_matrix, 1, max)
On Fri, Jan 14, 2011 at 11:44 AM, Barth B. Riley wrote:
> Hello
>
> Is there a straightforward way of getting a vector containing the minimum
> (or maximum) value of each row of a matrix?
>
> Thanks
>
> Barth
Hello
Is there a straightforward way of getting a vector containing the minimum (or
maximum) value of each row of a matrix?
Thanks
Barth
PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the
Dear Pierre,
A more elegant solution is to use ggsave()
library(ggplot2)
for (i in 1:2) {
p <-
qplot(carat, data=diamonds,
fill=color,geom='histogram')+scale_y_continuous(i)
ggsave(filename = paste('test ',i,'.png',sep=''), plot = p)
}
Best regards,
Thierry
--
The corrected code:
library(ggplot2)
for (i in 1:2) {
png(file=paste('test ',i,'.png',sep=''))
print(qplot(carat, data=diamonds,
fill=color,geom='histogram')+scale_y_continuous(i))
dev.off()
}
Thanks
Le 14/01/2011 02:17, Pierre-Olivier Chasset a écrit :
Hello,
this following code give
Ofcourse you can loop over your data, but a vectorised way:
f.search <- function(x, ref, search) {
cs <- match(cumsum(x==ref), cumsum(x==ref))
outp <- suppressWarnings(tapply(x==search,cs, function(x)
min(which(x==1
outp <- outp[outp!=Inf] # To remove the occurences where nothing was f
Thanks so much that works, but I just realised I was unclear, I meant I need
to select all the "MagDwn" after every "Resp" :)
--
View this message in context:
http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3217456.html
S
Hi:
If I understood you correctly, the following may work:
# Utility function to compute all pairwise differences of a vector:
# The upper triangle subtracts x_i - x_j for j > i; if you want it the
# other way around, use lower.tri() instead of upper.tri().
# Coercion to vector means that the dif
Try this:
!list %in% c("aa", "bb")
On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
> Hi everybody,
>
> I have the following problem. I have a vector containing character
> elements,
> such as:
>
> list = c("aa","bb","cc","dd","ee")
>
> I want to create an index which identifies the element
it works!
thank you so much
Mario
On Fri, Jan 14, 2011 at 1:29 PM, Henrique Dallazuanna wrote:
> Try this:
>
> !list %in% c("aa", "bb")
>
> On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
>
>> Hi everybody,
>>
>> I have the following problem. I have a vector containing character
>> element
Try this:
!list %in% c("aa", "bb")
On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
> Hi everybody,
>
> I have the following problem. I have a vector containing character
> elements,
> such as:
>
> list = c("aa","bb","cc","dd","ee")
>
> I want to create an index which identifies the element
Other option:
which(!diff(as.numeric(factor(x, levels = c("MagDwn", "Resp")[1]
On Fri, Jan 14, 2011 at 10:12 AM, Henrique Dallazuanna wrote:
> Try this:
>
> which(x %in% c("MagDwn", "Resp"))[2]
>
>
> On Fri, Jan 14, 2011 at 7:22 AM, surreyj wrote:
>
>>
>> Hello everyone,
>>
>> I am current
Hi everybody,
I have the following problem. I have a vector containing character elements,
such as:
list = c("aa","bb","cc","dd","ee")
I want to create an index which identifies the elements that are different
from, e.g. "aa" and "bb".
When I do the following:
jj = list!="aa" & list!="bb"
> j
On Thu, Jan 13, 2011 at 7:36 PM, Sean Zhang wrote:
> Dear R helpers:
>
> I like to apply deparse(substitute()) on multiple arguments to collect the
> names of the arguments into a character vector.
> I used function test.fun as below. it works when there is only one input
> argument. but it does n
Try this:
which(x %in% c("MagDwn", "Resp"))[2]
On Fri, Jan 14, 2011 at 7:22 AM, surreyj wrote:
>
> Hello everyone,
>
> I am currently working with some data where I need to select the first
> occurrence of a value after the occurrence of another value.
>
> The data has two columns, one with a
Pierre,
You did not look hard enough. You need FAQ 7.22
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur-
Hi,
I'll do something like this (there is probably a nicer way, but this code
is what first comes up to my mind)
provided your data is in x
pos1 <- which(x %in% val1)[1]
pos2 <- which(x %in% val2)[which(x %in% val2) > pos1][1]
--
View this message in context:
http://r.789695.n4.nabbl
Hi, i have that table
Thesis Day A B C
1 0 83.43 90.15 22.97
1 0 85.50 94.97 16.62
1 0 83.36 95.38 20.70
1 0 84.47 92.16 23.58
1 0 83.98 95.33 19.39
1 0 82.86 93.78 24.55
1 0
Hello everyone,
I am currently working with some data where I need to select the first
occurrence of a value after the occurrence of another value.
The data has two columns, one with a time and one with occurence of certain
events.
The column of data I want to select from looks like this (a
David,
I haven't found any FAQs for ggplot.
Do you mean the http://cran.r-project.org/faqs.html?
In this one, no subject seems to be linked with my problem about qplot
in a loop.
Best regards,
Pierre-Olivier
Le 14/01/2011 05:43, David Winsemius a écrit :
On Jan 13, 2011, at 8:17 PM, Pierre-
Brian,
Thanks. My response to David follows. I should add that this problem has
never occurred previously as far as I know (I have now checked the
previous report I was sent):
Hello David,
Thanks for your e-mail. The data was a report derived from a statewide
database, saved in EXCEL format, so
Hello David,
Thanks for your e-mail. The data was a report derived from a statewide
database, saved in EXCEL format, so the usual issue of the vagaries of
human data entry variation wasn't the issue as the data was an automated
report, which is run every three months. I would not have even noticed
On Fri, 14 Jan 2011, David Scott wrote:
As a further note, this is a reminder that whenever you get data via
a spreadsheet the first thing to do is examine it and clean up any
problems. A basic requirement is to tabulate any categorical
variable. Spreadsheets allow any sort of data to be enter
As a further note, this is a reminder that whenever you get data via a
spreadsheet the first thing to do is examine it and clean up any
problems. A basic requirement is to tabulate any categorical variable.
Spreadsheets allow any sort of data to be entered, with no controls. My
experience is th
Dear "R workers",
I have a question about a mixed logistic regression for
repeated data. After fitting a traditional logistic
regression a quasi-complete separation with too large SE
for a covariate (sex) was shown. In these days I read a
lot of pubblication about the possible solutions of
q
Dear all,
I am quite new at R and have a question about using lme with crossed random
factors. I followed the instructions of Pinheiro & Bates, but that did not
work because of the non grouping of my data. Reading prior threads (
http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg10849.html),
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/13/2011 07:06 PM, Prof Brian Ripley wrote:
> On Thu, 13 Jan 2011, Duncan Murdoch wrote:
>
>> On 11-01-13 6:26 AM, Rainer M Krug wrote:
> Hi
>
> Assuming the following:
>
> x<- data.frame(a=1:10, b=runif(10))
> str(x)
> 'data.frame':
77 matches
Mail list logo