Re: [R] Puzzled about loading the Rattle interface package...

2021-12-07 Thread Eric Berger
Hi Brian, I have never tried Rattle but I did a quick search and found this link which might give some clues. https://book.huihoo.com/data-mining-desktop-survival-guide/Installing_GTK.html Good luck, Eric On Tue, Dec 7, 2021 at 1:29 PM Brian Lunergan wrote: > > Evening folks: > > Hope I'm in t

Re: [R] matching type question, please

2021-12-16 Thread Eric Berger
> a <- cbind(c(xr1,xs1),c(xr2,xs2)) > a[duplicated(a)] [1] 4 4 On Thu, Dec 16, 2021 at 10:18 PM Erin Hodgess wrote: > > Hello! > > I have the following: > > cbind(xr1,xr2) > > xr1 xr2 > > [1,] 8 0 > > [2,] 7 1 > > [3,] 6 2 > > [4,] 5 3 > > [5,] 4 4 > > [6,] 3

Re: [R] nlme::lme sigma parameter standard deviation or variance?

2021-12-18 Thread Eric Berger
You can run a test. Multiply all your data by a scalar, say 2. If this changes the result lme_mod$sigma by a factor of 2, then it is a std deviation. If it changes the result by a factor of 4, then it is a variance. HTH, Eric On Sat, Dec 18, 2021 at 11:26 AM Courtney Van Den elzen wrote: > > Hi

Re: [R] for loop question in R

2021-12-22 Thread Eric Berger
Try replacing "c:/temp/f[i].jpg" with paste0("c:/temp/",f[i],".jpg") On Wed, Dec 22, 2021 at 7:08 PM Kai Yang via R-help wrote: > Hello R team,I want to use for loop to generate multiple plots with 3 > parameter, (y is for y axis, c is for color and f is for file name in > output). I created a

Re: [R] Time for a companion mailing list for R packages?

2022-01-13 Thread Eric Berger
Re: constructive criticism to make this list more useful to more people: Suggestion 1: accommodate questions related to non-base-R packages This has been addressed by many already. The current de facto situation is that such questions are asked and often answered. Perhaps th

Re: [R] A question of data frame filter based on another one

2022-02-18 Thread Eric Berger
x[apply(y,MAR=1,sum) > 0,] On Fri, Feb 18, 2022 at 10:24 PM Li, Aiguo (NIH/NCI) [E] via R-help < r-help@r-project.org> wrote: > I have tow dataframes as below: > > x > id g > 1 1 21 > 2 3 52 > 3 2 43 > 4 4 94 > 5 5 35 > > > y > id g > 1 1 1 > 2 0 0 > 3 0 1 > 4 1 0 > 5 1 0 > > Resu

Re: [R] Possible causes of unexpected behavior

2022-03-04 Thread Eric Berger
Please confirm that when you do the manual load and check that f(v*) matches the result from qsub() it succeeds for cases #1,#2 but only fails for #3. On Fri, Mar 4, 2022 at 10:06 AM Arthur Fendrich wrote: > Dear all, > > I am currently having a weird problem with a large-scale optimization > r

Re: [R] stdev error

2022-03-11 Thread Eric Berger
try changing Bse_ftv = mean(Bse_ftv) to Bse_ftv_mean = mean(Bse_ftv) On Fri, Mar 11, 2022 at 4:15 PM Jeff Reichman wrote: > r-help forum > > > > When I run the following code > > > > my_tbl %>% > > mutate(Bse_bwt = round(Bse_bwt * 2) / 2) %>% > > group_by(Cat, Bse_bwt) %>% > > summarize(co

Re: [R] Where is list.names?

2022-03-30 Thread Eric Berger
At the R console prompt do: > table It prints out the source of the table() function. The first thing there is the definition of list.names() HTH, Eric On Wed, Mar 30, 2022 at 12:27 PM Göran Broström wrote: > I am trying to redefine the default behavior of base::table by editing > .Rprofile

Re: [R] [External] "apply" a function that takes two or more vectors as arguments, such as cor(x, y), over a "category" or "grouping variable" or "index"?

2022-04-08 Thread Eric Berger
library(dplyr) my_df |> group_by(my_category) |> summarise(my_z = cor(my_x, my_y)) On Sat, Apr 9, 2022 at 4:37 AM Richard M. Heiberger wrote: > look at > ?mapply > Apply a Function to Multiple List or Vector Arguments > > to see if that meets your needs > > > On Apr 08, 2022, at 21:26, Kelly Th

Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-09 Thread Eric Berger
This looks like homework, which is not permitted on this list. But giving you the benefit of the doubt, here are two ways to do it > as.matrix(val_df) * matrix(rep(weights$value,5),ncol=3,byrow = TRUE) ABC DEF ONS [1,] 10 2 500 [2,] 20 4 500 [3,] 10 20 1000 [4,] 10 4 500 [5,]

Re: [R] Max-Diff Package

2022-04-13 Thread Eric Berger
I have no experience with this but a Google search came up with CRAN support.BWS See https://cran.r-project.org/web/packages/support.BWS/index.html On Wed, Apr 13, 2022 at 4:37 PM Dr Cazhaow Qazaz wrote: > Hi All, > > Any recommendations for a R package to perform MaxDiff analysis? > > Thank y

Re: [R] Looping through all matrix columns each 1 row at a time

2022-04-21 Thread Eric Berger
Hi Paul, I am not sure I understand your question, but perhaps the following is helpful. In particular, the apply() function used with MAR=1, applies a function to a matrix row-wise. set.seed(123) m <- matrix(sample(1:6,5*12,replace=TRUE),ncol=12) ## dummy data m [,1] [,2] [,3] [,4] [,5] [,6]

Re: [R] Confusing fori or ifelse result in matrix manipulation

2022-04-25 Thread Eric Berger
M[,x==1] is not the same as M[,x] :-) However, M[,!!x] is the same as M[,x==1] and saves one character! The point of this is "I can name that tune in ... " (as if that was not obvious) On Mon, Apr 25, 2022 at 5:30 PM Bert Gunter wrote: > x == 1 is the same as M[, x] so your expression is the s

