This usually has to do with the caller (Matlab) and the callee (R) being
dynamically lined with different versions of dynamic libraries. On Linux
I work around this sort of thing by setting LD_LIBRARY_PATH to exactly
what I want when invoking R. E.g., instead of making the sh command
/usr/loca
If your string will always represent an R expression, you could work with
the expression directly with functions like all.names() and substitute().
f <- function (expr)
{
toReplace <- setdiff(all.names(expr), c("pmin", "pmax"))
toReplace <- grep(value = TRUE, "[a-z]", toReplace)
names(
plot(1,1,main=expression(-70*degree*C%+-%10*degree*C/Ambient))
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Feb 27, 2015 at 7:27 PM, li li wrote:
> Hi all,
> I would like to add "-70°C ± 10°C/Ambient" as the title of my plot.
> Could anyone give some help on this?
> Thanks.
>
n these expressions
> since they’re only created from other strings. Would I first have to
> transform these strings to unevaluated expressions?
>
>
>
> *Von:* William Dunlap [mailto:wdun...@tibco.com]
> *Gesendet**:* Freitag, 27. Februar 2015 23:39
> *An:* Alrik Thiem
>
()?
> When I do the following, it returns an error message.
>
>
> plot(1,1,main=expression(-70*degree*C%+-%10*degree*C/Ambient Condition))
>
>
>
>Hanna
>
>
> 2015-02-27 23:03 GMT-05:00 William Dunlap :
>
>> plot(1,1,main=expression(-70*degree*C%+-%10*degre
Use order(), as in
sortListByMean <- function(List) {
List[order(vapply(List, mean, 0))]
}
sortedL <- sortListByMean(l)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 3, 2015 at 11:01 AM, wrote:
> Hello R-helpers,
>
> I have a list of 999 dataframes and I would like to s
You will need to convert strings like "2/15/15" into one of the time/date
classes available in R and then it is easy to do comparisons. E.g., if you
have no interest in the time of day you can use the Date class:
> d <- as.Date(c("12/2/79", "4/15/15"), format="%m/%d/%y")
> today <- as.Date("2015-
That blog post refers to the authors own function, as.data.frame.list,
that you would have to download from github. It makes data.frame()
act quite differently than the usual way. I would not recommend it.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Mar 5, 2015 at 1:53 AM, harini_v
wr
You could change the x component of density's output back into a Date object
and let plot choose a Date axis in its usual way. E.g.,
> den <- density(as.numeric(dd))
> den$x <- as.Date(den$x, origin=as.Date("1970-01-01"))
> plot(den$x, den$y)
(You probably will also want to normalize the y c
The key to your problem may be that
x<-apply(missing,1,genRows)
converts 'missing' to a matrix, with the same type for all columns
then makes x either a list or a matrix but never a data.frame.
Those features of apply may mess up the rest of your calculations.
Don't use apply().
Bill Dunlap
T
> %/% which, BTW,
> violated the sacred rule that for all a, and non-zero b:
>
> a = b * (a %/% b) + a %% b
>
> Namely, that Inf %/% n is not Inf, but NaN.
But the other sacred rule is that a%%b is >=0 and (1 + 2^53) %% 2 # 1 if you had infinite precision
[1] 0
> (2 + 2^53) %% 2
[1] 0
War
In base R you can do what I think you want with aggregate() and Filter().
E.g.,
> a <- aggregate(df["Day"], df["ID"], function(x)x)
> str(a)
'data.frame': 3 obs. of 2 variables:
$ ID : num 1 2 3
$ Day:List of 3
..$ 1: num 1 2 4 7
..$ 5: num 2 3
..$ 7: num 1 3 4 8
>
Poke around the help files (& perhaps source code) for package:httr to see
how to set
options("httr_oauth_cache"). E.g.,
help(package="httr", "Token-class")
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Mar 12, 2015 at 8:25 AM, Doran, Harold wrote:
> I’m dealing with an issue that
t 1:06 PM, Jocelyn Ireson-Paine
wrote:
> David, and also William Dunlap, thanks for taking the time to reply, with
> examples. Both your answers are very helpful.
>
> William noted that 'reshape2' is not 'R', but a user-contributed package
> that runs in R. I agree
Increasing the value of 'n' given to density will give an estimate at more
points so it will look smoother. Try n=2^18.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 17, 2015 at 12:06 PM, Fix Ace wrote:
>
>
> I have a dataset with 6187 elements, ranged from 3 to 104028. When I
> tr
lap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 17, 2015 at 7:02 PM, Fix Ace wrote:
> Thank you for the email.
>
> What is the default "n"?
>
> Thanks!
>
>
>
> On Tuesday, March 17, 2015 4:06 PM, William Dunlap
> wrote:
>
>
> Increasing the va
You can use the reorder() function to reorder the grouping vector's
factor levels according to a function of the data in each group. E.g.,
compare the following two plots:
d <- data.frame(Response=cos(1:15), Group=rep(c("A","B","C"),c(6,5,4)))
par(mfrow=c(1,2))
boxplot(Response ~ Group,
> # Import CSV file into a data frame.
> case_weights <- read.csv(file = "case_weights.csv")
>
> # For each row, take the number in the Weight column and replicate it
> # as many times as there are in each count column.
> LC09 <- rep(case_weights$Weight, case_weights$LC09)
> LC10 <- rep(case_weight
sim.app.wald<-function(B=0.1,min=10,max=50,alpha=0.05){
result<-c(fails=0,n=0)
for(n in min:max){
x<-seq(1,n-1,1)
...
return(result) # indent! see what's wrong?
}
}
Make your indentation (of the return line) correspond to the braces
Add the argument mode="wb" to your call to download.file(). On Windows
this means to use 'binary' format - do not change line endings.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Mar 27, 2015 at 7:25 AM, Giles Crane wrote:
>
> # download.file() Seems to put the xlsx file onto hard dri
Try using the plural 'keys' instead of 'key' (as help(hash) says):
yourhash <- hash(keys=letters, values=1:26)
Then there will be 26 items in the hash table and keys(yourhash)
will return the 26 lowercase letters. Is that what you want?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Mar
at, Mar 28, 2015 at 4:45 PM, Brian Smith wrote:
> Hi William,
>
> That's the point - the 'keys()' doesn't seem to work..
>
>
> On Sat, Mar 28, 2015 at 7:36 PM, William Dunlap wrote:
>
>> Try using the plural 'keys' instead of 'key'
> I can't understand how the body of the function, x[c1]/x[c2] refers to
the columns "data" and "SE" of the matrix data.
If you put the line 'str(x)' at the start of myfun(), as in
myfun <- function(x, c1, c2) {
str(x)
x[c1]/x[c2]
}
you would start to see why it works - extractin
If you really want your coefficient estimates to be scale-equivariant you
should test those methods for such a thing. E.g., here are functions that
let you check how scaling one predictor affects the estimated coefficients
- they should give the same results for any scale factor.
f <-
function (s
You can use structure() to attach the names to a list that is input to
data.frame.
E.g.,
dfNames <- c("First", "Second Name")
data.frame(lapply(structure(dfNames, names=dfNames),
function(name)rep(NA_real_, 5)))
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 31, 2015 at 11:37 AM, Sara
> MannKendalltau<- numeric(nc) simply makes MannKendalltau a single
> integer equal to nc; that doesn't look sensible when the next thing you
> do is treat MannKendalltau as a vector.
No, numeric(nc) makes a "numeric" (double precision) vector of length nc
filled with zeros.
Perhaps you were thin
nd.Name".
It is often preferable, but it is different.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Apr 3, 2015 at 5:51 AM, peter dalgaard wrote:
>
> > On 31 Mar 2015, at 20:55 , William Dunlap wrote:
> >
> > You can use structure() to attach the names to a
split() might help, but you should give a more complete
explanation of your problem.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Apr 6, 2015 at 1:56 PM, Keshav Dhandhania
wrote:
> Hi,
>
> I know that one can find all occurrences of x in a vector v by doing
> > which(x == v).
>
> Howeve
> plot(vols,plot.type="s",format="auto")
> lines(vols[,2],col="red")
Did you get any warning messages when you did that? I get
> library(xts)
> z <- xts(cbind(One=sin(1:20), Two=cos(1:20)+1.5), order.by
=as.Date("2015-04-06")+(0:19))
> plot(z)
Warning message:
In plot.xts(z) : only the
> > args <- commandArgs(TRUE)
> > num <- args[1]
and then you get a complaint about something not being numeric.
commandArgs() returns a character vector so try
num <- as.numeric(args[1])
and you may as well preface it with
stopifnot(length(args)>0)
Bill Dunlap
TIBCO Software
wdunlap tibco
You can make such functions by using the fact that a function
(really, a 'closure') always has access to the environment in
which the function was created. E.g.
makeConstantFunction <- function(constant) {
force(constant) # evaluate the argument now
function(PAI) {
constant
It is a printing problem - the default number of digits in print.summary.aov
is max(3L, getOption("digits") - 3L). Set options(digits=7) instead of
your current 6 (?) or try print(summary(fit.Y), digits=7) to see more
digits.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 14, 2015 at
Try Googling for
".list" file extension
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 14, 2015 at 1:40 PM, Dimitri Liakhovitski <
dimitri.liakhovit...@gmail.com> wrote:
> Is it possible to read a LIST file into R? Any package?
>
> I've done some googling, but there are just too man
> strsplit(x=sub(pattern="^\\* ", replacement="", x=test), split=" ")
[[1]]
[1] "a" "b" "d"
[[2]]
[1] "z" "u" "i" "h" "hh"
[[3]]
[1] "h" "bh" "kk"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 14, 2015 at 2:34 PM, Hermann Norpois wrote:
> Hello,
>
> I try to open a text file
You also might try wrapping the call to the scripts with capture.output().
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Jul 24, 2014 at 9:54 AM, Nick Matzke wrote:
> Actually, this was the full solution:
>
> At the beginning of the script:
>
> # Suppressing all output/warnings/try errors
> if
> yourData[,8]==0,
> then
> yourData[,8]==1, yourData[,10] <- yourData[,9]/yourData[,8]
You could do express this in R as
is8Zero <- yourData[,8] == 0
yourData[is8Zero, 8] <- 1
yourData[is8Zero, 10] <- yourData[is8Zero,9] / yourData[is8Zero,8]
Note how logical (Boolean) values are us
I find bquote() handy for this sort of manipulation. E.g.,
> f <- function() { 1 }
> origBody <- body(f)
> newBody <- bquote({ .(origBody) ; .(addedStuff) }, list(origBody=origBody,
> addedStuff=quote(function(){})))
> body(f) <- newBody
> f
function ()
{
{
1
}
function() {
This is a real hack, but you can redefine return in your function:
> f <- function() {
+ return("early return")
+ "last value in function"
+ }
> f()
[1] "early return"
> f <- function() {
+ return <- function(x)x
+ return("early return")
+ "last value in function"
+ }
> f()
[1]
The problem with Don's
if (condition) {
Results <- something
} else {
Results <- somethingElse
}
is that in a long sequence of if-then-else-if... you have
to check every branch to make sure Results got assigned to
(or that the remaining branches contained a return() or a stop()).
R is a functional language so you might want to google for 'dependency
injection functional language' and see why dependency injection is not
a hot concept in R.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Jul 29, 2014 at 9:02 AM, Reed Spool wrote:
> Greetings,
>
> New to R, coming fro
> I should have mentioned that I tried other time stamps, generated the
> same way as "q" above.
How did you generate q and in what time zone were you? Note that 2am
on 9 March 2014 is when 'daylight savings time' started in the parts
of the US where it is observed. Does 2am exist or do we jump
I meant what R commands did you use to change the database's version
of the time/date object to the R version?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Jul 30, 2014 at 11:07 AM, John McKown
wrote:
> On Wed, Jul 30, 2014 at 12:54 PM, William Dunlap wrote:
>>> I shou
Even better is to replace
for(i in 1:length(something)) {}
with
for(i in seq_along(something)) {}
The former gives you 2 iterations, the 2nd probably causing an error,
when length(something) is 0. The latter always gives one iteration
per element of 'something'.
Bill Dunlap
TIBCO Softwar
Do you know how to extract some rows of a data.frame? A short answer
is with subscripts, either integer,
first10 <- 1:10
dFirst10 <- d[first10, ] # I assume your data.frame is called 'd'
or logical
plus4 <- d[, "Col_4"] == "+"
dPlus4 <- d[ plus4, ]
If you are not familiar with that sor
One way to accomplish this is to assign a new environment to the
formula, an environment which inherits from the formula's original
environment but one that you can add things to without affecting the
original environment. Also, since you do this in a function only the
copy of the formula in the f
Have you tried using the merge() function? E.g.,
lapply(split(d, d$NAME), function(di)merge(all=TRUE, di,
data.frame(YEAR=seq(min(di$YEAR), max(di$YEAR), by=1
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Aug 1, 2014 at 8:22 PM, Florian Denzinger
wrote:
> Thank you everyone for your
Look at withCallngHandlers for another way to capture warnings. It
will let you attach warnings from an iteration of your function to the
output of the function so you can later track down the root cause of
the warning.
E.g., the attached captureWarningsAndMessagesWithContext attaches
warnings, m
You can those vectors into character strings and pass them to table(). E.g.,
> d <- list(`30008`=c(1,0,1,0), `60008`=c(0,0,1,0), `90008`=c(0,0,1,0),
> `17`=1, `130001`=c(0,1), `130007`=c(1,0,1,0))
> dChar <- vapply(d, FUN=function(di)paste(di, collapse=" "), FUN.VALUE="")
> dTable <- table(d
Using vapply instead of sapply or unlist(lapply) here gives you a
little more safety. vapply insists that you supply a FUN.VALUE
argument that gives a prototype (type and length) of the expected
output of FUN. It will stop if FUN returns something unexpected.
Compare the following where I misspel
> a<-c(1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1)
> which( a==1 & c(TRUE, a[-length(a)]!=1) )
[1] 1 6 16 23
> which( a==0 & c(TRUE, a[-length(a)]!=0) )
[1] 4 12 18
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Aug 6, 2014 at 7:12 PM, Johnnycz wrote:
> Hello,eve
!= x[-length(x)], TRUE)
}
}
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Aug 7, 2014 at 7:36 AM, William Dunlap wrote:
>> a<-c(1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1)
>> which( a==1 & c(TRUE, a[-length(a)]!=1) )
> [1] 1 6 16 23
&g
I prefer the idiom
c(TRUE, a[-1] != a[-length(x)])
because it works for character and other data types as well.
I also find that thinking in terms of runs instead of subscripting
tricks is easier.
__
R-help@r-project.org mailing list
https://stat.ethz
> for(i in ls(pattern="P_")){ head(get(i), 2)} # Should work.
You also need to use print(head(...)) if you want to see the printed
output from each iteration.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Aug 8, 2014 at 4:36 PM, David Winsemius wrote:
>
> On Aug 8, 2014, at 11:25 AM,
> I was able to create 102 distinct dataframes (DFs1, DFs2, DFs3, etc) using
> the assign() in a loop.
The first step to making things easier to do is to put those data.frames
into a list. I'll call it DFS and your data.frames will now be DFs[[1]],
DFs[[2]], ..., DFs[[length(DFs)]].
DFs <- la
DF",i))[1,]
>>> assign(paste0("df",i),tmp)
>>> dfi=dfi[,1:3]
>>> names(dfi)=names(tmp[c(1,4,5)])
>>> dfi=rbind(dfi,tmp[c(1,4,5)])
>>> names(dfi)=c("UID","Date","Location")
>>>}
>
> NB: The code ab
You can use
m[m > 0 & m <= 1.0] <- 1
m[m > 1 ] <- 2
or, if you have lots of intervals, something based on findInterval(). E.g.,
m[] <- findInterval(m, c(-Inf, 0, 1, Inf)) - 1
(What do you want to do with non-positive numbers?)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Au
> What if I just want the seconds vector without the date, please? Is there
> a convenient way to create such a vector, please?
Why do you want such a thing? E.g., do you want it to print the time
of day without the date? Or are you trying to avoid numeric problems
when you do regressions with
s, I
> just care about what time.
>
> Thank you!
>
>
>
>
> On Tue, Aug 12, 2014 at 3:14 PM, William Dunlap wrote:
>>
>> > What if I just want the seconds vector without the date, please? Is
>> > there
>> > a convenient way to create such a vecto
> Again, in my opinion, all time date should be recorded in GMT.
It depends on context. If you are studying traffic flow or
electricity usage, then you want local time with all its warts
(perhaps stated as time since 3am so any daylight savings time
problems are confined to a small portion of th
Use [[ instead of $. E.g.,
f <- function(columnName) {
d <- data.frame(x=1, y=2, z=3)
d[[columnName]]
}
f("z") # 3
cName <- "y"
f(cName) # 2
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Aug 13, 2014 at 4:33 AM, madhvi.gupta wrote:
> Hi,
> Can anyone please tell me how to use
You can replace the loop
> for (i in nrow(x1)) {
>x[x1$V1[i], x1$V2[i]] <- 1;
> }
by
f <- function(x, x1) {
i <- as.matrix(x1[, c("V1","V2")]) # 2-column matrix to use as a subscript
x[ i ] <- 1
x
}
f(x, x1)
You will get an error if not all the strings in the subscript matrix
are in the
CA10", "ABCA12", "ABCA13", "ABCA4"
> ), c("ABCA10", "ABCA12", "ABCA13", "ABCA4")))
>
>
> x1 <- structure(list(V1 = c("AKT3", "AKTIP", "AKTIP", "AKTIP", "AKTIP",
>
r presence and FALSE for
absence, use X>0. If you want 1 for presence and 0 for absence you
can use pmin(X, 1).
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Aug 13, 2014 at 2:51 PM, William Dunlap wrote:
> I may have missed something, but I didn't see the result you want for
>
Previously you asked
> A second question: is this the best way to make a list
>of data frames without having to manually type c(dataframe1, dataframe2,
> ...) ?
If you use 'c' there you will not get a list of data.frames - you will
get a list of all the columns in the data.frame you supp
s with A, since M is not present in X - we will
> not map this association with 1. Since A and D are present in X - we
> will assign 1.
>
>
>
>A B C D
>
> A 0 0 0 0
>
> B 0 0 0 0
>
> C 0 0 0 0
>
> D 1 0 0 0
>
>
> I tried this simple for
Is there a function in core R that takes 2 strings and returns TRUE if
they refer to the same file? (If either does not refer to a file, I
think it would be fine if it returned FALSE.)
Compariing inode/device numbers on Unix-like systems and the output of
normalizePath on Windows would probably d
gsub will work on a column of a data.frame, not an entire data.frame.
> gsub(pattern = "facebook-Ads1", "FBAds", DataGoogle1$Campaña)
[1] "FBAds" "faceBOOK-Ads1" "fcebook-ads12" "Email1"
"mail1"
[6] "referral1"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 18, 2014 at 2:13 AM,
Have you tried the 'envir' argument to load()? E.g.,
envA <- new.environment()
load("A.RData", envir=envA)
envB <- new.environment()
load("B.RData", envir=envB)
plot(A$object, B$object)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 18, 2014 at 5:30 PM, Jinsong Zhao wr
Rolf,
Yes, I meant to write envA$object, etc, but did not read it twice
before running off to dinner. Thanks.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 18, 2014 at 7:52 PM, Rolf Turner wrote:
> On 19/08/14 14:20, William Dunlap wrote:
>>
>> Have you tried the &
> This function unfortunately does not work in 3d space.
[I think 'this' is refering to the 'dist' function.]
Can you show how it is not working for you? I.e., what does it
produce compared to what you want for a given input?
dist() does work on a 3-column (or n-column) matrix or data.frame,
wh
Add zero.line=FALSE to the call to plot() to get rid of the gray line.
help(plot.density) should say something about it.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 25, 2014 at 5:00 AM, Dario Strbenac
wrote:
> Why is the bottom boundary plotted in a different colour to the other thr
You could use local() to associate a state variable with your function:
myFunc <- local({
notWarnedYet <- TRUE
function(x) {
if (notWarnedYet) {
warning("myFunc is funky")
notWarnedYet <<- FALSE # note use of <<-
}
sqrt
t; }
> }
> Grant Rettke | ACM, ASA, FSF, IEEE, SIAM
> g...@wisdomandwonder.com | http://www.wisdomandwonder.com/
> “Wisdom begins in wonder.” --Socrates
> ((λ (x) (x x)) (λ (x) (x x)))
> “Life has become immeasurably better since I have been forced to stop
> taking it seriousl
as.environment(characterString) maps an entry from the output of
search() to the environment at the named position in the search list.
as.environment(number) maps an index into the output of search() to
the the environment at that position in the search list. If
'characterString' is not in the out
Delete all characters up to and including the last hyphen with
sub(".*-", "", test)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Aug 28, 2014 at 10:41 AM, Jun Shen wrote:
> Hi everyone,
>
> I believe I am not the first one to have this problem but couldn't find a
> relevant thread o
I think you can get yourself going by calling
Peaks:::.First.lib(dirname(find.package("Peaks")), "Peaks")
to get Peaks' DLL loaded. .First.lib is not getting called.
You should ask the package's maintainer, maintainer("Peaks"), to fix
up the statup procedures. It the help files had examples o
The built-in table method for plot() makes a decent looking plot as
well. Look at
plot(table(art), ylab="Count")
plot(table(factor(art, levels=0:19)), ylab="Count")
plot(table(LETTERS[art+1]), ylab="Count")
plot(table(factor(LETTERS[art+1], levels=LETTERS[1:20])), ylab="Count")
Bill Dunlap
You can easily run into precedence problems with the %fun% syntax. E.g., if
1 %<% 5 %<% 10
returns TRUE then
1 %<% 5 %<% 10*2
will return 2 because %<% has higher precedence than *.
> as.list(quote(1 %<% 5 %<% 10*2))
[[1]]
`*`
[[2]]
1 %<% 5 %<% 10
[[3]]
[1]
You could try using the non-formula interface to aggregate.
Note that the following two calls to aggregate are equivalent but
the second (using the non-formula interface) makes the response column
a variable:
> df <- data.frame(Y1=1:10, Y2=101:110, Group=rep(letters[1:3], c(3,3,4)))
> aggrega
> testdataextract1<-switch(menu(c(unique(levels(testdata[,1]))),graphics=FALSE,title='Select
> something'))
The switch function does not work the way you are expecting it to.
Read help("switch") and read the introduction to R that comes with R.
You probably want to use the output of menu() to ex
In your first example I get an error:
> mtest.data.frame(testdata, valid2=="N", valid3 > 1)
Error in mtest.data.frame(testdata, valid2 == "N", valid3 > 1) :
object 'valid2' not found
I expect the error because list(...) ought to evaluate the ... arguments.
Use substitute() to get the uneva
Again, feed the output of menu() directly into "[". Do not use switch().
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Sep 8, 2014 at 2:12 AM, wrote:
> On Sat, 6 Sep 2014 08:21:19 -0700
> William Dunlap wrote:
>
>> >
>> > testdataextract1<
R pdf
that comes with R. It is worth reading.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Sep 8, 2014 at 8:13 AM, wrote:
> On Mon, 8 Sep 2014 07:55:23 -0700
> William Dunlap wrote:
>
>> Again, feed the output of menu() directly into "[". Do not use
>>
Complain to the RStudio people - RStudio defines its own
options("editor") which is not completely compatible with R's
option(editor="internal"). If you set options(editor="internal") in
RStudio then you can look at the code in the vignette. (I tried with
last year's RStudio 0.98.501 and this may
et the editor argument , i don't know how to report a
> bug to Rstudio, may you do that ?
>
>
>
> --
>
> PO SU
> mail: desolato...@163.com
> Majored in Statistics from SJTU
>
>
>
>
> At 2014-09-09 00:41:33, "William Dunlap" wrote:
>>
Another nice thing about using ~formula is that it stores the
environment in which the formula was made along with the formula.
Thus you know which envrionment should be used with evaluating it (and
don't have to guess that parent.frame() may be the right environmnet).
E.g.,
evalRHS <- function
Can you make your example a bit more concrete? E.g., is your 'index
vector' A an integer vector? If so, integer(0), an integer vector
with no elements, would be a more reasonable return value than NULL,
an object of class NULL with length 0, for the 'not found' case and
you could check for that c
'q' should be an expression object, not a list of expression objects.
Try defining 'q' as
q <- as.expression(lapply(lambdas, function(l)bquote(lambda==.(l
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Sep 13, 2014 at 5:55 PM, Julio Sergio Santana
wrote:
> I need to add a legend w
> Why are the first two yielding an integer after multiplying, and the last two
> don't?
> Apparently, c(0.8,0.6,0.4,0.2) can't be represented exactly.
Most fractions cannot be represented exactly. Also, you cannot depend
on the third element of seq(.2,.8,by=.2) being equal to .6 (it is
slightly
> [*] I recall a student fitting a GLM with about 30 predictors to 1.5m
> records: at the time (ca R 2.14) it did not fit in 4GB but did in 8GB.
You can easily run out of memory when a few of the variables are
factors, each with many levels, and the user looks for interactions
between them. This
You can work around this issue by matching the types of the the 'x'
and 'levels' arguments to factor():
> factor(30, as.numeric(29:31)) # both are floating
point ('numeric')
[1] 3e+05
Levels: 29 3e+05 31
> factor(as.integer(30), 29:31) # both are integer
[1
If you really want to continue to use the function in the supported
package, then you could try asking the maintainer of the package to
make the problematic URL an argument to the function. I thnk that
changing the function on the fly, no matter how you do it, is likely
to cause problems when the
> testLines <- mapproject(yValue, xValue, proj="lambert", param=c(50,65))
For starters, if you give the x,y values in reverse order of what the
mapproject function expects you need to label them: y=yValue,
x=xValue.
(Also, I would have expected longitudes in the Americas to be
negative, but mappr
ly reset the projection it messes things up.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Sep 23, 2014 at 9:36 AM, William Dunlap wrote:
>> testLines <- mapproject(yValue, xValue, proj="lambert", param=c(50,65))
>
> For starters, if you give the x,y values in re
Running pkg::func or pkg:::func has the side effect of loading pkg's
namespace, if it is not already loaded. Use remove.packages() to
remove the package from your machine if you want to make its namespace
unloadable.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Sep 24, 2014 at 11:56 AM,
Try
hist(oded$Breed)
(I suspect that summary(Breed) does not work in your current session either -
perhaps you had a dataset named just Breed or had attached the data.frame
oded in the session where summary(Breed) works.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Sep 26, 2014 at 10
ifelse() often has problems constructing the right type of return value.
if you want to keep the data as a factor (with its existing levels)
use x[condition] <- value instead of ifelse(condition, value, x). E.g.,
> x <- factor(c("Large","Small","Small","XLarge"),
levels=c("Small","Med","Large"
Omit the sink() statements to see what is happening -
lapply(myList,print) prints
each item in the list and then the output of lapply is printed via the
autoprinting mechanism.
If you put this into a function or saved the return value of lapply
into a variable or wrapped
the call to lapply in a cal
ventory[[i]],file=sprintf("test_new%d",i)) }
>> lapply(1:10,func)
>
> But here of course I get 10 different text files (one per list element) when
> what I would like is to have them all in one file...
>
> Ingrid
>
>
>
> -Original Message-
> Fro
Change your 'max=T' to 'maximum=TRUE'. A long time ago the '...' in
optimize's argument
list was at the end, so you could abbreviate any of its argument
names. Now the '...' is the
third formal argument, so all the trailing arguments meant for
optimize itself must be fully
spelled out. Otherwise
101 - 200 of 2211 matches
Mail list logo