similar to: A question on list and lapply

Displaying 20 results from an estimated 7000 matches similar to: "A question on list and lapply"

2012 Dec 18
7
Summarizing elements for a data.frame
Hello again, let say we have following data: Dat1 <- structure(list(factor.sample.LETTERS.1.3...6..replace...T.. = structure(c(1L, 3L, 2L, 1L, 3L, 3L), .Label = c("A", "B", "C"), class = "factor"), factor.sample.letters.1.2...6..replace...T.. = structure(c(2L, 2L, 1L, 1L, 2L, 1L), .Label = c("a", "b"), class =
2013 Jan 15
2
Need some help on Text manipulation.
Dear all, Let say I have following data-frame: Dat <- structure(list(dat = c(-0.387795842956327, -0.23270882099043, -0.89528973290562, 0.95857175595512, 1.61680582493783, -1.17738110289352, 0.210601060411423, -0.827369747447338, -0.36896112964414, 0.440288648776096, 1.28018410608809, -0.897113649961341, 0.342216546981718, -1.17288066266219, -1.57994101992621, -0.913655547602414,
2009 Jun 23
2
Partitioning matrix
Let say, I have following matrix : dat <- matrix(rnorm(40), 2, 20) Now I want to partition this like this : dat1 <- dat[1,] dat2 <- dat[2,] But point is that, dat1 and dat2 become vector object. How can I force them to be matrix object with dimension (1x20) ? Thanks, -- View this message in context: http://www.nabble.com/Partitioning-matrix-tp24161021p24161021.html Sent from the R
2009 Sep 25
3
Problem on plotting TS using GGPLOT
Hi, I have following codes : library(zoo); library(ggplot2); library(plyr) dat <- rnorm(306); vv <- letters[1:6]; dat1 <- data.frame(dat, vv) dat2 = zooreg(rnorm(51), as.yearmon(as.Date("2000-01-01")), frequency=12) ggplot(dat1) + geom_line(aes(y=dat, x=index(dat2), colour=vv), group=vv, size = 1.3) However I got error while plotting them :
2012 Dec 06
1
Can somebody help me with following data manipulation?
Dear all, let say I have following data: dat <- structure(list(V1 = structure(c(1L, 4L, 5L, 3L, 3L, 5L, 6L, 6L, 4L, 3L, 5L, 6L, 5L, 5L, 4L, 4L, 6L, 2L, 3L, 4L, 3L, 3L, 2L, 5L, 3L, 6L, 3L, 3L, 6L, 3L, 6L, 1L, 6L, 5L, 2L, 2L), .Label = c("C", "G", "I", "O", "R", "T"), class = "factor"), V2 = c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L,
2017 Oct 09
1
load() failed to load .Rdata file in AWS-Ububtu
Hi Eric, thanks for your further pointer. I have put a line with load() function just as an illustration of a bigger project of mine, which appears failing due to load() function issue. If I comment out that line my shiny app is working correctly locally and globally. otherwise, locally my shiny app is working but not with AWS. On Mon, Oct 9, 2017 at 12:37 PM, Eric Berger <ericjberger at
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration) Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Lapply_me(as.list(1:4), function(xx) { if (xx ==
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a" and "b", still
2018 Mar 04
0
Change Function based on ifelse() condtion
The reason that it works for Apply_MC=TRUE is that in that case you call mclapply(X,FUN,...) and the mclapply() function strips off the mc.cores argument from the "..." list before calling FUN, so FUN is being called with zero arguments, exactly as it is declared. A quick workaround is to change the line Lapply_me(as.list(1:4), function(xx) { to Lapply_me(as.list(1:4),
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below : Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% '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,
2018 Mar 04
2
Change Function based on ifelse() condtion
@Eric - 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 <ericjberger at gmail.com> wrote: > Hi Christofer, > You cannot assign to list(...). You can do the following > > myList <- list(...)[!names(list(...)) %in% 'mc.cores'] > > HTH, > Eric > > On Sun, Mar
2017 Oct 08
2
load() failed to load .Rdata file in AWS-Ububtu
Thanks Eric for your pointer. However I just altered the argument of load() function a little bit to get that loaded. Below is the line what I tried. ubuntu at ip-172-31-23-148:~$ R R version 3.4.2 (2017-09-28) -- "Short Summer" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO
2017 Aug 02
4
Extracting numeric part from a string
Hi again, I am struggling to extract the number part from below string : "\"cm_ffm\":\"563.77\"" Basically, I need to extract 563.77 from above. The underlying number can be a whole number, and there could be comma separator as well. So far I tried below : > library(stringr) > str_extract("\"cm_ffm\":\"563.77\"",
2012 Mar 16
4
How to start R in maximized size???
Dear all, when I start R, I want that the console window should be in the Maximized size automatically. Can somebody help me how to achieve that? Thanks and regards,
2013 Mar 28
4
How to replace '$' sign?
Hello again, I want to remove "$" sign and replace with nothing in my text. Therefore I used following code: > gsub("$|,", "", "$232,685.35436") [1] "$232685.35436" However I could not remove '$' sign. Can somebody help me why is it so? Thanks and regards
2018 Mar 04
0
Change Function based on ifelse() condtion
That's fine. The issue is how you called Lapply_me(). What did you pass as the argument to FUN? And if you did not pass anything that how is FUN declared? You have not shown that in your email. On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso < bogaso.christofer at gmail.com> wrote: > My modified function looks below : > > Lapply_me = function(X = X, FUN = FUN, Apply_MC =
2017 Aug 10
3
Zoo rolling window with increasing window size
Hi Joshua, thanks for your prompt reply. However as I said, sum() function I used here just for demonstrating the problem, I have other custom function to implement, not necessarily sum() I am looking for a generic solution for above problem. Any better idea? Thanks, On Fri, Aug 11, 2017 at 12:04 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote: > Use a `width` of integer index
2011 Nov 10
5
A question on Programming
Dear all. Let say I have a group of codes which will be used in many places in my overall R-code files. These group of codes will be used within a for-loop (with a big length, like 10000 times) and also many other places outside of that for loop. As this group of codes are being used in many places, I thought to put them within a user-defined function. Here my question is, is there any speed
2011 Jan 21
3
How to look into the asterisked function?
Hi friends, there is methods() function to see the all available methods for a particular function, for example: > head(methods("print")) [1] "print.acf" "print.anova" "print.aov" "print.aovlist" "print.ar" "print.Arima" In this list, there are some functions which are asterisked like print.acf().
2023 Nov 29
2
Code editor for writing R code
Bert, Posit (formerly RStudio) has moved from RMarkdown to Quarto. They still support RMarkdown but major new features will be in Quarto. For new users a better choice would be Quarto. See https://quarto.org/docs/faq/rmarkdown.html Secondly, the OP stated he was using the VS-Code IDE, so there is no reason to point him to the Posit/RStudio IDE for this functionality which VS-Code supports very