Thanks for help.
But, I am surprised, that mapply is slower than for loop?
OV
From: Uwe Ligges
Cc: "r-help@r-project.org"
Sent: Saturday, November 3, 2012 4:32 PM
Subject: Re: [R] mapply instead for loop
On 30.10.2012 20:01, Omphalodes Verna wrot
Yes, the assign command goes a little way toward what what I was hoping for.
But it requires a different syntax, and it does not in general let you use
quoted expressions that you could use with other assignment operators. For
instance,
> DD <- 1:3
> assign("DD[2]", 5)
> DD
[1] 1 2 3
So I am s
Ah! Excellent! That will be most useful. And sorry about the typo.
I found another function in a different discussion that also seems to work,
at least in most cases I have tried. I do not at all understand the
difference between the two.
doppel <- function(x) {eval(parse(text=x))
However, ne
There is a phenomenon that occurs here which, it seems to me,
merits some emphasis. The glm() function appears to be perfectly
willing to take a variable of class "Date" and treat it as a continuous
variable.
Apparently what it does (on the basis of one little experiment that I
did) is convert
Most likely your "Date" is either a character or a factor (you need to
provide an 'str' of the dataframe). You are therefore most likely
doing a character compare and that is the reason for your problem.
You need to convert to a character string of the format -MM-DD to
do the correct character
Here is how to convert your column of factors into Dates:
> x <- read.table(text = '2/10/2011
+ 2/20/2011
+ 3/4/2011')
> # read in as factors
> str(x)
'data.frame': 3 obs. of 1 variable:
$ V1: Factor w/ 3 levels "2/10/2011","2/20/2011",..: 1 2 3
> # convert to Date
> x$date <- as.Date(as.chara
I am very new to R, so I apologize if this question is trivial.
I have a row in my data of dates in the format mm/dd/; about 3500 rows.
I am using this variable in a logistic regression model, and need to treat
it as continuous, not a factor as r has decided it is.
I tried the as.numeric fu
Dear R-help readers,
i've created a database for quotes data (for 4 years; 2007 -- 2010)
with the sqldf package. This database contains a column "Date" in the
format mm/dd/.
The table in the database is called "main.data" and the database
itself "Honda". I tried to get the Data just f
Mike, thanks for your answer.
I thought GDAL is a library itself. You suggest underlying libraries. Do you
know where can I find them?
The other option: to convert the jpeg2000 files outside R: is it possible in
R to execute an extern program?
Btw I'm working with OSX Lion and still in the steep
Even you used perm="Exact", the maximum observations allowed is only 10. If
data exceeds this, perm="Prob" is used instead of "Exact". So, the p-values
are always changed. The Porb method will approximate the permutation
distribution by randomly exchanging pairs of Y elements.
--
View this mes
Hi,
thanks A.K
try this not working
#*
# Load historical data
#**
library('quantmod')
endDate =Sys.Date()
startDate = as.Date(endDate-10, order="ymd")
dataspy = getSymbo
Dear R-help readers,
i've created a database for quotes data (for 4 years; 2007 -- 2010)
with the sqldf package. This database contains a column "Date" in the
format mm/dd/.
The table in the database is called "main.data" and the database
itself "Honda". I tried to get the Data just
HI Bill,
It is much simpler.
# with aggregate() and merge()
res1<-with(dat2,aggregate(seq_len(nrow(dat2)),by=list(idr=idr),FUN=function(i)
with(dat2[i,], any(schyear<=5 & year ==0
res2<-merge(dat2,res1,by="idr")
colnames(res2)[4]<-"flag"
within(res2,{flag<-as.integer(flag)})
#idr schyea
Or, even simpler,
> flag <- with(dat2, ave(schyear<=5 & year==0, idr, FUN=any))
> data.frame(dat2, flag)
idr schyear year flag
1 1 4 -1 TRUE
2 1 50 TRUE
3 1 61 TRUE
4 1 72 TRUE
5 2 90 FALSE
6 2 101 FALSE
7 2 112
On 11/04/2012 06:27 AM, Nathan Miller wrote:
Hi,
I'm trying to create a plot showing the density distribution of some
shipping data. I like the look of violin plots, but my data is not
continuous but rather binned and I want to make sure its binned nature (not
smooth) is apparent in the final pl
ave() or split<-() can make that easier to write, although it
may take some time to internalize the idiom. E.g.,
> flag <- rep(NA, nrow(dat2)) # add as.integer if you prefer 1,0 over
TRUE,FALSE
> split(flag, dat2$idr) <- lapply(split(dat2, dat2$idr), function(d)with(d,
any(schyear<=5 & year
> -Original Message-
> From: William Dunlap
> Sent: Saturday, November 03, 2012 11:23 AM
> To: 'Hafen, Ryan P'; Bert Gunter
> Cc: r-help@r-project.org
> Subject: RE: [R] finding global variables in a function containing formulae
>
> findGlobals must be explicitly ignoring calls to the ~ fu
Hi,
May be this helps:
dat2<-read.table(text="
idr schyear year
1 4 -1
1 5 0
1 6 1
1 7 2
2 9 0
2 10 1
2 11 2
",sep="",header=TRUE)
dat2$flag<-unlist(lapply(split(dat2,dat2$i
I have a similar sort of follow up and I bet I could reuse some of this
code but I'm not sure how.
Let's say I want to create a flag that will be equal to 1 if schyear < = 5
and year = 0 for a given idr. For example
> dat
idr schyear year
1 4 -1
1 50
1
Hi Jim,
Thank you so much. That does exactly what I want.
Chris
On Sat, Nov 3, 2012 at 1:30 PM, jim holtman wrote:
> > x <- read.table(text = "idr schyear year
> + 1 80
> + 1 91
> + 1 10 NA
> + 2 4 NA
> + 2 5 -1
> + 2 60
> + 2 7
for the second part use 'assign'
> assign(paste0('a', 'a'), 3)
> aa
[1] 3
>
On Sat, Nov 3, 2012 at 5:31 PM, andrewH wrote:
> Dear folks--
>
> Suppose I have an expression that evaluates to a string, and that that
> string, were it not a character vector, would be a symbol. I would like a
> fu
Is this what you want (the answer you "wanted" is not correct):
> aa <- 3.1416
> bb <- function(x) {x^2}
> r <- 2
> xx <- c("aa", "bb")
>
> doppel <- function(x) get(x)
>
> out <- doppel(xx[1])*doppel(xx[2])(r)
>
> out
[1] 12.5664
>
On Sat, Nov 3, 2012 at 5:31 PM, andrewH wrote:
> Dear fol
works fine for me creating:
> state_pflt200 <- df$p_fatal <200
> df[state_pflt200, c("state.name","p_fatal")]
[1] state.name p_fatal
<0 rows> (or 0-length row.names)
>
considering that there were no values less than 200 in your data, the
result is correct.
So what is the problem?
On Sat, Nov 3
Hello,
The most part of the program works except that the following logical variable
does not get created although the second logical variable-based extraction
works.
I don't understand what I am doing wrong here.
state_pflt200 <- df$p_fatal <200
df[state_pflt200, c("state.name","p_fatal")]
On Sat, Nov 3, 2012 at 4:08 PM, Alexander Shenkin wrote:
> On 11/2/2012 5:14 PM, Gabor Grothendieck wrote:
> > On Fri, Nov 2, 2012 at 6:02 PM, Alexander Shenkin
> wrote:
> >> Hi Folks,
> >>
> >> I'm trying to extract just the backreferences from a regex.
> >>
> >>> temp = "abcd1234abcd1234"
> >>
Dear folks--
Suppose I have an expression that evaluates to a string, and that that
string, were it not a character vector, would be a symbol. I would like a
function, call it doppel(), that will take that expression as an argument
and produce something that functions exactly like the symbol woul
It easier than that. I forgot I can do it entirely within R:
setwd("/temp/csv")
files <- Sys.glob("daily*csv")
output <- file('Rcombined.csv', 'w')
for (i in files){
cat(i, '\n') # write out file processing
input <- readLines(i)
input <- input[-1L] # delete header
writeLines(inp
These are not commands, but programs you can use. Here is a file copy
program in "perl" (I spelt it wrong in the email); This will copy all
the files that have "daily" in their names. It also skips the first
line of each file assuming that it is the header.
perl can be found on most systems.
On 11/2/2012 5:14 PM, Gabor Grothendieck wrote:
> On Fri, Nov 2, 2012 at 6:02 PM, Alexander Shenkin wrote:
>> Hi Folks,
>>
>> I'm trying to extract just the backreferences from a regex.
>>
>>> temp = "abcd1234abcd1234"
>>> regmatches(temp, gregexpr("(?:abcd)(1234)", temp))
>> [[1]]
>> [1] "abcd123
Jim,
Where can I find documentation of the commands you mention?
Thanks
On Sat, Nov 3, 2012 at 12:15 PM, jim holtman wrote:
> A faster way would be to use something like 'per', 'awk' or 'sed'.
> You can strip off the header line of each CSV (if it has one) and then
> concatenate the files t
Hello,
Without data it's not easy to answer to your questions, but
1. Use ?unlist. If the data is in a file, read it with ?read.table and
the unlist the result. All columns will be stacked.
dat <- read.table(filename, ...)
unlist(dat)
2. At best confusing. But to divide a vector into groups
On Nov 3, 2012, at 9:07 AM, dattel_palme wrote:
> Hi People!
>
> I have following concern consisting of some steps to do in R:
>
> I have an ascii file (table) consisting of many columns and rows.
> 1. I would like to order all values of the columns one under each other. It
> will begin with
Hi,
I'm trying to create a plot showing the density distribution of some
shipping data. I like the look of violin plots, but my data is not
continuous but rather binned and I want to make sure its binned nature (not
smooth) is apparent in the final plot. So for example, I have the number of
indivi
A faster way would be to use something like 'per', 'awk' or 'sed'.
You can strip off the header line of each CSV (if it has one) and then
concatenate the files together. This is very efficient use of memory
since you are just reading one file at a time and then writing it out.
Will probably be a
I use notepad++ on Windows, so it is easy to add a "hotkey" that will
surround a block of code that you want to execute with:
system.time({..code to run..})
Usually you don't want it around each statement. I use the following
function to have it print out CPU and memory usage at various
On 03.11.2012 19:42, jim holtman wrote:
Here is a faster solution to your 'apply'; use 'sapply' instead:
str(x)
num [1:100, 1:30] 0.0346 0.4551 0.66 0.8528 0.5494 ...
system.time(y <- apply(x, 1, cumsum))
user system elapsed
13.240.61 14.02
system.time(ys <- sapply(1:
On 03.11.2012 16:52, mrzung wrote:
Hi all;
I want to print system.time whenever I execute any command.
It takes too much time to type "system.time()" function to all command.
is there any solution on it?
See ?Rprof on how to profile your code.
And,
apply(matrix,1,cumsum) command is too
Here is a faster solution to your 'apply'; use 'sapply' instead:
> str(x)
num [1:100, 1:30] 0.0346 0.4551 0.66 0.8528 0.5494 ...
> system.time(y <- apply(x, 1, cumsum))
user system elapsed
13.240.61 14.02
> system.time(ys <- sapply(1:col, function(a) cumsum(x[,a])))
user syst
> x <- read.table(text = "idr schyear year
+ 1 80
+ 1 91
+ 1 10 NA
+ 2 4 NA
+ 2 5 -1
+ 2 60
+ 2 71
+ 2 82
+ 2 93
+ 2 104
+ 2 11 NA
+ 2 126
+ 3 4 NA
+ 3 5 -2
+
HI,
Could you check whether you are getting the same result with tz="GMT"?
as.POSIXct(x,format=fmt,tz="GMT")
#[1] "2004-01-01 01:15:00 GMT" "2004-01-01 01:30:00 GMT"
#[3] "2004-01-01 01:45:00 GMT" "2004-01-01 02:00:00 GMT"
#[5] "2004-01-01 02:30:00 GMT" "2004-01-01 03:00:00 GMT"
#[7] "2004-01-01 0
Hi all;
I want to print system.time whenever I execute any command.
It takes too much time to type "system.time()" function to all command.
is there any solution on it?
And,
apply(matrix,1,cumsum) command is too slow to some large matrix.
is there any function like rowCumSums ?
thank u!
-
Hello,
I am attempting to use optim under the default Nelder-Mead algorithm for
model fitting, minimizing a Chi^2 statistic whose value is determined by a
.C call to an external shared library compiled from C & C++ code.
My problem has been that the R session will immediately crash upon starting
Hi,
Try this:
genotype1<-factor(genotype,levels=c("CJ1450 NW 4/25/12","CJ1450 BAL 4/25/12",
"CJ1450 NW\n4/27/12",
"CJ1450 BAL 4/27/12", "CJ1721 NW 4/27/12", "CJ1721 BAL\n4/27/12",
"CJ1721 NW 4/29/12", "CJ1721 BAL 4/29/12") )
segplot(genotype1 ~ lower + upper, data = x, draw.bands =
FALSE, center
Hi People!
I have following concern consisting of some steps to do in R:
I have an ascii file (table) consisting of many columns and rows.
1. I would like to order all values of the columns one under each other. It
will begin with column 1, then column 2 under column 1, column 3 under
column 2
findGlobals must be explicitly ignoring calls to the ~ function.
You could poke through the source code of codetools and find
where this is happening.
Or, if you have the source code for the package you are investigating,
use sed to change all "~" to "%TILDE%" and then use findGlobals on
the resul
Hello,
Try the following. I've called your data.frames 'dat' and 'dat2'
# First your datasets, see ?dput
dput(dat)
structure(list(idr = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), schyear = c(8L, 9L,
10L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 4L, 5L, 6L, 7
On Nov 3, 2012, at 6:36 AM, Jorge Dinis wrote:
> Thanks David, I used you suggestion and it worked fine, please see below for
> what I did.
>
> segplot(reorder(factor(genotype), genotype) ~ lower + upper
Perhaps a missing close-paren . ^
Although reading this as a formatted posting
Hi,
I have the following data:
> data[1:20,c(1,2,20)]
idr schyear year
1 80
1 91
1 10 NA
2 4 NA
2 5 -1
2 60
2 71
2 82
2 93
2 104
2 11 NA
2 126
3 4 NA
3 5 -2
3 6 -1
3
Hi,
Sorry, I forgot to answer the second question.
txt<-paste("\\10",unique(month(index(x.1))),"\\2",sep="") #without the
as.character() also should work
#because
str(paste("\\10",unique(month(index(x.1))),"\\2",sep="")) # it returns a
character
# chr "\\101\\2"
#Here too:
str(paste(10,unique
Sys.setenv(TZ="GMT") did the trick! Thank you very much. I'll continue
to work the larger problem with this option.
Out of curiosity, however, can the following code be modified so that the
replacement argument is informed by the month of x.1?:
index(y.1)<-as.POSIXct(gsub("(.*\\-).*(\\-.*)","
I am out of the office until 30/11/2012.
Please send work related emails to laura.jor...@uk.rsagroup.com or personal
emails to alanch...@gmail.com.
Note: This is an automated response to your message "R-help Digest, Vol
117, Issue 3" sent on 03/11/2012 11:00:07.
This is the only notification y
Hello Arun,
I too am using R 2.15 and am unable to get the same result as you. You
will notice in the R code that follows that when I use 'update' the time
in the xts object goes haywire. For example, "2004-04-04 01:15:00 EST"
gets converted to "2004-01-03 22:15:00 PST" (see below). Because
On 11/3/2012 6:47 AM, Duncan Murdoch wrote:
On 12-11-02 7:47 PM, Robert Baer wrote:
I am trying to figure out how to use rgl package for animation. It
appears that this is done using the play3d() function. Below I have
some sample code that plots a 3D path and puts a sphere at the point
farthe
On the absence of any data examples from you per the posting guidelines, I will
refer you to the help files for the melt function in the reshape2 package.
Note that there can be various mixtures of wide versus long... such as a wide
file with one date column and columns representing all stock p
On 03.11.2012 14:56, Brawni wrote:
i will sorry! anyway it's a data.frame object. isn't that good?
And what are you referring to? I do not see any citation in this message?
A, some Nabble generated mail... Please do read the posting guide to
this mailing list.
Uwe Ligges
--
View
On 30.10.2012 20:01, Omphalodes Verna wrote:
Hi all!
My question in about using mapply instead for loop. Below is a example with for
loop: Is it posible to give same results with mapply function?
Thanks for help!
OV
x <- 1:10
y <- 1:10
xyz <- data.frame(expand.grid(x,y)[1], expand.grid(x,y
Hi everybody
I am trying to find contrast in MANOVA.
I used next code
contrasts(ffage)<-ctr
contrasts(ffage)
MANOVA.agec<-manova(Y1~ffage,data=vol18.df)
summary(MANOVA.agec, split =list (ffage=list("0-17 v over 18"=0, "18-25 v
over 26"=1, "26-31 v over 32"=2, "32-42 v over 43"=3, "43-65 v 66+"=4
Thanks David, I used you suggestion and it worked fine, please see below for
what I did.
segplot(reorder(factor(genotype), genotype) ~ lower + upper
On Nov 3, 2012, at 2:47 AM, David Winsemius wrote:
> define genotype as a factor
[[alternative HTML version deleted]]
i will sorry! anyway it's a data.frame object. isn't that good?
--
View this message in context:
http://r.789695.n4.nabble.com/Bioconductor-merging-annotation-with-list-of-probeids-tp4648251p4648305.html
Sent from the R help mailing list archive at Nabble.com.
_
On Nov 2, 2012, at 10:06 PM, 21rosit wrote:
> Hi I need to know how to make pch symbols like pch=3 (+) or pch=4(x) or even
> the border of squares or triangles thicker without changing the size. I have
> a lot of symbols of different colors but you can't see the colors clearly
> and I don't want
On 12-11-02 7:47 PM, Robert Baer wrote:
I am trying to figure out how to use rgl package for animation. It
appears that this is done using the play3d() function. Below I have
some sample code that plots a 3D path and puts a sphere at the point
farthest from the origin (which in this case also a
On Thu, Nov 1, 2012 at 2:04 PM, Hafen, Ryan P wrote:
> I need to find all global variables being used in a function and
> findGlobals() in the codetools package works quite nicely. However, I am not
> able to find variables that are used in formulae. Simply avoiding formulae
> in functions is
Jeff,
If you're willing to educate, I'd be happy to learn what wide vs long
format means. I'll give rbind a shot in the meantime.
Ben
On Nov 2, 2012 4:31 PM, "Jeff Newmiller" wrote:
> I would first confirm that you need the data in wide format... many
> algorithms are more efficient in long forma
On Nov 2, 2012, at 8:04 PM, JDINIS wrote:
> Hello all, thanks for your time and help. Below are my commands, and it
> generates a really nice plot, however I am not happy with the reorder()
> function. I would like the order to be the same as they appear in the
> genotype variable "genotype <- c
Hello all, thanks for your time and help. Below are my commands, and it
generates a really nice plot, however I am not happy with the reorder()
function. I would like the order to be the same as they appear in the
genotype variable "genotype <- c("CJ1450 NW 4/25/12","CJ1450 BAL
4/25/12","CJ1450 NW
65 matches
Mail list logo