Hi Peter,
Thanks for contributing such a great answer. Can you please provide a
pointer to the documentation where it explains why dd$B <- s and dd["B"] <-
s have such different behavior?
(I am perfectly happy if you write the explanation but if it saves you time
to point to some reference that wo
How about going back to earlier versions if you don't need the latest ones?
On Thu, Oct 26, 2017 at 12:59 PM, Klaus Michael Keller <
klaus.kel...@graduateinstitute.ch> wrote:
> Dear all,
>
> I just installed the "Short Summer" R update last week. Now, my R Studio
> doesn't open anymore!
>
> -->
na.rm=TRUE (you need to capitalize)
On Fri, Oct 27, 2017 at 10:43 AM, Engin YILMAZ
wrote:
> Dear R Staff
>
> My working file is in the annex. "g1.csv"
> I have only 2 columns. Rice and coke.
> I try to execute following(below) function, but do not work.
> Because "Coke" value has NA values.
>
If one does not need all the intermediate results then after defining data
just one line:
grand_total <- nrow(data)*ncol(data) - sum( sapply(data, function(x) sum(
is.na(x) | x == 0 ) ) )
# 76
On Sun, Oct 29, 2017 at 2:38 PM, Rui Barradas wrote:
> Hello,
>
> Your attachment didn't came throu
I did a simple search and got hits immediately, e.g.
https://www.r-bloggers.com/passing-arguments-to-an-r-script-from-command-lines/
On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help
wrote:
> Is it possible to pass parameters to an R Script, say, from Java or other
> language?
>
> I did some
I do not program in Java but it seems a Java program can make system calls
which would be equivalent to running from the command line, but done from
within a Java program. Not sure whether that would meet your needs and if
not why not. Just a suggestion.
Check out
http://www.java-samples.com/show
If you need a function (e.g. convertTime ) from a package (unknown?) then
you cannot simply instruct R to install the function.
e.g. if you give the command
> install.packages("convertTime")
you will get an error message like
"package 'convertTime' is not available (for R version 3.4.1)"
I did a G
Hi,
I did a quick search for other packages that provide the beta binomial
distribution and found "rmutil".
> install.packages("rmutil")
The package has the CDF (pbetabinom) and inverse CDF (qbetabinom) among
other functions.
HTH,
Eric
On Wed, Nov 1, 2017 at 7:50 AM, MCGUIRE, Rhydwyn <
rm...@
Some comments:
1. sink() does not return a value. There is on point to set attr <-
sink(...). Just give the command sink("C://etc")
2. to complete the saving to the file you must give a second sink command
with no argument: sink()
So your code would be (pseudo-code, not actual code)
sink( "fi
ignaling_submodule3.txt")
>
> sink("C://Users//Priya//Desktop//Attractor analysis_all
> genes//synaptogenesis//attr.txt")
>
>
> sink()
>
> attr <- getAttractors(net, type="asynchronous")
>
>
> Priya
>
>
> On Wednesday, 1 November 20
tion
> "dbb"
>
> >
>
> I am confused because if the package TailRank is already there, why the
> pervious code does not work to calculate dbb (x,N,u,v) and I got error? If
> I do not have the package, would you please let me know the right commands
> I should writ
matches <- merge(training,data,by=intersect(names(training),names(data)))
HTH,
Eric
On Wed, Nov 1, 2017 at 6:13 PM, Elahe chalabi via R-help <
r-help@r-project.org> wrote:
> Hi all,
> I have two data frames that one of them does not have the column ID:
>
> > str(data)
> 'data.frame':
> output with File | Save to File.
>
> ---
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Be
frame
>
>
> On Wednesday, November 1, 2017 10:18 AM, Eric Berger <
> ericjber...@gmail.com> wrote:
>
>
>
> matches <- merge(training,data,by=intersect(names(training),names(data)))
>
> HTH,
> Eric
>
>
>
> On Wed, Nov 1, 2017 at 6:13 PM, Elahe chal
Hi Paul,
#First I set up some sample data since I don't have a copy of your data
dtOrig <- as.Date( c("1985-04-01","1985-07-01","1985-12-01","1986-04-01"))
dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325),
CargoTons=c(1000,1080,3785,4200) )
#Generate the complete set of dates
Following Erin's pointer:
library(zoo)
times <- seq(from=as.POSIXct("2015-12-18 00:00:00"),
to=as.POSIXct("2017-10-24 23:00:00"), by="hour")
mydata <- rnorm(length(times))
tseri <- zoo( x=mydata, order.by=times )
HTH,
Eric
On Tue, Nov 7, 2017 at 9:59 AM, Erin Hodgess
wrote:
> Hello!
a, order.by=times )
when use it without x=mydata like,
tseri <- zoo( x, order.by=times )
it works.
I checked it by following command
x[times==as.POSIXct("2015-12-18 02:00:00")] and it gave me the true value.
Do you think it is okay?
By the way, I appreciate for fast rep
Why not define your own functions based on d?
e.g.
myCumDist <- function(x) { integrate(d, lower=-Inf, upper=x)$value }
myQuantile <- function(x) { uniroot(f=function(y) { h(y) - x },
interval=c(-5,5)) } # limits -5,5 should be replaced by your own which
might require some fiddling
e.g.
d <- fun
I was not able to reproduce this problem. I tried two environments
1. Ubuntu 14.04.5 LTS, R version 3.4.2 (same R version as yours)
2. Windows 10, same R version
On Wed, Nov 8, 2017 at 9:50 AM, Zeki ÇATAV wrote:
> Hello,
> I've an error recently.
>
> ggplot(data = mtcars, aes(x= wt, y= mpg)) +
gt;
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul
> Bernal
> > Sent: Wednesday, November 8, 2017 2:46 PM
> > To: Eric Berger
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Adding Records to
How about this workaround - add 1 to the vector
x <- c(1,0,2,1,0,2,2,0,2,1)
tabulate(x)
# [1] 3 4
tabulate(x+1)
#[1] 3 3 4
On Fri, Nov 10, 2017 at 4:34 PM, Marc Schwartz wrote:
> Hi,
>
> To clarify the default behavior that Boris is referencing below, note the
> definition of the 'bin' argument
Hi Andras,
I have not used this package before but I did the following steps to arrive
at an answer. Hopefully both the answer is what you are looking for and
also the steps to understand how you can answer such questions yourself in
the future.
1. R is an object-oriented language, but there are se
Hi Cristina,
You can try this:
> Community <- R6Class("Community",
public = list(
e = NULL,
initialize = function() { self$e <- list() },
add = function( person ) { self$e[[ length(self$e)
+ 1]] <<- p
As Jeff recommends, I use the pkg::fun for clarity.
However I probably use it more than needed (e.g. I use the dplyr:: prefix
on all dplyr function calls instead of just the functions with name
collisions).
Are there any tools that can be used (like a form of lint) to identify uses
of functions wit
Hi Joe,
The centering and re-scaling is done for the purposes of his example, and
also to be consistent with his definition of the sharpe function.
In particular, note that the sharpe function has the rf (riskfree)
parameter with a default value of .03/252 i.e. an ANNUAL 3% rate converted
to a DAIL
that each column
has mean MU_D and std deviation SIGMA_D.
HTH,
Eric
On Tue, Nov 21, 2017 at 2:33 PM, Eric Berger wrote:
> Hi Joe,
> The centering and re-scaling is done for the purposes of his example, and
> also to be consistent with his definition of the sharpe function.
> I
to have
> whatever properties they have (meaning they will have whatever average and
> std dev they happen to have). Is that correct?
>
> Thanks, -Joe
>
>
>> On Tue, Nov 21, 2017 at 5:36 AM, Eric Berger wrote:
>> [re-sending - previous email went out by accident be
LOL. Great reply Jim.
(N.B. Jim's conclusion is "debatable" by a judicious choice of seed. e.g.
set.seed(79) suggests that making the request more readable will actually
lower the number of useful answers. :-))
On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon wrote:
> Hi Engin,
> Sadly, your illustr
Since you only provide pseudo-code I will give a guess as to the source of
the problem.
It is easy to get "burned" by use of the ifelse statement. Its results have
the same "shape" as the first argument.
My suggestion is to try replacing ifelse by a standard
if ( ) {
} else {
}
HTH,
Eric
I totally agree with Duncan's last point. I find it hard to reconcile your
early remarks (which indicate a deep knowledge of programming) with the
idea that your code is not built up from combining small(ish) functions.
Small functions would generally be considered best practices. Try searching
on
.Call("compute_values_cpp")
Also, if you were passing arguments to the C++ function you would need to
declare the function differently.
Do a search on "Rcpp calling C++ functions from R"
HTH,
Eric
On Sun, Dec 3, 2017 at 3:06 AM, Martin Møller Skarbiniks Pedersen <
traxpla...@gmail.com> wrote:
>
Hi,
Sarah's last comment about using min/max x got me thinking. It's not that
the points are "very close together", it's that the x-values are not
ordered. So the plot is actually drawing a dashed line back-and-forth
between different points on the line, which has the effect of making the
result ap
Hi Boris,
Do a search on "the order of elements of the symmetric group". (This search
will also turn up homework questions and solutions.) You will understand
why you are seeing this once you understand how a permutation is decomposed
into cycles and how the order relates to a partition of n (n=10
ifelse returns the "shape" of the first argument
In your ifelse the shape of "3 > 2" is a vector of length one, so it will
return a vector length one.
Avoid "ifelse" until you are very comfortable with it. It can often burn
you.
On Wed, Dec 13, 2017 at 5:33 PM, jeremiah rounds
wrote:
> ifel
You seem to have a typo at this expression (and some others like it)
Namely, you write
any(!dat2$norm_sd) >= 1
when you possibly meant to write
!( any(dat2$norm_sd) >= 1 )
i.e. I think your ! seems to be in the wrong place.
HTH,
Eric
On Thu, Dec 14, 2017 at 3:26 PM, DIGHE, NILESH [AG/2362]
My own typo ... whoops ...
!( any(dat2$norm_sd >= 1 ))
On Thu, Dec 14, 2017 at 3:43 PM, Eric Berger wrote:
> You seem to have a typo at this expression (and some others like it)
>
> Namely, you write
>
> any(!dat2$norm_sd) >= 1
>
> when you possibly meant to wr
gt; return(df1)
>
> }
>
>else {
>
> df2 <- recursive_funlp()
>
> return(df2)
>
> }
>
> }
>
> df3 <- recursive_funlp(dataset = dat1, func = funlp2)
>
> df3
>
> }
>
2017 at 5:33 PM, Eric Berger wrote:
> The message is coming from your stopifnot() condition being met.
>
>
> On Thu, Dec 14, 2017 at 5:31 PM, DIGHE, NILESH [AG/2362] <
> nilesh.di...@monsanto.com> wrote:
>
>> Hi, I accidently left out few lines of code from the calclp
Hi Eric,
How about
match( TRUE, cumsum(hyd/sum(hyd)) > .5 ) - 1
HTH,
Eric
On Sat, Dec 16, 2017 at 3:18 PM, Morway, Eric wrote:
> The small bit of script below is an example of what I'm attempting to do -
> find the day on which the 'center of mass' occurs. In case that is the
> wrong term, I
myAuto <- Auto[ grep("ford|toyota",Auto$name),]
On Sat, Dec 16, 2017 at 10:28 PM, Bert Gunter
wrote:
> I did not care to load the packages -- small reproducible examples are
> preferable, as the posting guide suggests.
>
> But, if I have understood correctly:
>
> See, e.g. ?subset
>
> Alternat
eter dalgaard wrote:
> That probably works in this case, but it would cause grief if another car
> make had "ford" somewhere inside its name e.g. "bedford". Safer general
> practice is
>
> Auto[Auto$name %in% c("ford", "toyota"),]
>
> or
gain thank you all.
>
> abou
>
> __
>
>
> *AbouEl-Makarim Aboueissa, PhD*
>
> *Professor of Statistics*
>
> *Department of Mathematics and Statistics*
> *University of Southern Maine*
>
>
> On Sun, Dec 17, 2017 at 3:10 AM, Eric Berger
&g
/maps.google.com/?q=2730+N.+Deer+Run+Rd.Carson+City,+NV+89701+(775&entry=gmail&source=g>
> Carson City, NV 89701
> <https://maps.google.com/?q=2730+N.+Deer+Run+Rd.Carson+City,+NV+89701+(775&entry=gmail&source=g>
> (775
> <https://maps.google.com/?q=2730+N.+Deer+R
Hi Pablo,
There are probably many ways to do this in R. This suggestion uses dplyr.
The solution is actually only one line (see the line starting with dat2).
The first section simply creates the example data.
library(dplyr)
# 1. set up the example data
m <- matrix( c(0,0,0,0,0,1,1,1,0,0,1,1,1,1,2,
You have an error with the filename in the loop.
Try replacing the relevant line wtih
fileConn<-file(sprintf("TESTI/%d.txt",i))
HTH,
Eric
On Fri, Dec 29, 2017 at 4:31 PM, Luca Meyer wrote:
> Hello,
>
> I am trying to run the following syntax for all cases within the dataframe
> "data"
>
> d1 <
Hi Rolf,
I looked at
https://docs.microsoft.com/en-us/azure/sql-database/sql-database-public-data-sets
One of the first sets in the list is the airline time series (I think it is
also used in dplyr examples).
https://www.transtats.bts.gov/OT_Delay/OT_DelayCause1.asp
You might find other possibil
You can enforce these assumptions by sorting on multiple columns, which
leads to
na.locf(df1[ order(df1$ID,df1$Value), ])
On Mon, Jan 8, 2018 at 4:19 PM, Jeff Newmiller
wrote:
> Yes, you are right if the IDs are always sequentially-adjacent and the
> first non-NA value appears in the first re
Marc and Jeff give excellent advice. Since you have a commercial
perspective, here are two more points to consider:
1. There are companies that sell software built on R. For example, the
company Rstudio.com develops both free and "professional" versions of its
products RStudio and Shiny.
2. You ask
'position="dodge"' has no effect in the plot because the x-axis is a factor
variable. The bars do not need to be moved to avoid each other. The
'aes(fill=y)' is specifying that you want the color gradient to capture the
sums in the 'y' variable. You might be better off to use 'no' and 'yes'
rather
for "yes" , the other, beside
> it, with the sum for "no".
>
> I am way off track with my method here?
>
> Thanks,
> Ken
>
> Sent from Blue <http://www.bluemail.me/r?b=11745>
> On Jan 15, 2018, at 14:34, Eric Berger wrote:
>>
>> 'p
If layer$z is a matrix and you want to reverse the order of the rows, you
can do:
n <- nrow(layer$z)
layer$z <- layer$z[ n:1, ]
HTH,
Eric
On Tue, Jan 16, 2018 at 8:43 AM, lily li wrote:
> Sorry for the emails, I just wanted to have an example.
> layer$z
>
> 1 1 3 4 6 2
> 2 3 4 1 2 9
A very common chart in the financial markets is a split chart with two time
series shown in two vertically stacked sub-charts.
A classic case would be the top panel showing the time series of historical
prices of some stock, and the bottom
panel showing the volume traded per day immediately below i
This is an error message from R.
For example, if you give the following R commands
> a <- 5
> a$foo
This will generate the error message:
Error in a$foo : $ operator is invalid for atomic vectors
So you can search for the string 'x$tag' in your code (or possibly in the
package).
HTH,
Eric
On W
It seems the file contains records, with each record having 18 fields.
I would use awk (standard unix tool), creating an awk script to process the
file
into a new file with one line for each record, each line with 18 fields,
say comma-separated.
The csv file can then be easily read into R via the f
Hi Charlie,
I am comfortable to put the data in any way that works best. Here are two
possibilities: an xts and a data frame.
library(quantmod)
quantmod::getSymbols("SPY") # creates xts variable SPY
SPYxts <- SPY[,c("SPY.Close","SPY.Volume")]
SPYdf <- data.frame(Date=index(SPYxts),close=as.numer
e ggplot2 code:
>
> library(ggplot2)
> ggplot(plotDF, aes(x=Date, y=resp)) +
> facet_wrap(~parameter, ncol=1, scales="free") +
> geom_line()
>
>
> Hope that does the trick!
>
> Charlie
>
>
>
> On 01/18/2018 02:11 PM, Eric Berger wrote:
>
>
t; comic strip )
>>
>> On Sat, Jan 20, 2018 at 12:19 PM, Charlie Redmon > <mailto:redm...@gmail.com>> wrote:
>>
>> For this kind of control you will probably need to move to base
>> graphics
>> and utilize the `fig` argument in par(), in whi
Hi Scott,
I have never done this myself but I read something recently on the
r-help distribution that was related.
I just did a quick search and found a few hits that might work for you.
1.
https://medium.com/@CharlesBordet/how-to-extract-and-clean-data-from-pdf-files-in-r-da11964e252e
2. http://
Hi Marsh,
An RDS is not a data structure such as a data.frame. It can be anything.
For example if I want to save my objects a, b, c I could do:
> saveRDS( list(a,b,c,), file="tmp.RDS")
Then read them back later with
> myList <- readRDS( "tmp.RDS" )
Do you have additional information about your "RD
; > Ulrik
> >
> > Marsh Hardy ARA/RISK schrieb am So., 28. Jan. 2018,
> 04:14:
> >
> >> Cool, looks like that'd do it, almost as if converting an entire record
> to
> >> a character string and comparing strings.
> >>
> >> ___
Capture the results of the apply command into an object and then work with
that. Here is one way to do it:
> res <- apply(C, 2, fitdist, "gamma")
> out <- c( res$A$estimate["shape"], res$B$estimate["shape"],
res$A$estimate["rate"], res$B$estimate["rate"])
> names(out) <- c("A shape","B shape","A r
Or a shorter version of Rui's approach:
set.seed(2511)# Make the results reproducible
fun <- function(n){
f <- function(){
c(mean(runif(5,1,10)),mean(runif(5,10,20)))
}
replicate(n, f())
}
fun(10)
On Tue, Jan 30, 2018 at 12:03 PM, Rui Barradas wrote:
> Hello,
>
> Another way would
Assuming your polyline is defined by two vectors, one for the x
coordinates, one for the y coordinates, you can try the following
library(NISTunits)
polyangles <- function(xV,yV) {
stopifnot( (length(xV)==length(yV)) && (length(xV) >= 3))
v <- function(i) { c( xV[i]-xV[i-1], yV[i]-yV[i-1])}
re = xV, im = yV)
> c(NA, diff(Arg(diff(z))), NA) # radians, positive is counter-clockwise
> }
> > x <- c(0:3)
> > y <- c(0,0,1,1)
> > polyAngles2(x,y) / pi * 180
> [1] NA 45 -45 NA
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
Hi Martin,
Why not just do the following?
In your editor after you create the script save it to a file, say "foo.R".
Then in your R session you give the command
> source("foo.R")
HTH,
Eric
On Sun, Feb 4, 2018 at 6:33 AM, Bert Gunter wrote:
> Obvious suggestion: use a more capable IDE instead o
Hi Max,
Here's an example that will generate that error. Maybe it will point you to
your problem.
# create a 2x2 matrix
> m <- matrix(1:4,nrow=2)
# refer to column 3 - which does not exist
> m[,3]
# Error in m[, 3] : subscript out of bounds
HTH,
Eric
On Wed, Feb 21, 2018 at 4:35 PM, Max Hen
Hi,
1. I think the reason that the different ordering leads to different
results is because of the following:
date[ some condition is true ][1]
will give you an NA if there are no rows where 'some condition holds'.
In the code that 'works' you don't have such a situation, but in the
cod
_1"][1]] <- "survey_2013"
>
>
>
> #filter trialData
>
> trialData <- trialData %>% filter(id == "id_786/3")
>
>
>
> *#attempt 2 works: code for survey*
>
> trialData$survey_year[trialData$date >= trialData$date[trialData$surve
Hi Allaisone,
I took a slightly different approach but you might find this either as or
more useful than your approach, or at least a start on the path to a
solution you need.
df1 <-
data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"),
strin
Good question Rolf.
Rui, thanks for pointing out dyn.unload.
When I started using Rcpp a couple of years ago I got burned by stale .so
enough times that I adopted a policy of recompile-then-start new R session.
My workflow does not include Rolf's "brazillion" repeats, so the overhead
of this approa
Hi Laura,
I will state up front that I have no experience or knowledge of the Cox
model or the survival package.
Out of curiosity I loaded the package and did ?coxph and found the
following comment in the documentation:
"The routine internally scales and centers data to avoid overflow in the
argum
What is 'd'? What is 'n'?
On Sun, Mar 4, 2018 at 12:14 PM, Christien Kerbert <
christienkerb...@gmail.com> wrote:
> Thanks for your reply.
>
> I use mvrnorm from the *MASS* package and lmrob from the *robustbase*
> package.
>
> To further explain my data generating process, the idea is as follow
Hard to help you if you don't provide a reproducible example.
On Sun, Mar 4, 2018 at 1:05 PM, Christien Kerbert <
christienkerb...@gmail.com> wrote:
> d is the number of observed variables (d = 3 in this example). n is the
> number of observations.
>
> 2018-03-04 11:3
Hi Christofer,
You cannot assign to list(...). You can do the following
myList <- list(...)[!names(list(...)) %in% 'mc.cores']
HTH,
Eric
On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:
> Hi,
>
> As an example, I want to create below kind of custom Functio
ic - with this approach I am getting below error :
>
> Error in FUN(X[[i]], ...) : unused argument (list())
>
> On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger
> wrote:
> > Hi Christofer,
> > You cannot assign to list(...). You can do the following
> >
> > myLi
#x27;mc.cores']
> }
> return(lapply(X, FUN, myList))
> }
> }
>
> Here, I am not passing ... anymore rather passing myList
>
> On Sun, Mar 4, 2018 at 10:37 PM, Eric Berger
> wrote:
> > Hi Christofer,
> > Before you made the change that I suggested, your program was
> Error message :
>
> Error in FUN(X[[i]], ...) : unused argument (list())
>
> Kindly note that, with Apply_MC = TRUE, it is working perfectly.
>
> On Sun, Mar 4, 2018 at 10:45 PM, Eric Berger
> wrote:
> > That's fine. The issue is how you called Lapply_me(). Wha
You need to load the package 'rasterVis'
> library(rasterVis)
HTH,
Eric
On Thu, Mar 8, 2018 at 5:11 PM, lily li wrote:
> Hi all,
>
> I ran the code:
> > s <- stack(replicate(2, raster(matrix(runif(100), 10
> > xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
> +
Bert's suggestion is good as a pointer to a variety of resources.
Sticking to the book format there are two of Hadley Wickham's books, which
have the advantage that they are freely available.
You can either read them online or download the source from github and
create your own copy (which you can
Hi Akshay,
Presumably PFC.NS and snl[[159]] are not exactly the same.
You can start by trying to determine if (and then how) they differ.
e.g.
> identical(PFC.NS, snl[[159]])
presumably this will result in FALSE
then compare
> class(PFC.NS)
> class(snl[[159]])
etc
HTH,
Eric
On Wed, Mar 14, 201
I have a littler script which is crashing with a segmentation fault.
I tried to find out why by running it through valgrind, which produced the
output below.
I am not sure how to proceed from here (other than binary search with print
statements).
Any help would be appreciated.
Thanks,
Eric
==1258
...how do I effect it? create a list
with some other element list... for example snl[[200]] == PFC.NS?
very many thanks for your time and effort...
yours sincerely,
AKSHAY M KULKARNI
------
*From:* Eric Berger
*Sent:* Wednesday, March 14, 2018 5:22 PM
*To:* akshay
uired, but the script does not run. Is there an additional
script required?
Best,
Albrecht
--
Albrecht Kauffmann
alkau...@fastmail.fm
Am Mi, 14. Mär 2018, um 09:13, schrieb Eric Berger:
> Bert's suggestion is good as a pointer to a variety of resources.
> Sticking to the book fo
Hi Cheyenne,
I noticed one thing that might be helpful to you.
First, I took a shortcut to the case of interest:
> m <- matrix(c(2,1,1,0,1,1,NA,1,1,NA,1,1,2,1,2,0,1,0),nrow=3)
> colnames(m) <- c("1.G","1.A","2.C","2.A","3.G","3.A")
> m
# 1.G 1.A 2.C 2.A 3.G 3.A
# [1,] 20 NA
I like Don's answer which is clean and clear. A frequently useful
alternative to lapply() is sapply().
Taking the sapply() route also avoids the need for do.call(). So a modified
version of Don's code would be:
## example data
output <- list(1:5, 1:7, 1:4)
maxlen <- max( sapply(output, length) )
You are missing a comma between "MARITAL" and "JOBSTATUS".
On Tue, Apr 10, 2018 at 10:27 AM, Saif Tauheed
wrote:
> I run this command for converting the numerical variable into factor.
> However, I get the following error message.
>
> > cols<- c(“GrMM", "RELG", "CASTE1", "SECTOR", "SECTOR4","AGE
Here's a hint:
> y <- which(x>100)
> identical(y,y)
# TRUE
> identical(y,-y)
# TRUE
The '-' is misleading - it is absorbed into the empty y, leaving the
request x[y] to be x for an empty set of indices.
HTH,
Eric
On Wed, Apr 18, 2018 at 2:13 PM, Ashim Kapoor wrote:
> Dear All,
>
> Here is a
Hi Neha,
How about this?
A <- as.matrix(A)
B <- as.matrix(B)
C <- A %*% t(B)
SA <- apply(A, MAR=1, sum )
SB <- apply(B, MAR=1, sum )
vapply( 1:nrow(B), function(j) { sum( C[,j]==SA & SA <= SB[j] ) > 0 }, 1 )
HTH,
Eric
On Sat, Apr 21, 2018 at 10:27 AM, Neha Aggarwal
wrote:
> Hi,
>
> I am
Hi Luca,
How about this?
# create some dummy data since I don't have your d0 or d1
> n <- 3
> d0 <- data.frame(a=runif(5),b=runif(5))
# here's the suggested code
> d1 <- cbind(d0, matrix(0,nrow(d0),n))
> colnames(d1)[1:n + ncol(d0)] <- paste("V",1:n,sep="")
HTH,
Eric
On Sun, Apr 22, 2018 at 1
Zoo_TS/lag(Zoo_TS) - 1
On Tue, Apr 24, 2018 at 9:29 PM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:
> Hi,
>
> I have a 'zoo' time series as below :
>
> Zoo_TS = zoo(5:1, as.Date(Sys.time())+0:4)
>
> Now I want to calculate First order difference of order 1, rolling
> window basis i.e
Hi Pol,
Here is one way:
fb <- function(mean=NULL, median=NULL, mode=NULL, a, b=0.95, lower=F) {
stopifnot ( (is.null(mean) + is.null(median) + is.null(mode)) == 2 )
etc...
}
HTH,
Eric
On Thu, Apr 26, 2018 at 4:46 PM, Polychronis Kostoulas <
polychronis.kostou...@gmail.com> wrote:
Hi Michael,
A few comments
1. To add the constraint sum(wgt.vect=1) you would use the method of
Lagrange multipliers.
What this means is that in addition to the w_i (the components of the
weight variables) you would add an additional variable, call it lambda.
Then you would modify your opti
typo: lambda * (sum(wgt.wect) - 1)
On Sun, May 6, 2018 at 10:51 AM, Eric Berger wrote:
> Hi Michael,
> A few comments
> 1. To add the constraint sum(wgt.vect=1) you would use the method of
> Lagrange multipliers.
> What this means is that in addition to the w_i (the co
Can you create a small script that reproduces the problem?
If you can, then please post it to the mailing list.
On Tue, May 8, 2018 at 4:24 PM, Bogdan Tanasa wrote:
> Dear all,
>
> would appreciate a suggestion about the following situation : I am running
> a script in R, and shall i execute it
abline (v=x_mmdd, lty=3, lwd=1.0, col="blue")
On Tue, May 8, 2018 at 5:23 PM, Gregory Coats wrote:
> Since the horizontal axis side=1 is year-month-day, how do I issue an
> abline command to draw dashed vertical lines, as a background grid, within
> the graph’s border? Similar to the ablin
Hi Rich,
Take a look at the function fromJSON found in the rjson package.
Note that the Usage in the help page: ?fromJSON
names the second argument 'file' but if you look at the description the
argument can be a URL.
HTH,
Eric
On Tue, May 8, 2018 at 6:16 PM, Evans, Richard K. (GRC-H000) <
richar
mean(unlist(lst))
On Tue, May 8, 2018 at 10:26 PM, varin sacha via R-help <
r-help@r-project.org> wrote:
>
> Dear R-experts,
>
> Here below the reproducible example. I am trying to get the average of the
> 100 results coming from the "lst" function. I have tried lst$mean and
> mean(lst). It doe
Hi Shakeel,
One approach would be to look at the dplyr package and its functions
group_by() and summarise(). These should be useful in preparing the data.
(Alternatively if you know SQL you might look at dbplyr.)
On the plotting side you can use plot(...) for the first line and then
lines(...) for
FYI I see everything after the '^' as a superscript.
The '~' does act as a space. (When I omit it there is less space between
the '-' and the '('.
On Mon, May 21, 2018 at 3:09 PM, Jinsong Zhao wrote:
> hi there,
>
> I find the following codes produce strange output.
>
> plot(1:10, xlab = expre
Hi Stephen,
I am not sure that the "for loop" is the source of slowness.
You seem to be doing a lot of unnecessary work each time through the loop.
e.g. no need to check if it's the last file, just move that section outside
of the loop.
It will be executed when the loop finishes. As it is you are c
1 - 100 of 553 matches
Mail list logo