Re: [R] struccchange on zoo time series

2022-05-01 Thread Eric Berger
Hi Achim, My point was that tsbox (apparently) provides tools to convert zoo --> ts which should help the OP. On Sun, May 1, 2022 at 5:56 PM Achim Zeileis wrote: > > On Sun, 1 May 2022, Eric Berger wrote: > > > Hi Naresh, > > The tsbox package on CRAN - > >

Re: [R] extracting numeric values returned when using the by function to run the acf function

2022-05-10 Thread Eric Berger
as.numeric(by(RecallSmall[1:4,"value"],RecallSmall[1:4,"ID"],acf,na.action=na.pass,plot=FALSE)[[1]]$acf) On Tue, May 10, 2022 at 8:29 PM Sorkin, John wrote: > I am using the by function to run the acf function. Each run of the by > function returns more information than I want. All I want is th

Re: [R] Fitted values from AR model

2022-08-12 Thread Eric Berger
The model that you are fitting to the data is an AR(2) model, which means y(t) = a0 + a1 * y(t-1) + a2 * y(t-2) + eps(t) (1) The fitting procedure estimates the coefficients a0, a1, a2 (and the variance of eps). After the coefficients have been estimated, the fitted values can be

Re: [R] von Neumann/Bartels/Serial Correlation

2022-08-14 Thread Eric Berger
Hi Nick, I have no experience with this package but I just installed it with no problem and found the help and ran the functions. > library(DescTools) > ?VonNeumannTest <-- works fine > VonNeumannTest(d.pizza$temperature) <-- suggested in the help page; works > fine > ?BartelsRankTest <-- wor

Re: [R] Problem with installing packages in R

