[R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
Dear R list, I came across dgCMatrix. I believe this class is associated with sparse matrix. I see there are 8 attributes to train$data, I am confused why are there so many, some are vectors, what do they do? Here's the R code: library(xgboost) data(agaricus.train, package='xgboost') data(agari

Re: [R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
though it *looks* like the opposite. Cheers! On Fri, Oct 20, 2017 at 3:22 PM, David Winsemius wrote: > > > On Oct 20, 2017, at 11:11 AM, C W wrote: > > > > Dear R list, > > > > I came across dgCMatrix. I believe this class is associated with sparse > >

Re: [R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
. [2,] . . [3,] . . [4,] . . [5,] . . On Fri, Oct 20, 2017 at 3:51 PM, C W wrote: > Thank you for your responses. > > I guess I don't feel alone. I don't find the docume

[R] How create columns for squared values from previous columns?

2017-04-28 Thread C W
Dear R list, I am am a little unsure what is the best way to approach this. I suppose I have > dat <- matrix(rnorm(30), ncol = 5) > dat <- data.frame(dat) > dat X1 X2 X3 X4 X5 1 -1.1317 -0.87868106 -0.33000492 1.5241765 -0.92483388 2 -0.56168006

Re: [R] How create columns for squared values from previous columns?

2017-04-28 Thread C W
275 0.2213842 6 0.90691210 0.7247171 0.8244184 0.73328097 -1.05284737 0.822489552 0.52521494 0.6796657 But, you would NOT ONLY get undesired variable names, BUT ALSO duplicated names. I suppose I can use paste() to solve that? Any better ideas? On Fri, Apr 28, 2017 at 8:57 PM, C W wrote: >

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
uffle the names in the same way: > > names(dat)[3:5] <- names(dat)[c(5,3,4)] > > Better(?): > > perm <- c(1,2,5,3,4) > dat <- dat[perm] > > dat is a list. > > Göran > > >> From: Rolf Turner >> Sent: Frida

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
the same way: > > > > names(dat)[3:5] <- names(dat)[c(5,3,4)] > > > > Better(?): > > > > perm <- c(1,2,5,3,4) > > dat <- dat[perm] > > > > dat is a list. > > > > Göran > > > > > >> > >> ___

[R] What are some toy models I can use in R?

2016-05-25 Thread C W
Hi everyone, I am searching for some toy models in R. My goal is do to model checking. For example, My data come from statistical model N(5, 2), with n=100, call this model_1 Then, I add bias to that data with N(3, 1), with n=100, call this model_2 Ultimately, I want to see model_1+ model_2 gi

Re: [R] What are some toy models I can use in R?

2016-05-25 Thread C W
On Wed, May 25, 2016 at 1:13 PM, S Ellison wrote: > > -Original Message- > > My data come from statistical model N(5, 2), with n=100, call this > model_1 > > Then, I add bias to that data with N(3, 1), with n=100, call this model_2 > Do you mean you have data from N(5,2) that has had data

[R] trouble installing RcppOctave

2015-05-08 Thread C W
Dear R list, I am trying install the RcppOctave package to run Matlab packages in R. I did the following, > install.packages("RcppOctave") After some time of installation, I get the following error. I have homebrew installed, I also have Octave and Matlab install. installing the source packag

[R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-28 Thread C W
Dear R list, I am trying to do use the R.matlab library, I did the following, but it does not work. > library(R.matlab) Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘R.methodsS3’ Error: package or namespace load failed for ‘R

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
h the other > dependencies (R.oo and R.utils), do the same. > > /Henrik > > > > On Thu, May 28, 2015 at 11:47 AM, C W wrote: > > Dear R list, > > > > I am trying to do use the R.matlab library, I did the following, but it > > does not work. > &g

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
n Bolker wrote: > C W gmail.com> writes: > > > > > Hi Henrik, > > > > I don't quite get what I should do here. I am not familiar with > > R.methodS3. Can you tell me what command exactly do I need to do? > > > > Thanks, > > > >

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
viewdoc/download?doi=10.1.1.208.9970&rep=rep1&type=pdf > > > On 15-05-29 05:11 PM, C W wrote: > > Wow, thanks Ben. That worked very well. > > > > I guess I didn't have R.methodS3? But that doesn't make sense, > > because I was using R.matlab

[R] sampling rows with values never sampled before

2015-06-22 Thread C W
Hello R list, I am have question about sampling unique coordinate values. Here's how my data looks like > dat <- cbind(x1 = rep(1:5, 3), x2 = rep(c(3.7, 2.9, 5.2), each=5)) > dat x1 x2 [1,] 1 3.7 [2,] 2 3.7 [3,] 3 3.7 [4,] 4 3.7 [5,] 5 3.7 [6,] 1 2.9 [7,] 2 2.9 [8,] 3 2.9

Re: [R] sampling rows with values never sampled before

2015-06-22 Thread C W
on, Jun 22, 2015 at 2:19 PM, Daniel Nordlund wrote: > On 6/22/2015 9:42 AM, C W wrote: > >> Hello R list, >> >> I am have question about sampling unique coordinate values. >> >> Here's how my data looks like >> >> dat <- cbind(x1 = rep(1:5

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
I use R on Mac, and I use RStudio on Windows. That's my opinion. I have one problem. When I use R on Mac. The function plot() gives a graph that's cut off. For example, try plot(rnorm(100) I believe there should be space below "index" on x-axis. Why is that? Thanks, Mike On Mon, Jan 12, 2

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
m of the screen > > On Mon, Jan 12, 2015 at 4:31 PM, Duncan Murdoch > wrote: > > On 12/01/2015 12:00 PM, C W wrote: > >> I use R on Mac, and I use RStudio on Windows. That's my opinion. > >> > >> I have one problem. > >> > >> When

[R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi all, I want to graph a curve as a function of mu, not x. Here's the R code: x <- rnorm(10) y <- rnorm(10) func <- function(x, y, mu){ x + y + mu ^ 2 } curve(f = func(x = x, y = y, mu), from = 0, to = 10) I know I can change variable mu to x, but is there a way to tell R that mu is the va

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
rk, but I don't know if it's what you want. func2 > will get x and y from the global environment. > > func2 <- function(mu){ >x + y + mu ^ 2 > } > > curve(func2, from = 0, to = 10) > > > Hope this helps, > > Rui Barradas > > Em 29-01-2015 21

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
ent variable > and func(rnorm(10), rnorm(10), mu=seq(0,5,len=501)) won't > work right. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Thu, Jan 29, 2015 at 5:43 PM, C W wrote: > >> Hi Rui, >> >> Thank you for your help. Th

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread C W
And I want zero everywhere else. Thanks, Mike On Thu, Jan 29, 2015 at 10:34 PM, C W wrote: > Hi Bill, > > You solved by problem. For some reason, I thought xname was only > referring to name of the x-axis. > > I remember last time I fixed it, it was something about xname, co

[R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-17 Thread C W
Hi list, I am running the following R code, the answer should be zero. But R gives a very small negative number, what should I do? ##R code library(numDeriv) h_x <- function(x){ a = x[1] b = x[2] c = x[3] d = x[4] (a^2 + c^2 + d^2) * (b^2 + c^2 + d^2) } x1 = 10 x2 = 1 x3 = 0 x4

Re: [R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-18 Thread C W
Hi Ben and JS, Thanks for the reply. I tried using: hessian(func = h_x, x, method = "complex"), it gives zero, that's good. # R code > hess.h <- hessian(func = h_x, x, method = "complex") > mat <- h_x(x)*hess.h - grad(h_x, x) %o% grad(h_x, x) > mat [,1][,2] [,3][,4] [1,]

Re: [R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-18 Thread C W
e answer can be extracted from a given body of data. > ~ John Tukey > > 2015-02-18 17:44 GMT+01:00 C W : > >> Hi Ben and JS, >> >> Thanks for the reply. >> >> I tried using: hessian(func = h_x, x, method = "complex"), it gives zero, >> that'

[R] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
Hi R list, I am using the GPfit package to fit Gaussian Process model. The kernel in the package is, K(x, x') = sigma^2 * exp(x-x')^2 My kernel have an extra term, K((x, z), (x', z')) = sigma^2 * exp(x-x')^2 * exp(z-z')^2 The function corr_matrix() is, corr_matrix(X, beta, corr=list(type="expon

Re: [R] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
.00154643121052443, 0.0248938938021518, 0.187306626057348, 0.64822387977866, 1), .Dim = c(5L, 5L)) Now if I do, > GP_fit(xx, yy, corr=cor.mat) Error in corr$type : $ operator is invalid for atomic vectors How could I fix it? Thanks! -M On Mon, Mar 9, 2015 at 2:14 PM, C W wrote: > Hi R list,

[R] Is RcppOctave package available for Mac to install?

2015-03-13 Thread C W
Hi everyone, When I tried to install RcppOctave package I got the following. > install.packages("RcppOctave") --- Please select a CRAN mirror for use in this session --- package ‘RcppOctave’ is available as a source package but not as a binary Warning message: package ‘RcppOctave’ is not avai

Re: [R] Is RcppOctave package available for Mac to install?

2015-03-14 Thread C W
Hi David, Thanks for the detail information. I think I will probably work in Octave instead, and fix the problem when I have a little more time. Mike On Sat, Mar 14, 2015 at 2:13 AM, David Winsemius wrote: > > > On Mar 13, 2015, at 11:50 PM, C W wrote: > > > > Hi eve

[R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-02 Thread C W
Dear R community, I am working with dates. And I get the following error: > strftime(dat[20], format="%H:%M") Error in as.POSIXlt.character(as.character(x), ...) : character string is not in a standard unambiguous format Here's the original data: dat <- structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
this can be as simple as > > Sys.setenv(TZ="GMT") > > but it can be specific to your data set also. > > On February 2, 2019 7:09:46 AM PST, Duncan Murdoch < > murdoch.dun...@gmail.com> wrote: > >On 01/02/2019 10:45 p.m., C W wrote: > >> Dea

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
uot;2015-07-13" [36] "2015-07-13" "2015-07-13" "2015-07-13" "2015-07-13" "2015-07-13" > class(as.Date(dat, "%m/%d/%y")) [1] "Date" > class(strftime(strptime(dat, format="%m/%d/%y %H:%M"), format = "%

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
h Date and POSIXt types > in the same analysis... I recommend sticking with one or the other. > > The trunc.POSIXt function is more appropriate for getting POSIXt dates > than converting to character and back. > > On February 2, 2019 9:03:31 AM PST, C W wrote: > >Also, I

[R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
Hi list, I have trying to calculate the covariance/correlation of three elements. I have vector say, v <- c(700, 800, 1000) I want to have a 3 by 3 correlation matrix, meaning cor(v1, c2), cor(v1, c3), cor(v2, v3), etc... So far I get, > cor(v) Error in cor(v) : supply both 'x' and 'y' or a mat

Re: [R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. >

[R] How to use curve() with two parameters in the function

2015-10-27 Thread C W
Dear R list, I am trying to plot the curve of a function. Here's the R code: library(mvtnorm) p <- function(x, mu){ mu <- c(mu, 0) dmvnorm(c(x, 1), mu, diag(2)) } > curve(p(x, 2), from = 0, to =1) Error in dmvnorm(c(x, 1), mu, diag(2)) : mean and sigma have non-conforming size I think

Re: [R] How to use curve() with two parameters in the function

2015-10-27 Thread C W
Never mind, I figured it out. You need to use sapply(), for instance, curve(sapply(x, p), from = 0, to =10) Thanks all! On Tue, Oct 27, 2015 at 11:14 AM, C W wrote: > Dear R list, > > I am trying to plot the curve of a function. > > Here's the R code: > > library(mv

[R] How to add legend to 2 different data frame overplot?

2015-10-30 Thread C W
Hi, I am trying to do add a legend to an overplot, something like this: ggplot() + geom_density(data = df1, aes(x = x), fill = "green", show_guide = FALSE) + geom_area(data = df2, aes(x = x), fill = "yellow", show_guide = FALSE) + scale_color_manual(values = c("green", "yellow"), labe

[R] How to find the likelihood, MLE and plot it?

2015-11-18 Thread C W
Dear R list, I am trying to find the MLE of the likelihood function. I will plot the log-likelihood to check my answer. Here's my R code: xvec <- c(2,5,3,7,-3,-2,0) fn <- function(theta){ sum(0.5 * (xvec - rep(theta, 7)) ^ 2 / 1 + 0.5 * log(1)) } gn <- Vectorize(fn) curve(gn, -5, 20) opti

Re: [R] [FORGED] How to find the likelihood, MLE and plot it?

2015-11-19 Thread C W
Hi Rolf, I think the MLE should be 1.71, no? And yes, I am aware of the maximum=TRUE argument. I still feel something is wrong here. Thanks! On Wed, Nov 18, 2015 at 6:23 PM, Rolf Turner wrote: > On 19/11/15 11:31, C W wrote: > >> Dear R list, >> >> I am tryin

Re: [R] [FORGED] How to find the likelihood, MLE and plot it?

2015-11-19 Thread C W
; On Thu, Nov 19, 2015 at 10:29 AM, peter dalgaard wrote: > > On 19 Nov 2015, at 16:17 , C W wrote: > > > Hi Rolf, > > > > I think the MLE should be 1.71, no? And yes, I am aware of the > > maximum=TRUE argument. I still feel something is wrong here. > >

[R] If I have 3 parameters, is optim() doing the same thing as Gibbs sampling?

2015-12-10 Thread C W
Hi R list, I am using optim() to optimize a function with 3 parameters. #My 1-d toy example: loglikelihood of normal with x=c(2,5,3,7,-3,-2,0), find MLE of mean. p1 <- function(theta){ sum(log(dnorm(c(2,5,3,7,-3,-2,0), mean = theta, sd = 1))) +log(dnorm( theta, mean = 0.8, sd = 2)) } optimiz

[R] Why two curves and numerical integration look so different?

2016-02-10 Thread C W
Dear R, I am graphing the following normal density curve. Why does it look so different? # the curves x <- seq(-2, 4, by=0.1) curve(dnorm(x, 2, 10^(-100)), -4, 4) #right answer curve(dnorm(x, 2, 10^(-100)), -3, 4) #changed -4 to -3, I get wrong answer Why the second curve is flat? I just

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
e(..., -2, 4, 100) will not show the bump. > The same principal holds for numerical integration. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Feb 10, 2016 at 6:37 PM, C W wrote: > >> Dear R, >> >> I am graphing the following normal d

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
I want to do numerical integration w.r.t. mu: P(mu) × N(mu, 0.1) Because the variance is small, it results in density like: 7.978846e+94 Is there any good suggestion for this? Thanks so much! On Thu, Feb 11, 2016 at 9:14 AM, C W wrote: > Wow, thank you, that was very clear. Let me g

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
06 PM, David Winsemius wrote: > > > On Feb 11, 2016, at 9:20 AM, C W wrote: > > > > I want to do numerical integration w.r.t. mu: P(mu) × N(mu, 0.1) > > > > Because the variance is small, it results in density like: 7.978846e+94 > > > > Is the

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
but that doesn't seem to be good enough, as we know, it should integrate to 1. On Thu, Feb 11, 2016 at 3:32 PM, David Winsemius wrote: > > > On Feb 11, 2016, at 11:30 AM, C W wrote: > > > > Hi David, > > > > My real function is actually a multivariate norma

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Fri, Feb 12, 2016 at 7:36 AM, C W wrote: > > Hi David, > > > > This is the Gaussian looking distribution I am trying to integrate. > > > h

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
't > work. > > -pd > > On 12 Feb 2016, at 16:57 , C W wrote: > > > Hi Bert, > > > > Yay fantasyland! > > > > In all seriousness, You are referring to this? > > > https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
On a side note, is it ok to do? > which(max(p_x)) and use that instead of numerical integration to get E[X]? I will try both and report back! Thank you expeRts On Fri, Feb 12, 2016 at 11:29 AM, C W wrote: > Hi Peter, > > Great, let me try that and get back to you on my findi

[R] R segfault at startup, causing R crash

2016-11-04 Thread C W
Dear R list, Every time I start R, the following error message come up: *** caught segfault *** address 0x0, cause 'unknown' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace > Selection: I am unable to do a s

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
) R.app R 3.3.2 GUI 1.68 Mavericks build Consider saving your work soon in case this develops into a problem. On Fri, Nov 4, 2016 at 4:39 PM, C W wrote: > Dear R list, > > Every time I start R, the following error message come up: > > *** caught segfault *** > address 0

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
es utils datasets methods [7] base On Fri, Nov 4, 2016 at 4:50 PM, C W wrote: > I just got the following error instead of the previous one, > > 2016-11-04 16:50:08.446 R[23372:326103] -[NSDrawerWindow > setRuleThickness:]: unrecognized selector sent to instance 0x7fabc94a74b0 > 20

[R] Can R markdown do beamer palo alto theme?

2017-01-23 Thread C W
Hi R list, Is it possible to use R markdown with beamer palo alto theme? Are they compatible? I copy pasted my LaTex code over to R, I get the following error message: ! LaTeX Error: Can be used only in preamble. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate

Re: [R] Can R markdown do beamer palo alto theme?

2017-01-23 Thread C W
20 PM, C W wrote: > Hi R list, > > Is it possible to use R markdown with beamer palo alto theme? Are they > compatible? > > I copy pasted my LaTex code over to R, I get the following error message: > > ! LaTeX Error: Can be used only in preamble. > > See the

[R] Confused about using data.table package,

2017-02-19 Thread C W
Hi R, I am a little confused by the data.table package. library(data.table) df <- data.frame(w=rnorm(20, -10, 1), x= rnorm(20, 0, 1), y=rnorm(20, 10, 1), z=rnorm(20, 20, 1)) df <- data.table(df) #drop column w df_1 <- df[, w := NULL] # I thought you are supposed to do: df_1 <- df[, -w] df_2

Re: [R] Confused about using data.table package,

2017-02-20 Thread C W
to have some kind of graph conditioned on species, by grade . What's a good lead to learn about plotting this? Thank you! On Mon, Feb 20, 2017 at 11:12 AM, Hadley Wickham wrote: > On Sun, Feb 19, 2017 at 3:01 PM, David Winsemius > wrote: > > > >> On Feb 19, 2017, at 11

[R] Error in match.fun(f) : object 'x' not found

2017-02-21 Thread C W
Dear R list, I am having a little trouble understanding the R code. I want to compute expectation of normal pdf. I did the following: integrate(x*dnorm(x, rate=1), -Inf, Inf) Error in match.fun(f) : object 'x' not found If I did this, I get, integrate(dexp(x, rate=1), -Inf, Inf) Error in dexp(x

Re: [R] Confused about using data.table package,

2017-02-21 Thread C W
Hi Carl, I have not fully learned dplyr, but it seems harder than tapply() and the ?apply() family in general. Almost every ggplot2 data I have seen is manipulated using dplyr. Something must be good about dplyr. aggregate(), tapply(), do.call(), rbind() will be sorely missed! :( Thanks! On Tu

[R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
Dear R, I wanted to simulate a 5 by 3 matrix which fills up by either rows or columns? I started with the following filling the matrix by rows, dat <- matrix(NA, nrow=5, ncol = 3) for(i in 1:5){ dat[i, ] <- rnorm(3) } But, R is known for no loop drama. Any suggestions? Thanks!

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
gt; And what is this "no loop drama" you refer to? I use loops frequently to > loop around large memory gobbling chunks of code. > > -- > Sent from my phone. Please excuse my brevity. > > On February 24, 2017 5:02:46 PM PST, C W wrote: > >Dear R, > > >

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
to expand your example to illustrate how the data comes to you > in order to suggest alternatives. > > Also post using plain text to prevent your code from being mangled on its > way to us. > -- > Sent from my phone. Please excuse my brevity. > > On February 24, 2017 5:27:07 PM PS

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
ent from my phone. Please excuse my brevity. > > On February 24, 2017 5:55:15 PM PST, C W wrote: > >I suppose for loop will suffice. > > > >I simply copy & paste the code from R editor. From my email, it looks > >plain. Is there a way to tell? > > > >

[R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-14 Thread C W
Dear list, I am trying to use saveGIF() from library animation. https://cran.r-project.org/web/packages/animation/animation.pdf saveGIF() has dependency on package ImageMagick. I got the following, > install.packages("ImageMagick") Warning in install.packages : package ‘ImageMagick’ is not ava

Re: [R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-15 Thread C W
p coming along > > and sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > > > On Tue, Mar 14, 2017 at 10:21 PM, C W wrote: > >> Dear list, > >> > >> I am trying to use saveG

Re: [R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-15 Thread C W
I figured it out. You can first do, saveGIF({ for (j in 1:20){ plot(-4:4, -4:4, type = "n") for(i in 1:10){ x[i] <- rnorm(1) y[i] <- rnorm(1) points(x[i], y[i]) } } }) It looks like you have to re-plot every time. On Wed, Mar 15, 2017 at 1:4

[R] How to understand the mentality behind tidyverse and ggplot2?

2020-11-18 Thread C W
Dear R list, I am an old-school R user. I use apply(), with(), and which() in base package instead of filter(), select(), separate() in Tidyverse. The idea of pipeline (i.e. %>%) my code was foreign to me for a while. It makes the code shorter, but sometimes less readable? With ggplot2, I just do

[R] Is there anyone who uses both R and Python here? How do you debug? Perhaps in RStudio?

2021-01-26 Thread C W
Hello all, I'm a long time R user, but recently also using Python. I noticed that RStudio rolled out Python through reticulate. It's great so far! My question is, how do you debug in Python? In R, I simply step through the code script in my console with cmd+enter. But you can't do that with Pyth

[R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
Hi list, I am using scale() to standardize a distribution? But why does it give me attributes attached to the data? I just want a standardized matrix, that is all. library(mvtnorm) > x <- rmvnorm(15, mean=rep(50, 10)) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
t;scaled:center")<-NULL > attr(x1,"scaled:scale")<-NULL > str(x1) > #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ... > A.K. > > > > > - Original Message - > From: C W > To: r-help > Cc: > Sent: Tuesday, July 16, 2013 3

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
; scale <- apply(x, 2L, f) > x <- sweep(x, 2L, scale, "/", check.margin = FALSE) > } > } > else if (is.numeric(scale) && length(scale) == nc) > x <- sweep(x, 2L, scale, "/", check.margin = FALSE) >

[R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Hi everyone, I am using package knitr, FIRST TIME. I don't have access to RStudio. Read through Yihui's page, didn't find it helpful. Stuck on terms Rnw, GFM (GitHub Flavored Markdown). Never used Sweave, so the reference is not helping. Is there a simple step-by-step example WITHOUT RStudio?

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
com/product/isbn/9781482203530 > > Regards, > Yihui > -- > Yihui Xie > Phone: 206-667-4385 Web: http://yihui.name > Fred Hutchinson Cancer Research Center, Seattle > > > On Thu, Jul 18, 2013 at 11:13 AM, C W wrote: >> Hi everyone, >> >> I am using pack

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
xamples/knitr-minimal.Rnw > > > Hope this helps > > > Best > > Simon > > > > > > On Jul 18, 2013, at 8:52 PM, C W wrote: > >> How do you create a .Rnw file, in R or LaTex? I don't think any >> tutorial mentions it. >> >>

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Actually, I see it at the bottom. Sorry! On Thu, Jul 18, 2013 at 3:44 PM, C W wrote: > Hi Simon, > I am on OS X Lion, I have TeXworks, I don't have knitr as an option. > > How do I install that into TeXworks? Seems like I have to something > in terminal? > > Mike >

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165 In step 3: "add the executable file (step 3)". What is the executable file? Locate package knitr directory path in R? Mike On Thu, Jul 18, 2013 at 3:56 PM, C W wrote: > Actually, I see it at the b

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
at 4:19 PM, Berend Hasselman wrote: > > On 18-07-2013, at 22:09, C W wrote: > >> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165 >> >> In step 3: "add the executable file (step 3)". >> >> What is the executabl

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
e the \begin{document} \end{document} tags. > > > > Best > > Simon > > On Jul 18, 2013, at 10:22 PM, C W wrote: > >> Thanks, Simon. I would never figured it out! >> >> I apologize if I sound frustrated, because I am. >> >> @package aut

[R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Hi R list, I have a sequence repeating 1:15 . Some numbers are deleted. I want to find how many times 1, 2, 3 appeared. Basically, I want to "grab" the beginning of the sequence and tally it up. R code: > vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, 15, 1, 2, 3, 5, 6,

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
end Hasselman wrote: > > On 20-07-2013, at 18:05, C W wrote: > >> Hi R list, >> >> I have a sequence repeating 1:15 . Some numbers are deleted. I want >> to find how many times 1, 2, 3 appeared. >> Basically, I want to "grab" the beginning of the sequen

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
table, >> # of times one element (out of 1, 2, 3) showed up, two elements, and all >> three. >> >> I am trying, don't know if this works: >> >>> aa <- rle(a) >>> b <- aa$lengths[aa$values] >>> table(b) >> b >> 1 3 >> 3 12

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
t;>>> Sent: Sat, 20 Jul 2013 12:36:55 -0400 >>>> To: b...@xs4all.nl >>>> Subject: Re: [R] How to search for a sequence(and its combination) >>>> inside >>>> a vector? >>>> >>>> Hi Berend >>>> I am looking for a

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
On Sat, Jul 20, 2013 at 1:50 PM, C W wrote: > Thanks, you guys are correct, I had different data. > But why I get length 5 and 6, should only be 1 to 3. > > Full R code : > > vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, > 15, 1, 2, 3, 5, 6, 10, 12,

[R] How to delete repeated values in MCMC sampling and get index of unique values?

2013-01-17 Thread C W
Dear list, How do you delete repeated samples? In MCMC, when your candidate value has been reject, so you remain on the same point, so you keep that value. Say I have this toy example, > c(1,6,6,6,3,5,4,4,2,3,5) The 6 and 4 are repeated, I only want the index of the non-repeated values. I thou

Re: [R] How to delete repeated values in MCMC sampling and get index of unique values?

2013-01-17 Thread C W
Exactly what I am looking for. Thanks a lot! Mike On Thu, Jan 17, 2013 at 4:59 PM, Duncan Murdoch wrote: > On 13-01-17 4:50 PM, C W wrote: > >> Dear list, >> How do you delete repeated samples? In MCMC, when your candidate value >> has >> been reject, so you re

Re: [R] How to delete repeated values in MCMC sampling and get index of unique values?

2013-01-17 Thread C W
-- Bert > > On Thu, Jan 17, 2013 at 1:59 PM, Duncan Murdoch > wrote: > > On 13-01-17 4:50 PM, C W wrote: > >> > >> Dear list, > >> How do you delete repeated samples? In MCMC, when your candidate value > >> has > >> been reject, so yo

[R] Recommendation for website to format R code

2013-01-23 Thread C W
Hi list, Could anyone recommend some good website for formatting R code? For example, when you copy paste R code to gmail and back to R, it loses its format, the dash symbol causes errors. I've had someone used it to format my code here on the list, but can't find it anymore. Mike [[al

Re: [R] Recommendation for website to format R code

2013-01-23 Thread C W
kage: > > http://yihui.name/knitr/ > > Also, you could check out the formatR package: > http://cran.r-project.org/web/packages/formatR/formatR.pdf > > --Mark Lamias > > > -- > *From:* C W > *To:* r-help > *Sent:* Wednesday, January

Re: [R] Recommendation for website to format R code

2013-01-24 Thread C W
: > On 1/23/2013 6:40 PM, C W wrote: > >> Hey Mark, >> I am aware of this package. The situation is, >> 1. I am emailing my code from my machine to a public machine. >> Installation >> is a hassle. >> 2. Copy pasting for a website. >> > >

Re: [R] Recommendation for website to format R code

2013-01-24 Thread C W
ou are interested in formatting your code in Latex/PDF/HTML > take a look at the knitr package: > > http://yihui.name/knitr/ > > Also, you could check out the formatR package: > http://cran.r-project.org/web/packages/formatR/formatR.pdf > > --Mark Lamias > > > -----

[R] the word "rand" comes up in console after typing a command

2013-01-31 Thread C W
Hi list, I keep on getting this "rand" word come up on my console. It shows up maybe one out 20 times I type in R console. I don't understand why it is coming up? > mean(variables) [1] -0.41 rand rand rand rand rand rand rand rand rand rand rand rand rand rand rand> mean(variables) > rm(list

Re: [R] the word "rand" comes up in console after typing a command

2013-01-31 Thread C W
t this was > investigated and fixed in the most recent release of the Mac GUI. > > -- > David. > > > > On Jan 31, 2013, at 9:49 PM, C W wrote: > > Hi list, >> I keep on getting this "rand" word come up on my console. It shows up >> maybe one ou

[R] How to stack row vector on top of each other?

2013-02-14 Thread C W
Hi list, How do you actually stack a vector on top of each other? Say, I want everything in a row vector. Neither rbind(), nor cbind() will do the job. It gives me 2 dimension. Here's my reproducible example: > a <- rnorm(10) > b <- rnorm(10) > c <- cbind(a,b) > dim(c) [1] 10 2 > d <- rbind(a

Re: [R] How to stack row vector on top of each other?

2013-02-14 Thread C W
lt;- rnorm(10) > > d <- c(a,b) > > length(d) > [1] 20 > > HTH, > Pascal > > > Le 15/02/2013 10:08, C W a écrit : > >> Hi list, >> How do you actually stack a vector on top of each other? Say, I want >> everything in a row vector. Neither rbin

[R] Why R simulation gives same random results?

2013-02-19 Thread C W
Hi, list I am doing 100,000 iterations of Bayesian simulations. What I did is I split it into 4 different R sessions, each one runs 25,000 iteration. But two of the sessions gave the simulation result. I did not use any set.seed(). What is going on here? Thanks, Mike [[alternative HTM

Re: [R] Why R simulation gives same random results?

2013-02-20 Thread C W
ame) then they would start from the same seed. > > > On Tue, Feb 19, 2013 at 6:31 PM, C W wrote: > >> Hi, list >> I am doing 100,000 iterations of Bayesian simulations. >> >> What I did is I split it into 4 different R sessions, each one runs 25,000 >>

[R] using reserved words in R, and reuse variable names in different functions

2013-03-01 Thread C W
Hi list, I am writing several functions and running out variable names. I am using words such as "t", "c", "matrix" to keep the notation same as formulas I am using. For example I have, unnormalized <- function(t, x, y){ val <- rnorm(t, mean=x, var=y) return(val) } metropolis <- functio

Re: [R] using reserved words in R, and reuse variable names in different functions

2013-03-01 Thread C W
Thanks, that was just an example I came up with. I was just curious if using same variable names in different functions would cause problems. Especially with reserved words. Mike On Fri, Mar 1, 2013 at 5:45 PM, David Winsemius wrote: > > On Mar 1, 2013, at 1:56 PM, C W wrote: > &g

Re: [R] using reserved words in R, and reuse variable names in different functions

2013-03-01 Thread C W
turday, March 02, 2013 5:01 AM > > To: Sarah Goslee > > Cc: r-help > > Subject: Re: [R] using reserved words in R, and reuse variable names in > different > > functions > > > > On 03/02/2013 01:12 PM, Sarah Goslee wrote: > > > On Fri, Mar 1, 2013 at 7:06 P

[R] How to stop set.seed() besides exiting out of R?

2013-03-18 Thread C W
Hi list, I am curious how to stop the set.seed(), I don't want the same repeated random number. I know I can set it to a different seed, but I don't want to go through the trouble of setting different seed every time. Thanks, Mike [[alternative HTML version deleted]] __

  1   2   >