similar to: define a list with names as variables

Displaying 20 results from an estimated 10000 matches similar to: "define a list with names as variables"

2017 Aug 04
1
define a list with names as variables
Do you mean like this? > f <- function(foo, bar) { + result <- list(bar) + names(result) <- foo + result + } > (x <- f("hello", "world")) $hello [1] "world" > names(x) [1] "hello" -- Thomas Mailund On 4 August 2017 at 12.08.28, Giovanni Gherdovich (g.gherdovich at gmail.com) wrote: Hello, I'm having troubles defining
2017 Aug 04
0
define a list with names as variables
Hello Thomas, Ulrik, thanks for your suggestions. Giovanni On Fri, Aug 4, 2017 at 12:13 PM, Thomas Mailund <thomas.mailund at gmail.com> wrote: > Do you mean like this? > > >> f <- function(foo, bar) { > + result <- list(bar) > + names(result) <- foo > + result > + } > >> (x <- f("hello", "world")) > $hello >
2017 Aug 04
0
define a list with names as variables
Hi Giovani, I would create an unnamed list and set the names after. Best, Ulrik On Fri, 4 Aug 2017 at 12:08 Giovanni Gherdovich <g.gherdovich at gmail.com> wrote: > Hello, > > I'm having troubles defining a list where names are variables (of type > character). Like this, which gives "foo" instead of "world" (the way I > meant it is that
2017 Aug 04
2
define a list with names as variables
You can wrap the list-creating function call (e.g. lapply) in a call to ?setNames, or you can use the ?map function from the purrr package. -- Sent from my phone. Please excuse my brevity. On August 4, 2017 3:14:44 AM PDT, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote: >Hi Giovani, > >I would create an unnamed list and set the names after. > >Best, >Ulrik > >On
2017 Aug 04
0
define a list with names as variables
> f <- function(foo,bar) structure(list(bar),names =foo) > f("hello","world") $hello [1] "world" Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Aug 4, 2017 at 6:12 AM, Jeff
2017 Jul 13
2
Help with R script
Using Ulrik?s example data (and assuming I understand what is wanted), here is what I would do: ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE) sp <- strsplit(tst$x, ':', fixed=TRUE) chk <-
2018 Jan 28
2
Newbie wants to compare 2 huge RDSs row by row.
The anti_join from the package dplyr might also be handy. install.package("dplyr") library(dplyr) anti_join (x1, x2) You can get help on the different functions by ?function.name(), so ?anti_join() will bring you help - and examples - on the anti_join function. It might be worth testing your approach on a small subset of the data. That makes it easier for you to follow what happens
2017 Jul 14
0
Help with R script
@Don your solution does not solve Vijayan's scenario 2. I used spread and gather for that. An alternative solution to insert mising Fval - picking up with Don's newtst - is newtst <- c("FName: fname1", "Fval: Fval1.name1", "FName: fname2", "Fval: Fval2.name2", "FName: fname3", "FName: fname4", "Fval: fval4.fname4")
2017 Sep 12
2
Load R data files
Dear All: It was saved, but there was a space somewhere. So it works for me now. I do have another similar problem. I saved an R data file save(datahs0csv,file=" F:\Fall_2017\5-STA574\2-Notes\1-R\1-R_new\chapter4-Entering_Data/datahs0csv2 .rda") *The new R data file "*datahs0csv2.rda*" is in the directory.* I tried to load the file "" to R, but I got an error
2017 Jun 01
4
Data import R: some explanatory variables not showing up correctly in summary
Hi Tara, It seems that you categorise and count for each category. Could it be that the method you use puts everything that doesn't match the predefined categories in Other? I'm only guessing because without a minimal reproducible example it's difficult to do anything else. Best wishes Ulrik Rui Barradas <ruipbarradas at sapo.pt> schrieb am Do., 1. Juni 2017, 17:30: >
2010 Sep 04
3
Levels in returned data.frame after subset
Dear List, When I subset a data.frame, the levels are not re-adjusted (see example). Why is this? Am I missing out on some basic stuff here? Thanks Ulrik > m <- data.frame(gender = c("M", "M","F"), ht = c(172, 186.5, 165), wt = c(91,99, 74)) > dim(m) [1] 3 3 > levels(m$gender) [1] "F" "M" > s <- subset(m, m$gender ==
2018 Jan 28
0
Newbie wants to compare 2 huge RDSs row by row.
The diffobj package (https://cran.r-project.org/package=diffobj) is really helpful here. It provides "diff" functions diffPrint(), diffStr(), and diffChr() to compare two object 'x' and 'y' and provide neat colorized summary output. Example: > iris2 <- iris > iris2[122:125,4] <- iris2[122:125,4] + 0.1 > diffobj::diffPrint(iris2, iris) < iris2 >
2018 Jan 28
1
Newbie wants to compare 2 huge RDSs row by row.
Thanks, I think I've found the most succinct expression of differences in two data.frames... length(which( rowSums( x1 != x2 ) > 0)) gives a count of the # of records in two data.frames that do not match. // ________________________________________ From: Henrik Bengtsson [henrik.bengtsson at gmail.com] Sent: Sunday, January 28, 2018 11:12 AM To: Ulrik Stervbo Cc: Marsh Hardy ARA/RISK;
2018 Jan 27
2
Newbie wants to compare 2 huge RDSs row by row.
If your two objects have class "data.frame" (look at class(objectName)) and they both have the same number of columns and the same order of columns and the column types match closely enough (use all.equal(x1, x2) for that), then you can try which( rowSums( x1 != x2 ) > 0) E.g., > x1 <- data.frame(X=1:5, Y=rep(c("A","B"),c(3,2))) > x2 <-
2017 Sep 12
0
Load R data files
The object you load has the same name as the object you saved. In this case datahs0csv and not the name of the file sans .rda On Di., 12. Sep. 2017, 21:26 AbouEl-Makarim Aboueissa < abouelmakarim1962 at gmail.com> wrote: > Dear All: > > > It was saved, but there was a space somewhere. So it works for me now. > > I do have another similar problem. > > I saved an R
2017 Aug 26
0
Find maxima of a function
Please keep the list in cc. Sorry, it didn't work as expected. Maybe someone else have an appropriate solution. Best, Ulrik On Sa., 26. Aug. 2017, 12:57 niharika singhal <niharikasinghal1990 at gmail.com> wrote: > Hi > > Thanks for you mail, > I really appreciate your time on my problem > > I have posted this problem on > > >
2016 Apr 24
2
Inserting a blank row to every other row
Well, something like this would work (there may be slicker solutions): > z <- data.frame(a=1:3,b = letters[1:3]) > i <- seq_len(nrow(z)) *2 > z <-rbind(z,z) > z[i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z)) > z a b 1 1 a 2 NA <NA> 3 3 c 4 NA <NA> 5 2 b 6 NA <NA> But I agree with you that there is probably a way to handle the underlying
2018 Apr 17
3
Hacked
I asked the moderators about it. This is the reply "Other moderators have looked into this a bit and may be able to shed more light on it. This is a "new" tactic where the spammers appear to reply to the r-help post. They are not, however, going through the r-help server. It also seems that this does not happen to everyone. I am not sure how you can automatically block the
2018 Jan 27
3
Newbie wants to compare 2 huge RDSs row by row.
Also, it will be easier to provide helpful information if you'd describe what in your data you want to compare and what you hope to get out of the comparison. Best wishes, Ulrik Eric Berger <ericjberger at gmail.com> schrieb am Sa., 27. Jan. 2018, 08:18: > 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
2018 Apr 17
0
Hacked
I got some spam emails after my last post to the list, and the emails did not seem to go through r-help. The spammers may be subscribed to the r-help, or they get the poster emails from some of the web copies of this list (nabble or similar). Peter On Tue, Apr 17, 2018 at 11:37 AM, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote: > I asked the moderators about it. This is the reply