2022-09-15 Thread Eric Berger
Can you bring up R in a shell? Do you get the same message? (Also, set your email to send plain text. HTML versions are deleted.) On Thu, Sep 15, 2022 at 11:27 AM Farah Al Saifi wrote: > > Dear Sir/Madam > > After the update of the new version of R 4.2.1, an error message ( Error in > nchar(ho

Re: [R] opening nimroad tar gz files in R

2022-09-15 Thread Eric Berger
Is there a way to download a file from that site without registering for the site? If you have a unix/linux shell, what does the 'file' command output? $ file foo.gz On Thu, Sep 15, 2022 at 2:11 PM Nick Wray wrote: > Hello > > I am trying to download data sets from the 1 km Resolution UK Comp

Re: [R] removing non-table lines

2022-09-19 Thread Eric Berger
Hi Nick, Here's one way to do it. It is based on the heuristic that you keep each line with the correct number of fields. The correct number of fields is automatically determined by the number of fields in the last line of the file. Here's the contents of a sample csv file - "tmp3.csv" where the

Re: [R] Converting time format

2022-09-19 Thread Eric Berger
What is the output of > class(b$time) ? Also, start sending your emails in plaint text format, if possible. On Mon, Sep 19, 2022 at 2:12 PM Parkhurst, David wrote: > > I have a dataframe obtained using read.csv from an excel file. Its first > column is times, running from 18:00 to 19:30. If

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Eric Berger
You are misinterpreting what is going on. The rbind command includes c(char, char, int) which produces a character vector of length 3. This is what you are rbind-ing which changes the type of the RT column. If you do rbind(df, data.frame(P="in", ANSWER="V>N", RT=round(runif(1,7000,16000),0))) you

Re: [R] aplpack / bagplot

2022-09-21 Thread Eric Berger
Hi Sigbert, I have never used the aplpack package but out of curiosity I tried it out. Doing a scatter plot of your (x,y) data shows that there are many repeated x values, and this seems to be the source of the error. There are no repeated y values. It seems that the bagplot() function does not han

Re: [R] aplpack / bagplot

2022-09-21 Thread Eric Berger
[re-sending as plain text] Hi Sigbert, I have never used the aplpack package but out of curiosity I tried it out. Doing a scatter plot of your (x,y) data shows that there are many repeated x values, and this seems to be the source of the error. There are no repeated y values. It seems that the bag

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Eric Berger
Hi Andrew, If you look at ?source you see its default value for encoding is picked up from getOption("encoding"). Couldn't you just set this option in your Rprofile? HTH, Eric On Wed, Sep 21, 2022 at 5:34 PM Andrew Hart via R-help wrote: > > Hi there. I'm working with some utf-8 incoded csv fil

Re: [R] Error in if (class(networks) == "matrix") from a function

2022-09-21 Thread Eric Berger
In R 4.2.0 there is a significant change. When you use an if() statement with a condition of length > 1 this now reports an error. e.g. this link mentions it as a change https://www.jumpingrivers.com/blog/new-features-r420/ In your case this is because class(obj) can return a character vector of l

Re: [R] Fatal Error: Contains Space

2022-09-22 Thread Eric Berger
Does this help? https://stackoverflow.com/questions/72138987/r-studio-fatal-error-r-tempdircontains-space On Thu, Sep 22, 2022 at 10:37 AM Kaitlyn Light wrote: > Hello! > I recently downloaded R and RStudio to my windows laptop. I downloaded the > correct version and made sure it was for windows

Re: [R] Solve equality function with GA

2022-09-25 Thread Eric Berger
?ga states that ga() searches for the maximum of the fitness function. The maximum of your fitness function is at x=0. On Sun, Sep 25, 2022 at 4:52 AM Bert Gunter wrote: > We aren't supposed to do homework on this list. > > Bert Gunter > > On Sat, Sep 24, 2022 at 5:29 PM Barry King via R-help

Re: [R] apply to row and column of matrix

2022-09-26 Thread Eric Berger
Bert provided an excellent answer to your question. FYI here is a different approach to do the calculation. It uses data.frame rather than matrix. A data frame is a list of its columns. Here the function supplied to sapply operates on each column of the data.frame. > m <- as.data.frame(t(matrix(1:

Re: [R] Fatal Error: Contains Space

2022-09-28 Thread Eric Berger
so > much for the help!! > > Best, > Kaitlyn Light > > On Thu, Sep 22, 2022 at 3:42 AM Eric Berger wrote: >> >> Does this help? >> https://stackoverflow.com/questions/72138987/r-studio-fatal-error-r-tempdircontains-space >> >> On Thu, Sep 22, 2022

Re: [R] Unintended behaviour of stats::time not returning integers for the first cycle

2022-10-15 Thread Eric Berger
Alternatively correct.year <- floor(time(x)+1e-6) On Sat, Oct 15, 2022 at 10:26 AM Andreï V. Kostyrka < andrei.kosty...@gmail.com> wrote: > Dear all, > > > > I was using stats::time to obtain the year as a floor of it, and > encountered a problem: due to a rounding error (most likely due to its

Re: [R] Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ?

2022-10-26 Thread Eric Berger
Also, since your examples were dplyr and dbplyr which are associated with RStudio.com (aka Posit) you might also try https://community.rstudio.com You can apply filters on that site to narrow the results On Wed, Oct 26, 2022 at 10:12 PM Jeff Newmiller wrote: > > The general recommendation is

Re: [R] Color Nodes

2022-10-27 Thread Eric Berger
You may want to change the color of the vertex labels. e.g. plot(g, vertex.size = 20, vertex.label.dist = 0.5, vertex.color = V(g)$color, vertex.label.color="cyan") On Thu, Oct 27, 2022 at 1:52 AM Jeff Reichman wrote: > > Yes Rui that will work for my needs thank you > > -Original Mes

Re: [R] Single pdf of all R vignettes request

2022-10-31 Thread Eric Berger
You can see all the installed vignettes on your system with `browseVignettes()`. (This opens a browser page.) Alternatively `browseVignettes("pkgname")` for those related to a single package. HTH, Eric On Mon, Oct 31, 2022 at 11:37 AM Richard O'Keefe wrote: > Let's put some numbers on that. >

Re: [R] Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-06 Thread Eric Berger
Hi Tiffany, Here is some code that might help with your problem. I solve a "toy" problem that is conceptually the same. Part 1 sets up my toy problem. You would have to replace Part 1 with your real case. The main point is to define a function f(i, j, data) which returns 0 or 1 depending on whether

Re: [R] Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-06 Thread Eric Berger
e(j=Var1,k=Var2) |> filter(j < k) u <- sapply(1:nrow(idx), \(i){ j <- idx$j[i]; k <- idx$k[i]; A[j,k] <<- f(j,k,myData) }) B <- A + t(A) + diag(N) C <- diag(myData$Conc) D <- B %*% C D[D==0] <- NA myData$Conc_min <- apply(D,MAR=1,\(v){min(v,na.rm=TRUE)}) print

Re: [R] [External] Re: Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-07 Thread Eric Berger
on all points to get a list of minimum Conv > values for all points, and merge back to pts. > > > # Now apply this function to all points in pts > Conc_min <- lapply(pts$X, function(i){ >MinConc(i, dist_matrix[i], pts) > }) > Conc_min <- data.frame("Conc_min&

Re: [R] [External] Re: Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-08 Thread Eric Berger
onc_min <- lapply(pts$X, function(i){ >MinConc(i, dist_matrix[i], pts) > #}) > Conc_min <- data.frame("Conc_min" = as.integer(Conc_min)) > > # Add back as new attrib to original points sf object > pts_with_min <- do.call(cbind, c(pts, Conc_min)) > > > >

Re: [R] IGCI implemented in R package ?

2022-11-21 Thread Eric Berger
Hi Sacha, My search turned up the Causal Discovery Toolbox which includes IGCI among 10 (or more) methods. This site includes both Python and R resources and seems to be quite rich - hopefully you will find something useful. Here's the link: https://fentechsolutions.github.io/CausalDiscoveryToolbox

Re: [R] What is new in R especially about Tidyverse.

2022-11-27 Thread Eric Berger
Hi Abdullah, The Tidyverse is a set of R packages that are designed to work well together for handling a variety of common tasks in data science. Many of these packages are written by Hadley Wickham, chief scientist at RStudio.com. https://en.wikipedia.org/wiki/Hadley_Wickham RStudio.com is a com

Re: [R] is.na()<- on a character vector

2022-12-16 Thread Eric Berger
maybe this will make it clear x <- c(a=1, b=5) is.na(x) <- "b" i.e. your second case is dealing with a named vector HTH, Eric On Fri, Dec 16, 2022 at 8:29 PM Göran Broström wrote: > I'm confused: > > > x <- 1:2 > > is.na(x) <- 1 > > x > [1] NA 2 > > OK, but > > > x <- c("A", "B") > > is.na(

Re: [R] Amazing AI

2022-12-19 Thread Eric Berger
Hi Boris, I think these are good questions. Some initial reactions: 1. with better tools available to the students, you can cover more material at a faster pace 🙂 2. For years, it has been possible for students to find "answers" online (e.g. Google search). Most programmers would regard this as an

Re: [R] Reg: Help in assigning colors to factor variable in ggplot2

2022-12-26 Thread Eric Berger
Your problem is that the color "#4DAF4A8" is not a valid color. It should have only 6 hex digits. e.g. "#4DAF4A" will work. Also you seem to be confused about ggplot. You are not using ggplot in your code at all. You are using base graphics. You can remove the 3 library calls. HTH, Eric On Mon,

Re: [R] Reg: ggplot error

2023-01-11 Thread Eric Berger
No code or data came through. Please read the posting guidelines. On Wed, Jan 11, 2023 at 1:38 PM Upananda Pani wrote: > > Dear All, > > I am using roptest function of package "ROptEst" (Kohl and Ruckdeschel > (2019)) to find out the ML, CvM-MD, and the RMX estimator and their > asymptotic conf

Re: [R] Topological network Map

2023-01-11 Thread Eric Berger
Google using "R package subway map" produced https://www.r-bloggers.com/2021/01/non-hierarchical-edge-bundling-flow-maps-and-metro-maps-in-r/ which looks promising On Wed, Jan 11, 2023 at 2:48 PM Nick Wray wrote: > > Hello I'd like to create a simple topological map of a river system, ie all > t

Re: [R] Removing variables from data frame with a wile card

2023-01-13 Thread Eric Berger
mydata[, -grep("^yr",colnames(mydata))] On Sat, Jan 14, 2023 at 8:57 AM Steven T. Yen wrote: > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild cardsomething similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) >[1] "yea

Re: [R] Printing special characters

2023-01-16 Thread Eric Berger
How about just 'EVENT > 30 sec' or 'EVENT > 29 sec' ? On Mon, Jan 16, 2023 at 10:19 AM Dennis Fisher wrote: > R 4.2.2 > OS X > > Colleagues > > A file that I have read includes strings like this: > "EVENT ≥ 30 sec" > When I include the string in a graphic using: > mtext(STRING,

Re: [R] Fwd: Reg: Frequency in declaring time series data

2023-01-17 Thread Eric Berger
Hi Upananda, A few comments: 1. As you know, CRAN has thousands of packages. One of the ways to learn about the packages you might care about is to use the CRAN views. A 'view' is an attempt to provide some information on a certain subset of the packages related to a particular area. See a list of

Re: [R] Problem to run python code in r markdown

2023-01-20 Thread Eric Berger
You don't specify what platform you are on (linux / Windows / other), and what tools you are using. I am running a linux system and I have virtual environments set up. I set the environment variable RETICULATE_PYTHON to point to python (in my virtual environment). I am using RStudio, and I use the

Re: [R] Detpack package

2023-02-01 Thread Eric Berger
Detpack or detpack? What happens when you try detpack::chi2testuniform(...) ? On Wed, Feb 1, 2023 at 6:08 PM Nick Wray wrote: > Hello I've successfully installed the package "Detpack" and remembered to > call it via library() But when I try to use the functions i get this: > > > chi2testuni

Re: [R] Simple Stacking of Two Columns

2023-04-03 Thread Eric Berger
pivot_longer() Sent from my iPhone > On 3 Apr 2023, at 18:09, Sparks, John wrote: > > Hi R-Helpers, > > Sorry to bother you, but I have a simple task that I can't figure out how to > do. > > For example, I have some names in two columns > > NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2

Re: [R] Matrix scalar operation that saves memory?

2023-04-11 Thread Eric Berger
One possibility might be to use Rcpp. An R matrix is stored in contiguous memory, which can be considered as a vector. Define a C++ function which operates on a vector in place, as in the following: library(Rcpp) cppFunction( 'void subtractConst(NumericVector x, double c) { for ( int i = 0; i

Re: [R] converting to date object...

2023-04-12 Thread Eric Berger
lubridate::dmy("12 APR 2023") On Wed, Apr 12, 2023 at 5:34 PM akshay kulkarni wrote: > dear members, > I want to convert "12 APR 2023" into a Date > object. I tried as_Date() from lubridate, but it is not working: > > > as_date("12 APR 2023") > [1] NA > Warning messa

Re: [R] Split String in regex while Keeping Delimiter

2023-04-12 Thread Eric Berger
This seems to do the job but there are probably more elegant solutions: f <- function(s) { sub("^ ","",unlist(strsplit(gsub("\\+ ","+@ ",s),"@"))) } g <- function(s) { sub("^ ","",unlist(strsplit(gsub("- ","-@ ",s),"@"))) } h <- function(s) { g(f(s)) } To try it out: s <- “leucocyten + gramnegati

Re: [R] Package Caret

2023-04-13 Thread Eric Berger
You first have to load the package using the library command. > library(caret) Then you can call createDataPartition. e.g. > data(oil) > createDataPartition(oilType,2) HTH, Eric On Fri, Apr 14, 2023 at 7:52 AM Gábor Malomsoki wrote: > Dear all, > When i try to use createDataPartition after ca

Re: [R] Package Caret

2023-04-14 Thread Eric Berger
king. > I saw a similar question in Stackoverflow, advising install package Rcpp, > but this one i am unable to install. > > Eric Berger schrieb am Fr., 14. Apr. 2023, 08:47: > >> You first have to load the package using the library command. >> > library(caret) >

Re: [R] Package Caret

2023-04-14 Thread Eric Berger
Malomsoki wrote: > Or is there any similar function to split the dataframe to trainDF and > testDF? > > Gábor Malomsoki schrieb am Fr., 14. Apr. 2023, > 09:45: > >> >> This is the error then: >> error in prettyseq(1:ncol(out)) : could not find function "prett

Re: [R] problem installing RGBL library

2023-04-22 Thread Eric Berger
What happens with the command > library(RBGL) On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help wrote: > Dear R-experts, > > How to solve that problem? > > My R version is 4.2.1 > > Here below trying to install RGBL library found here : > https://bioconductor.org/packages/release/bioc/htm

Re: [R] problem installing RGBL library

2023-04-22 Thread Eric Berger
, table, > tapply, union, unique, unsplit, which.max, > which.min > > > Attaching package: ‘graph’ > > The following objects are masked from ‘package:igraph’: > > degree, edges, intersection > > > Attaching package: ‘RBGL’ > > The following objects are ma

Re: [R] combining data.frames with is.na & match (), two questions

2019-04-18 Thread Eric Berger
Hi Drake, Petr's suggestion to use the merge() function is good. Another (possibly overkill) approach is to use functions from the dplyr package, which is a fantastic package to get familiar with. For example, the last alternative that Petr suggests is an example of what is called a "left join" (me

Re: [R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread Eric Berger
df$ClaimManagerID[ !(df$ClaimManagerID %in% c(1565,1569,1674,415,1564))] <- 0 On Thu, Apr 18, 2019 at 3:39 PM Bill Poling wrote: > Good morning. > > #RStudio Version 1.1.456 > sessionInfo() > #R version 3.5.3 (2019-03-11) > #Platform: x86_64-w64-mingw32/x64 (64-bit) > #Running under: Windows >=

Re: [R] troubles with foreign:read.dbf

2019-04-20 Thread Eric Berger
You seem to have a typo. In the case that works your filename is "Mailles_2011a.dbf" but in the case that fails your filename is "Mailles_2011a.shp" (different extensions) HTH, Eric On Sat, Apr 20, 2019 at 8:00 PM Patrick Giraudoux < patrick.giraud...@univ-fcomte.fr> wrote: > Dear listers, > >

Re: [R] Loading EDF files

2019-05-03 Thread Eric Berger
Hi Mariano, The problem appears to be that samples[[sn]] has zero length (or is NULL). Consider the following code which gives the same error message. x <- 1:10 x[1:5] <- as.numeric(NULL) Error in x[1:5] <- as.numeric(NULL) : replacement has length zero HTH, Eric On Fri, May 3, 2019 at 4:32 PM M

Re: [R] The function sink() --delete everything before printing by "sink()"

2019-05-06 Thread Eric Berger
?sink for the HELP page on that sink() function. Check the description of the (optional) argument append to get an answer to your question. On Mon, May 6, 2019 at 5:24 AM John wrote: > I use the functions "sink" and "print" to print the results to a txt file. > May I delete everything in the tx

Re: [R] Question concerning Loading large Data Sets

2019-05-07 Thread Eric Berger
I don't think I understand your question. What if you enter class(anno) Does that give anything? On Mon, May 6, 2019 at 2:29 AM David Winsemius wrote: > I wouldn’t have expected an message, but it does raise the question: why > are you making two different copies of the same text file if you

Re: [R] install R

2019-05-08 Thread Eric Berger
Do a web search such as "ubuntu install fortran" (or replace ubuntu by your distribution if it's different, e.g. debian or centos or ..) e.g. the above search gives a result of the following link which provides the appropriate commands https://fossnaija.com/how-to-install-fortran-compiler-in-linu

Re: [R] A question on generating Error message upon Timeout

2019-05-11 Thread Eric Berger
Hi Christofer, You have a number of misunderstandings. The first thing you could have tried in order to figure out what was going on was to remove the 'silent=TRUE' from the call to try(). This would then give you extra information, specifically that there was a timeout. The exact message that gets

Re: [R] reg expr that retains only bracketed text from strings

2019-06-12 Thread Eric Berger
Hi Nevil, Here's one way to do it. (No doubt some regular-expression-gurus will have more concise ways to get the job done.) a1 <- sub(".*\\(","\\(",mystrings) a2 <- sub("\\).*","\\)",a1) a2[grep("\\(",a2,invert=TRUE)] <- "" a2 HTH, Eric On Wed, Jun 12, 2019 at 8:46 AM nevil amos wrote: > H

Re: [R] Help with a third ggplot error

2019-06-15 Thread Eric Berger
Is this supposed to be a reprex? I don't see where train_tbl is defined. On Fri, Jun 14, 2019 at 10:30 PM Bill Poling wrote: > #RStudio Version 1.2.1335 > sessionInfo() > #R version 3.5.3 (2019-03-11) > #Platform: x86_64-w64-mingw32/x64 (64-bit) > #Running under: Windows >= 8 x64 (build 9200) >

Re: [R] Help with a third ggplot error

2019-06-15 Thread Eric Berger
looking for split to be 3 months from the end of current time > period. etc depends on our date period > > train_tbl <- dftmp %>% > filter(Date2 < ymd(train_test_split_date)) > > test_tbl <- dftmp %>% > filter(Date2 >= ymd(train_test_split_date)) > &g

Re: [R] Add transitivity to a matrix?

2019-06-18 Thread Eric Berger
Very nice, Peter. Here is one version of Peter's suggestion expressed in R code M <- M | t(M) # first step as symmetric matrix as stated by OP Q <- M for ( i in 2:(ncol(Q)-1) ) Q <- Q + Q %*% M R <- (Q > 0) R HTH, Eric On Tue, Jun 18, 2019 at 12:46 PM peter dalgaard wrote: > Sounds like

Re: [R] Add transitivity to a matrix?

2019-06-18 Thread Eric Berger
That's what my code does. On Tue, Jun 18, 2019 at 4:27 PM Jeff Newmiller wrote: > Assuming Peter's equation applies, I think a direct for loop with > multiplication would be a more efficient way to obtain this answer than > repeated use of a power operator. > > On June 18, 2019 8:01:09 AM CDT, M

Re: [R] How to select max data according to week?

2019-06-19 Thread Eric Berger
Hi Siti, I didn't test Bert's code but I assume it's fine. :-) I would take a different approach than Bert. I prefer to use a package such as lubridate to handle the date wrangling, and a package such as dplyr to handle the grouping and max extraction. It may be overkill for this problem, but these

Re: [R] Regarding R doubt

2019-06-19 Thread Eric Berger
Hi Shreepad, >From the command 'summary(PL2.rasch)' it seems that PL2.rasch is an object. You don't provide enough details on how this object was created. What python or R packages? And what functions from those packages were used? Ideally you would provide a reproducible example, but even without

Re: [R] How to select max data according to week?

2019-06-19 Thread Eric Berger
thing. I do not know > which of us -- if either -- has interpreted her query correctly. > > Cheers, > Bert > > On Wed, Jun 19, 2019 at 2:35 AM Eric Berger wrote: > >> Hi Siti, >> I didn't test Bert's code but I assume it's fine. :-) >> I would

Re: [R] How to select max data according to week?

2019-06-19 Thread Eric Berger
2010-05-06 0.998 10 2010-05-07 2010-05-20 0.761 # ... with 69 more rows On Wed, Jun 19, 2019 at 5:08 PM Eric Berger wrote: > Hi Bert, > I agree that our interpretation is slightly different, which is why I > wrote: > "If one can take the actual week of the year as an acceptable

Re: [R] How to select max data according to week?

2019-06-20 Thread Eric Berger
282000-01-15 2000-01-09 > > and then use: > > > aggregate(O3_Conc ~ TimeStartDays, data = DF, max) > TimeStartDays O3_Conc > 12000-01-01 0.068 > 22000-01-15 0.042 > > > aggregate(O3_Conc ~ TimeStartWks, data = DF, max) > TimeStartWks O3_Con

Re: [R] Colour for unique label with ggplot

2019-06-20 Thread Eric Berger
Hi Phil, Try this library(tidyverse) # Test data dta <- data.frame(dta_names=c("Series 1","Series 2","Series 3","Series 4"), dta_values=c(0.5,1.3,-0.7,0.2)) dta$dta_names <- as.character(dta$dta_names) # convert from factor *dta$labelColor <- c("black","red","black","black")* # Bar chart ggplot(

Re: [R] Recovering former projects on R

2019-06-23 Thread Eric Berger
RStudio has a panel with a tab 'History' (that panel also has tabs 'Environment' and 'Connections'). If you click on the 'History' tab and can see your relevant history, you can then highlight commands of interest and click the 'To Console' button. This copies the highlighted commands to the consol

Re: [R] turning a list of objects into columns

2019-06-29 Thread Eric Berger
Hi Janet, I am not sure what your problem is. It seems that the code you wrote is doing what you want. The command 'head(tmp2$X1)' is outputting a numeric vector, not a list. Eric On Sat, Jun 29, 2019 at 9:28 PM Janet Choate wrote: > Hi, > I have a data frame that looks something like this (bu

Re: [R] StructTS hang? TiThe fact

2019-06-30 Thread Eric Berger
Nothing came through. Note that this is a plain text list and content that is not plain text may be stripped off (or mangled). On Sat, Jun 29, 2019 at 10:14 PM Don or Charlotte Smith wrote: > > > Sent from my iPhone > > __ > R-help@r-project.org mailin

Re: [R] Control the variable order after multiple declarations using within

2019-07-03 Thread Eric Berger
Hi Sebastien, Your 'within' command returns a dataframe. So without changing the call to within you have some options such as: df2 <- within(df, {b<-a*2; c<-b*3}) df2[c("a","b","c")] OR within(df, {b<-a*2; c<-b*3})[c("a","b","c")] OR within(df, {b<-a*2; c<-b*3})[c(1,3,2)] HTH, Eric On We

Re: [R] Control the variable order after multiple declarations using within

2019-07-03 Thread Eric Berger
Nice suggestion, Richard. On Wed, Jul 3, 2019 at 4:28 PM Richard O'Keefe wrote: > Why not set all the new columns to dummy values to get the order you > want and then set them to their final values in the order that works > for that? > > > On Thu, 4 Jul 2019 at 00:12, Kevin Thorpe > wrote: > >

Re: [R] Adding column values based on a condition

2019-07-06 Thread Eric Berger
# create some test data df <- data.frame( id=101:105, author_id=25:21, parent_id=c(NA,NA,101,NA,NA) ) df$parent_author_id <- sapply(1:nrow(df), function(i) { if( !is.na(df$parent_id[i]) ) { j <- match(df$parent_id[i],df$id); df$author_id[j] } else NA } ) df # id author_id parent_

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
Change the definition of de to de <- data.frame(d,e,stringsAsFactors=FALSE) Then you should be ok. Some additional remarks: 1. The ifelse() command is a bit tricky in R. Avoiding it is often a good policy. 2. I find %in% very useful. You could replace the multiple conditions check de$d=="-

Re: [R] Warning: Error in *: non-numeric argument to binary operator

2019-07-10 Thread Eric Berger
Well, for example > "a" + 2 Error in "a" + 2 : non-numeric argument to binary operator On Wed, Jul 10, 2019 at 2:36 PM Tolulope Adeagbo wrote: > Dear All, > > Please what could be the cause of this error, I created a GUI with shiny R > and it throws this error. > But running it alone in R, it

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
For example, can you predict what the following code will do? > a <- 1:5 > b <- c(2,3) > ifelse( a < 3, 1, b) On Wed, Jul 10, 2019 at 4:34 PM José María Mateos wrote: > On Wed, Jul 10, 2019, at 04:39, Eric Berger wrote: > > 1. The ifelse() command is a bit tricky i

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
o be a single number, either 1 or 2 (unless you know the "shape" of a). I've been burned by such issues. On Wed, Jul 10, 2019 at 4:42 PM Eric Berger wrote: > For example, can you predict what the following code will do? > > a <- 1:5 > > b <- c(2,3) > >

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
y tricky thing I see is that R has > a strict vectorised ifelse(logical.vector, some.vector, another.vector) > AND > a non-strict non-vectorised if (logical.scalar) some.value else > another.value > AND > a statement form if (logical.scalar) stmt.1; else stmt.2; > > > On Thu, 11 J

Re: [R] tidyr gather(function)

2019-07-16 Thread Eric Berger
tempDat.long <- gather(data=tempDat, key=month, value=temp, "Jan", "Feb","Mar", "Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") %>% dplyr::mutate( monthIndex=match(month,month.abb)) %>% dplyr::arrange( Year, monthIndex) %>%

Re: [R] How to rename file names with condition

2019-07-23 Thread Eric Berger
Assuming you have the vector of .xlsx file names as oldFilenames then newname <- function(oldname) { yr <- substr(oldname,7,10) m <- as.numeric(substr(oldname,11,12)) mo <- as.integer( m/3 + 1 - 0.1 ) i <- c(3,1,2)[ m%%3 + 1 ] sprintf("Domain%s-%d-%d.txt",yr,mo,i) } for ( s in oldFi

Re: [R] Modelos neural netwok

2019-07-28 Thread Eric Berger
Hi Richard, Nice comment on how authors use examples to show *how* to use a particular method, not necessarily *when* to use a particular method (or which method to use). Good to keep in mind. Thanks for sharing. On Sun, Jul 28, 2019 at 11:30 AM Michael Dewey wrote: > Hay una lista en castellan

Re: [R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-28 Thread Eric Berger
Hi Anuj, I am providing comments regarding your first attempt to call mapply. Since you are working with named arguments, you shouldn't need to include the NULLs in the call. Also you have provided the argument MoreArgs twice, which is what is causing the Error message. You can replace that call wi

Re: [R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-28 Thread Eric Berger
oreArgs=list("theme=ct")) > mapply (chart_Series, mget(symVec), name=infoVec, > MoreArgs=list(quote("pars=cp"),quote("theme=ct"))) > mapply (chart_Series, mget(symVec), name=infoVec, > MoreArgs=list(quote("theme=ct"))) > > On Sun, Jul 28, 20

Re: [R] How to create a new column based on the values from multiple columns which are matching a particular string?

2019-07-29 Thread Eric Berger
You may have a typo/misstatement in your question. You define a data frame with 5 columns, each of which has 10 elements, so your data frame has dimensions 10 x 5. Then you request a new COLUMN which will have only 5 elements, which is not allowed. All columns of a data frame must have the same len

Re: [R] How to create a new column based on the values from multiple columns which are matching a particular string?

2019-07-29 Thread Eric Berger
=c("C","A","D","D","B","A",NA,NA,"A","B"), > eye_problemsdisorders_f6148_0_4=c("D","D",NA,"B","A","C",NA,"C","A","B"), > eye_problem

Re: [R] How to create a new column based on the values from multiple columns which are matching a particular string?

2019-07-29 Thread Eric Berger
Read the help for apply and %in% ?apply ?%in% Sent from my iPhone > On 29 Jul 2019, at 22:23, Ana Marija wrote: > > Thank you so much! Just to confirm here MARGIN=1 indicates that "A" should > appear at least once per row? > >> On Mon, Jul 29, 2019 at 1:53 PM

Re: [R] Connect to Oracle database via ODBC

2019-08-05 Thread Eric Berger
Hi Ahson, Many people use R via RStudio, an IDE that has both free and non-free versions. RStudio has invested a lot of effort into making it easier to establish connections to databases. If this sounds of interest to you, take a look at https://db.rstudio.com/ HTH, Eric On Mon, Aug 5, 2019 at 2

Re: [R] shinyWidgets::sliderTextInput

2019-08-06 Thread Eric Berger
Hi Sigbert, Just leave out the '=...', as in sliderTextInput('myinput', choices=list("choice1", "choice2", "choice3") ) HTH, Eric On Tue, Aug 6, 2019 at 10:52 AM Sigbert Klinke wrote: > Hi, > > I'am using > > sliderTextInput('myinput', choices=list("choice1"=1, "choice2"=2, > "choice3"=3))

<    1   2   3   4   5   6   >