Re: [R] Exceptional slowness with read.csv

2024-04-08 Thread jim holtman
Try reading the lines in (readLines), count the number of both types of quotes in each line. Find out which are not even and investigate. On Mon, Apr 8, 2024, 15:24 Dave Dixon wrote: > I solved the mystery, but not the problem. The problem is that there's > an unclosed quote somewhere in those 5

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread jim holtman
Try this: > x <- file("C:\\Users\\Jim\\Downloads\\PV2-ch2 - R_Help.ANA",+ > encoding = "UTF-16")> y <- readLines(x)> head(y)[1] "1\t36,74\t0" > "2\t269,02\t-44" "1\t326,62\t29""2\t354,52\t24"

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread jim holtman
checkout the 'officer' package Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Fri, Dec 29, 2023 at 10:14 AM Andy wrote: > Hello > > I am trying to work through a problem,

Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread jim holtman
try using 'lubridate' > library(lubridate)Attaching package: ‘lubridate’ The following objects are masked from ‘package:base’: date, intersect, setdiff, union > x <- "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28 10:35:00 UTC" > Than

Re: [R] Sum data according to date in sequence

2023-11-03 Thread jim holtman
2:00", "8:58"), EnergykWh = c(4.680496, 6.272414, 1.032782, 11.004884, 10.096824, 6.658797, 4.808874, 1.469384, 2.996239, 0.303222, 4.988339, 8.131804, 0.117156, 3.285669, 1.175608, 3.677487, 1.068393, 8.820755, 8.138583, 9.0575)), row.names = c(NA, 20L), class = "dat

Re: [R] Sum data according to date in sequence

2023-11-02 Thread jim holtman
How about send a 'dput' of some sample data. My guess is that your date is 'character' and not 'Date'. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.*

Re: [R] How to Reformat a dataframe

2023-10-28 Thread jim holtman
2 ...6 61.019 2 ...7 63.020 2 ...8 93.0 > Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Fri, Oct 27, 2023 at 10:41 PM Paul Bernal wrote: > Hi Iris, > > Thank you so mu

Re: [R] query in loops

2022-12-05 Thread jim holtman
So what is the problem that you would like help in correcting? The program seems to run. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Mon, Dec 5, 2022 at 12:59 PM ASHLIN VARKEY wrote

Re: [R] Converting a Date variable from character to Date

2022-09-29 Thread jim holtman
.Period CPI. date ## 1 2022m1 4994 2022-01-01 ## 2 2022m2 5336 2022-02-01 ## 3 2022m3 5671 2022-03-01 ## 4 2022m4 6532 2022-04-01 ## 5 2022m5 7973 2022-05-01 ## 6 2022m6 10365 2022-06-01 ## 7 2022m7 12673 2022-07-01 ## 8 2022m8 14356 2022-08-0

Re: [R] How long does it take to learn the R programming language?

2022-09-29 Thread jim holtman
Still at it after 38 years. First came across S at Bell Labs in 1984. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Thu, Sep 29, 2022 at 7:09 AM Ebert,Timothy Aaron wrote: > Learnin

Re: [R] able to estimate in the excel but not in R, any suggestion?

2021-12-23 Thread jim holtman
Glad to help! Happy Holidays Thanks Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Wed, Dec 22, 2021 at 11:12 PM Marna Wagley wrote: > > Dear Jim, > Thank you very much for the help. The code

Re: [R] able to estimate in the excel but not in R, any suggestion?

2021-12-22 Thread jim holtman
2 0.682 51.284 69.985 52.46340 3 0.741 51.249 75.914 56.96310 4 0.394 51.200 40.303 30.25918 5 0.200 51.137 20.493 15.34110 6 0.655 51.059 66.905 50.16535 7 0.375 50.968 38.185 28.66948 > Thanks Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what yo

Re: [R] for loop question in R

2021-12-22 Thread jim holtman
%>%filter(hwy <35) %>% print(ggplot(aes(x = displ, y = y[i], color = c[i])) + geom_point()) ggsave("c:/temp/f[i].jpg",width = 9, height = 6, dpi = 1200, units = "in") } Thanks Jim Holtman Data Munger Guru What is the problem that you are trying to sol

Re: [R] Changing time intervals in data set

2021-12-15 Thread jim holtman
At least show a sample of the data and then what you would like as output. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Wed, Dec 15, 2021 at 6:40 AM Rich Shepard wrote: > A 33-year set

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread jim holtman
drop the select, or put tz in the select Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Mon, Nov 1, 2021 at 3:39 PM Rich Shepard wrote: > On Mon, 1 Nov 2021, CALUM POLWART wr

Re: [R] Looping through data error

2021-04-13 Thread jim holtman
x27;if/else' i <- 0 for (i in 1:(nrow(PLC_Return) - 1)) { if (i == 1) { NUMBER_OF_SHARES[i] = 100 / is.na(CLOSE_SHARE_PRICE[i]) } else { if (is.na(PLC_Return[i, 1]) == is.na(PLC_Return[i + 1, 1]) { NUMBER_OF_SHARES[i] = 0 } else { NUMBER_OF_SHARES[i] = 100 / is

Re: [R] Read

2021-02-22 Thread jim holtman
ub(.x[i], -1))] <- .x[i] + } + result + })) > > # now add commas to convert to CSV > x_csv <- apply(x_matrix, 1, paste, collapse = ',') > > # now read in and create desired output > read_csv(x_csv) # A tibble: 6 x 4 x1 x2x3x4 1 1 B12 2

Re: [R] Read

2021-02-22 Thread jim holtman
It looks like we can look at the last digit of the data and that would be the column number; is that correct? Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. Jim Holtman Data Munger Guru What is the problem

Re: [R] Read

2021-02-22 Thread jim holtman
sed to the 'fixed' field? Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Mon, Feb 22, 2021 at 5:00 PM jim holtman wrote: > Try this: > > > library(tidyverse) > > > tex

Re: [R] Read

2021-02-22 Thread jim holtman
olumns literal data 5 -- 4 columns 2 columns literal data 6 -- 4 columns 3 columns literal data > mydata # A tibble: 6 x 4 x1 x2x3x4 1 1 B12 NANA 2 2 C23 NANA 3 322 B32 D34 NA 4 4 D44 NANA 551 D53 NANA 660 D62 NANA &g

Re: [R] Get 3 values not only 1

2021-01-27 Thread jim holtman
nce <-mean((ypred- mean(ypred))^2) + + lst[[i]] <- c(MSE = MSE, +biais = biais, +variance = variance) + # lst[i]<-MSE + # lst[i]<-biais + # lst[i]<-variance + + } > > # convert to a matrix > > x <- as.matrix(do.call(rbind, lst))

Re: [R] seq.Date when date is the last date of the month

2021-01-07 Thread jim holtman
yes it is the expected behaviour is you check the documentation: Using "month" first advances the month without changing the day: if this results in an invalid day of the month, it is counted forward into the next month: see the examples. Jim Holtman Data Munger Guru What is the pr

Re: [R] Error: Discrete value supplied to continuous variable

2020-12-28 Thread jim holtman
ymin, fill=factor(job))) + Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to d

Re: [R] Replace double slashes with single backslash

2020-12-28 Thread jim holtman
Why do you want to replace '\\' with '\' in the file names? They are actually single '\' in the character string, but are printing out as '\\'. see example below: > x <- 'a\\b' > x [1] "a\\b" > nchar(x) [

Re: [R] fusion of two matrices (numerical and logical)

2020-09-18 Thread jim holtman
os > result <- array(0, dim = dim(B)) > > # get the indices of values to replace > indx <- which(C, arr.ind = TRUE) > > result[indx] <- B[indx] > > result [,1] [,2] [,3] [,4] [1,]1600 [2,]2 000 [3,]3000 [4,]4

Re: [R] Help with locating error on import of data

2020-06-23 Thread jim holtman
one of the problems with Excel is that people can put anything in any column. You might want to restrict which columns you are reading since if it finds data in some cells and there is not a header, it will create one. Jim Holtman Data Munger Guru What is the problem that you are trying to

Re: [R] Creating file from raw content

2020-06-01 Thread jim holtman
, 'wb') writeBin(excel_file, output) close(output) === Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to

Re: [R] Conditions in R (Help Post)

2019-10-22 Thread jim holtman
# another way of doing it by constructing an integer to be used as > # index for the phase value based on the evaluation of X<0, Y<0 and Y > index <- with(input, + (X < 0) * 4 + (Y < 0) * 2 + (Y < X) + ) > > phase_val <- c(6, 5, 4, 3, 8, 7, 2, 1) > >

Re: [R] Conditions in R (Help Post)

2019-10-22 Thread jim holtman
X > 0 & Y < 0 & Y < X ~ 'phase=3', X > 0 & Y < 0 & Y > X ~ 'phase=4', X > 0 & Y > 0 & Y > X ~ 'phase=6', X > 0 & Y > 0 & Y < X ~ &

Re: [R] Conditions in R (Help Post)

2019-10-22 Thread jim holtman
t; 0 & Y < X ~ 'phase=5', TRUE ~ 'unknown' ) ) > input # A tibble: 2 x 6 YEAR DAY X Y Sig phase 1 1981 9 -0.213 1.08 1.1 phase=8 2 198110 0.065 1.05 1.05 phase=6 Jim Holtman *Data Munger Guru* *What is t

Re: [R] Query about calculating the monthly average of daily data columns

2019-10-20 Thread jim holtman
112 199401 0.000533 6112 199402 0.000593 7112 199403 0.000471 8112 199404 0.000587 9113 199401 0.000692 10113 199402 0.000591 11113 199403 0.000677 12 113 199404 0.000555 > Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me

Re: [R] Installing multiple packages fails

2019-08-09 Thread jim holtman
The first parameter needs to be a character vector: install.packages(c("Blossom","INLA","RTisean","RcppProgress","STRbook", "askpass","classInt","ellipsis","generics","lpSolve"," odesolve&qu

Re: [R] Structuring data for Correspondence Analysis

2019-03-29 Thread jim holtman
I am not familiar with SAS, so what did you want your output to look like. There is the 'table' function that might do the job and then there is always 'dplyr' which can do the hard stuff. So we need more information on what you want. Jim Holtman *Data Munger Guru* *What

Re: [R] aggregate output to data frame

2019-03-29 Thread jim holtman
You can also use 'dplyr' library(tidyverse) result <- pcr %>% group_by(Gene, Type, Rep) %>% summarise(mean = mean(Ct), sd = sd(Ct), oth = sd(Ct) / sqrt(sd(Ct)) ) Jim Holtman *Data Munger Guru* *What is the problem that you are tryi

Re: [R] loop through columns in a data frame

2019-03-25 Thread jim holtman
1 1 0 0 1 3 2 3 2 1 3 3 0 0 1 2 3 1 3 3 1 2 0 1 1 1 1 2 1 1 2 2 1 1 1 3 3 3 1 1 1 1 0 1 1 1 2 1 2 2 2 2 1 1 0 1 3 2 3 1 1 3 1 0 1 3 1 1 1 3 3 2 1 1 0 1 1 1 2 3 3 3 1 1 0 1-10 of 10 rows | 1-10 of 11 columns Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell m

Re: [R] Purr and Basic Functional Programming Tasks

2019-01-25 Thread jim holtman
g_rate 1 2001 7869288. EU28-Egypt -0.148 2 2003 6395999. EU28-Egypt -0.120 3 2001 19851236. World-Egypt -0.0721 4 2003 16055014. World-Egypt -0.175 5 2001 11981948. Extra EU28-Egypt -0.0147 6 2003 9659015. Extra EU28-Egypt -0.207 > Jim Holtman *Data

Re: [R] Purr and Basic Functional Programming Tasks

2019-01-25 Thread jim holtman
orld-Algeria 35070922. [[2]] # A tibble: 3 x 2 relation tot 1 EU28-Egypt7692530. 2 Extra EU28-Egypt 11494855. 3 World-Egypt 19187385. > Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to

Re: [R] Using apply

2018-10-30 Thread jim holtman
> s2 <- apply(x*x, 2, sum) > s2 [1] 55 330 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Tue, Oct 30, 2018 at 10:28 PM Steven Yen wrote: > > I need help with "apply". Below,

Re: [R] date and time data on x axis

2018-10-28 Thread jim holtman
, vjust = 1.0, hjust = 1.0)) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.

Re: [R] Need to understand how to troubleshoot below error

2018-10-20 Thread jim holtman
and then follow that path to make sure that there is a directory there that you can write into. Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Sat, Oct 20, 2018 at 1:19 PM MEENA SUBRAMANIAN via R-help

Re: [R] read txt file - date - no space

2018-08-01 Thread jim holtman
day = floor_date(date, unit = 'day') + ) > > by_day <- input %>% + group_by(day) %>% + summarise(m_s1 = mean(str1), + m_s2 = mean(str2), + m_s3 = mean(str3) + ) > > by_day # A tibble: 1 x 4 day m_s1 m_s2 m_s

Re: [R] values of list of variable names

2018-06-01 Thread jim holtman
You probably want to use 'get': > r1 <- 5 > r2 <- 3 > r3 <- 45 > x <- ls(pattern = '^r.$') > x [1] "r1" "r2" "r3" > lapply(x, get) [[1]] [1] 5 [[2]] [1] 3 [[3]] [1] 45 > Jim Holtman Data Munger Guru What is

Re: [R] Convert daily data to weekly data

2018-05-29 Thread jim holtman
ng$date) > # average by ID/week > avg <- x_long %>% + group_by(ID, year, week) %>% + summarise(avg = mean(value)) > avg # A tibble: 6 x 4 # Groups: ID, year [?] ID year week avg 1 1 1986.1. 16.0 2 2 1986.1. 16.0 3 3 1986.1. 17.9 4

Re: [R] Convert daily data to weekly data

2018-05-29 Thread jim holtman
) %>% + summarise(avg = mean(value)) > avg # A tibble: 6 x 3 # Groups: ID [?] ID week avg 1 11. 16.0 2 21. 16.0 3 3 1. 17.9 4 41. 16.0 5 51. 17.9 6 61. 16.0 > Jim Holtman Data Munger Guru What is the problem that you

Re: [R] Split a data.frame

2018-05-19 Thread jim holtman
;- NULL for (i in seq_len(length(offsets) - 1)){ if (offsets[i + 1] - offsets[i] > 1){ # something inbetween ret_indx <- c(ret_indx, (offsets[i] + 1):(offsets[i+1] - 1)) } } DF[ret_indx, ] ## name val ## 3v 0 ## 4z 0 Jim Holtman Data Munger Guru What is the problem that y

Re: [R] Split a data.frame

2018-05-19 Thread jim holtman
ork. offsets <- match(split_str, DF$name) # Since you only want the rows in between DF[diff(offsets), ] ## name val ## 2v 0 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sat, May 19, 2018

Re: [R] how to write a loop to repetitive jobs

2018-04-18 Thread jim holtman
ot;) , head=TRUE ) input$id <- paste0("sn", x) input # return the input }) result <- do.call(rbind, result) # combine dataframes together ​ Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how

Re: [R] request for code

2018-01-18 Thread jim holtman
a simple Google search turns up several possible choices. There is a package 'matconv' that might serve your purposes. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Jan 18, 2018 at 7:49

Re: [R] dplyr - add/expand rows

2017-11-26 Thread jim holtman
ot;QMM", "07EA001" ,1972 , 1976 , "QMC", "07EA001" ,1977 , 1983 , "QRC" ) result <- input %>% rowwise() %>% do(tibble(station = .$station, year = seq(.$from, .$to), record = .$record) ) ###

Re: [R] function pointers?

2017-11-23 Thread jim holtman
{ + closureList[[i]] <- list(func = rnorm, n = nsize[i]) + } > format(object.size(closureList), units = "Mb") [1] "22.4 Mb" > pryr::compare_size(closureList) base pryr 23520040 2241776 You will notice that you get back a size that is 10X smaller because it is

Re: [R] dealing with a messy dataset

2017-10-05 Thread jim holtman
You should be able to use that header information to create the correct parameters to the read_fwf function to read in the data. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Oct 5, 2017 at 11:02

Re: [R] dealing with a messy dataset

2017-10-05 Thread jim holtman
0 -5.8 27.1 5.26 5.70 NA -182 2.4 # ... with 3 more variables: X15 , X16 , X17 > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Oct 5, 2017 at 10:12 AM, jean-philippe wrote: > dear R-

Re: [R] Calculating Weeks Since Last Event

2017-09-15 Thread jim holtman
flag[indx] <- NA x$flag <- zoo::na.locf(x$flag) # determine weeks since x$weeks_since <- ifelse(x$count != 0, x$count - x$flag + 1, 0 ) x # print out the result ## Jim Holtman Data Munger Guru What is the problem that you are trying to

Re: [R] Merge by Range in R

2017-09-04 Thread jim holtman
Have you tried 'foverlaps' in the data.table package? Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Sep 4, 2017 at 8:31 AM, Mohammad Tanvir Ahamed via R-help < r-help@r-project.org&

Re: [R] Has For bucle be impooved in R

2017-08-07 Thread jim holtman
x27; loop that account for the differences. I have attached the output of the profiler. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Aug 7, 2017 at 10:57 AM, Thierry Onkelinx wrote: > Dear Jesus, &g

Re: [R] Importing Big data to R

2017-07-12 Thread jim holtman
columns did the data have. How big was the file on disk. What other objects were in memory at the same time. The list can go on and on, so more information would be useful to understand the problem. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what

Re: [R] Extraneous full stop in csv read

2017-06-28 Thread jim holtman
$ mo : int 1 2 3 4 5 6 7 8 9 10 ... $ Data: int 8243 2265 2340 1014 1281 58 156 140 1087 322 ... $ in : num 8.24 2.27 2.34 1.01 1.28 ... Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Wed, Jun 28,

Re: [R] Extraneous full stop in csv read

2017-06-28 Thread jim holtman
895 1895 1895 1895 1895 1895 1895 ... $ mo : int 1 2 3 4 5 6 7 8 9 10 ... $ Data: int 8243 2265 2340 1014 1281 58 156 140 1087 322 ... $ in : num 8.24 2.27 2.34 1.01 1.28 ... Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how y

Re: [R] reading data

2017-06-13 Thread jim holtman
You need to provide reproducible data. What does the file contain? Why are you using 'sep=' when reading fixed format. You might be able to attach the '.txt' to your email to help with the problem. Also you did not state what the differences that you are seeing. So hel

Re: [R] Joining tables with different order and matched values

2017-05-14 Thread jim holtman
(input, 1, function(x){ + toString(intersect(str_extract_all(x[1], "[^,]")[[1]], + str_extract_all(x[2], "[^,]")[[1]] + )) + }) > > input A B shared values 1 1,2,5 3,8,7 2 2,4,6 7,6,3 6 Jim Holtman Data Munger Guru Wha

Re: [R] Return value from function with For loop

2017-04-16 Thread jim holtman
> xx <- function(n) n+1 > print(xx(3)) [1] 4 > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Apr 16, 2017 at 10:26 PM, Ramnik Bansal wrote: > In the code below > > >

Re: [R] help on readBin in R

2017-04-16 Thread jim holtman
75005b43 040 o n t e n t _ T y p e s ] . x m 6f6e74656e745f54797065735d2e786d Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Apr 16

Re: [R] taking a small piece of large tiff

2017-04-05 Thread jim holtman
if you have 8GB of memory it should be easy to handle. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Wed, Apr 5, 2017 at 3:23 AM, Louisa Reynolds wrote: > Ok. I have a tiff of size over 2GB. It cov

Re: [R] taking a small piece of large tiff

2017-04-04 Thread jim holtman
How big is 'large'? Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Tue, Apr 4, 2017 at 7:47 AM, Louisa Reynolds via R-help wrote: > Dear Forum > I am trying to cut out a small section o

Re: [R] Getting an unexpected extra row when merging two dataframes

2017-03-30 Thread jim holtman
you need to show what 'str' shows for the data structure Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Mar 30, 2017 at 12:08 AM, paulberna...@gmail.com wrote: > Dear Jim, > >

Re: [R] Getting an unexpected extra row when merging two dataframes

2017-03-29 Thread jim holtman
UE # prevent conversion to factors + ) > > str(dataset1) 'data.frame': 378 obs. of 2 variables: $ TransitDate: chr "1-Oct-85" "1-Nov-85" "1-Dec-85" "1-Jan-86" ... $ Transits : int 55 66 14 48 57 49 70 19 27 28

Re: [R] Display data by condition

2017-03-16 Thread jim holtman
you are probably missing a comma: View(data[data$fact > 5000, ]) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Mar 16, 2017 at 11:16 AM, Juan Ceccarelli Arias wrote: > Hello, > I nee

Re: [R] Beginner needs help with R

2017-02-06 Thread jim holtman
, seq(060054, 060060), sep = "") > seq1 [1] "DQ60054" "DQ60055" "DQ60056" "DQ60057" "DQ60058" "DQ60059" "DQ60060" > > # use 'sprintf' to create leading zeros > seq2 <- paste0("DQ", spri

Re: [R] Source into a specified environment

2017-01-09 Thread jim holtman
?sys.source Here is an example of the way I use it: # read my functions into a environment .my.env.jph <- new.env() .sys.source('~/C_Drive/perf/bin/perfmon.r', envir=.my.env.jph) attach(.my.env.jph) Jim Holtman Data Munger Guru What is the problem that you are trying to solve?

Re: [R] re attach into the killed R session

2016-12-18 Thread jim holtman
s that are important, and then I can reload at that point and carry forward. Also you will have the objects that you need to examine if you have too. If I had something running that long, I would at least take a checkpoint every hour to help in the debugging/recovery process. Jim Holtman Data Munger Gur

Re: [R] Question about proxy setting of R

2016-12-05 Thread jim holtman
You will probably have to check with your network folks to see what is possible on your system. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Dec 5, 2016 at 6:33 AM, wrote: > Dear Jim, > &g

Re: [R] data

2016-12-03 Thread jim holtman
+ , keyby = state + ] state nCities count 100's 200's 1: 1 3 7 4 3 2: 2 4 8 4 4 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sa

Re: [R] About data manipulation

2016-11-26 Thread jim holtman
just assign it to an object x<- DT . Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Nov 27, 2016 at 2:03 AM, lily li wrote: > Thanks Jim, this method is very convenient and is what

Re: [R] About data manipulation

2016-11-26 Thread jim holtman
You did not provide any data, but I will take a stab at it using the "dplyr" package library(dplyr) DT %>% group_by(month, id, note) %>% summarise(avg = mean(total)) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to

Re: [R] The code itself disappears after starting to execute the for loop

2016-11-03 Thread jim holtman
is full -- this might be the cause of your problem. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Nov 3, 2016 at 1:55 PM, Maram SAlem wrote: > Hi all, > > I've a question concerning

Re: [R] How to copy and paste a row at the end of each group of a table?

2016-10-31 Thread jim holtman
2 211 0.4 2.21 2 241 0.4 2.22 2 271 0.6 2.23 2 301 1.5 2.24 2 331 4.5 2.1312 361 9.0 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Oct 31, 2016 at 8:59 AM, Kristi Glover wr

Re: [R] difference

2016-10-28 Thread jim holtman
e > require(data.table) > setDT(input) # convert to data.table > input[, diff := Num - Num[1L], by = Year][] # print output Year Num diff 1: 2001 250 2: 2001 75 50 3: 2001 150 125 4: 2002 300 5: 2002 85 55 6: 2002 95 65 Jim Holtman Data Munger Guru What is the problem

Re: [R] difference

2016-10-28 Thread jim holtman
age:dplyr’: between, last > setDT(input) # convert to data.table > input[, diff := c(0, diff(Num)), by = Year][] # print output Year Num diff 1: 2001 250 2: 2001 75 50 3: 2001 150 75 4: 2002 300 5: 2002 85 55 6: 2002 95 10 > Jim Holtman Data Munger Guru What is

Re: [R] Reg : R : How to capture cpu usage, memory usage and disks info using R language

2016-10-17 Thread jim holtman
within the VBS script you can easily access remote computers. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Oct 17, 2016 at 5:58 AM, Manohar Reddy wrote: > Thanks Jim. > > > >

Re: [R] Reg : R : How to capture cpu usage, memory usage and disks info using R language

2016-10-16 Thread jim holtman
] "PercentProcessorTime: 18 processor:0" "PercentProcessorTime: 6 processor:1" [3] "PercentProcessorTime: 6 processor:2" "PercentProcessorTime: 0 processor:3" [5] "PercentProcessorTime: 7 processor:_Total" > > # Jim Holtman Da

Re: [R] Problem with sample(...,size = 1000000000,...)

2016-10-15 Thread jim holtman
I forgot to add that if you have less than 16GB of memory, then you were probably paging memory to disk and that would have take a much, much, longer time. When you are trying to do something BIG, do it in some smaller steps and look at the resources that it takes (memory, cpu, ...). Jim Holtman

Re: [R] Problem with sample(...,size = 1000000000,...)

2016-10-15 Thread jim holtman
lapsed 30.761.70 32.92 > memory.size() [1] 11502.52 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sat, Oct 15, 2016 at 12:19 PM, Huy Nguyễn wrote: > When I ran this code: > " > x<

Re: [R] lag, count

2016-10-15 Thread jim holtman
25137 4 2 0 2012-12-25 1 0 0 5 2 450 2014-09-15 2450629 6 2 750 2016-01-30 3300502 7 2 656 2016-11-30 4-94305 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to

Re: [R] Writing data onto xlsx file without cell formatting

2016-09-26 Thread jim holtman
I use the "openxlsx" package to handle spreadsheets. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Sep 26, 2016 at 5:56 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wr

Re: [R] how to remove all messages when loading a library ?

2016-09-25 Thread jim holtman
quot;,quietly=TRUE)) suppressMessages(install.packages("xlsx",quietly=TRUE)) if (!require("ROracle",quietly=TRUE)) suppressMessages(install.packages("T:/CH/R/ROracle_1.2-2.zip", repos = NULL, type = "source",quietly=TRUE)) }) Jim Holtman Data Munger Guru What

Re: [R] Accelerating binRead

2016-09-17 Thread jim holtman
rite reals close(output) library(pack) library(readr) # read all the data at once allbin <- read_file_raw('integer.bin') # decode the data into a list (result <- unpack("V V V V V V V V V V d d d d d d d d d d", allbin)) Jim Holtman Data Munger Guru What is the probl

Re: [R] Accelerating binRead

2016-09-17 Thread jim holtman
I would also suggest that you take a look at the 'pack' package which can convert the binary input to the value you want. Part of your performance problems might be all the short reads that you are doing. Jim Holtman Data Munger Guru What is the problem that you are trying to solv

Re: [R] Accelerating binRead

2016-09-17 Thread jim holtman
Your example was not reproducible. Also how do you "break" out of the "while" loop? Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sat, Sep 17, 2016 at 8:05 AM, Philippe de Rochamb

Re: [R] gsub: replacing slashes in a string

2016-09-14 Thread jim holtman
try this: > gsub("", "/", test) [1] "8/24/2016" "8/24/2016" "6/16/2016" "6/16/2016" Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. O

Re: [R] parsing the file

2016-08-28 Thread jim holtman
Here is an attempt at parsing the data. It is fixed field so the regular expression will extract the data. Some does not seem to make sense since it has curly brackets in the data. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not

Re: [R] parsing a complex file

2016-08-27 Thread jim holtman
It is not clear as to how you want to parse the file. You need to at least provide an example of what you expect from the output. You mention " the detail which begins with 2 at byte location 1 to another file"; I don't see the '2' at byte location 1. Jim Holtman Data

Re: [R] read.xlsx function crashing R Studio

2016-08-22 Thread jim holtman
try the openxlsx package Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Aug 21, 2016 at 1:30 PM, Kevin Kowitski wrote: > Hey everyone, > >I have used read.xlsx in the past ra

Re: [R] Conditionally remove rows with logic

2016-08-10 Thread jim holtman
L == 1) + if (length(indx) == 1) .id <- .id[1:indx, ] # keep upto the '1' + .id + }) + ) > > > result ID TIME LABEL 1.1 10 0 1.2 13 0 1.3 16 0 1.4 19 0 1.5 1 12 1 2.8 20 0 2.9 23 0 2

Re: [R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread jim holtman
s to see if anything refers to either "value" or "visible", and then you might find the cause of your problem. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Jul 29, 2016 at 6:52

Re: [R] Subtraction with aggregate

2016-07-28 Thread jim holtman
) > > > agg # A tibble: 3 x 3 subject QMyi 1 s1 57.8918 28.240036 2 s2 5.7602 4.077484 3 s3 -35.8694 2.666504 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to

Re: [R] Subtraction with aggregate

2016-07-28 Thread jim holtman
> > agg # A tibble: 3 x 3 subject QM yi 1 s1 46.1558 -90.04829 2 s2 -50.2313 -180.33473 3 s3 -50.9669 -136.08716 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to

Re: [R] about file name

2016-07-28 Thread jim holtman
add another step: (need to learn about regular expressions) > a [1] "X35.84375_.100.71875" > a.new <- sub("^.", '', a) > a.new [1] "35.84375_.100.71875" > sub("_.", "_-", a.new) [1] "35.84375_-100.71875" >

Re: [R] about file name

2016-07-28 Thread jim holtman
just strip off the first character: > a [1] "X35.84375_.100.71875" > a.new <- sub("^.", '', a) > a.new [1] "35.84375_.100.71875" > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do

Re: [R] means by year, month and day

2016-07-17 Thread jim holtman
1 4.5 269.7 6.45 7.21 1026.81 3.86 -3.6 3 2015 3 1 4.5 269.7 6.45 7.21 1026.81 3.86 -3.6 > Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Jul 17, 2016 at 5:42 PM, Jianlin

Re: [R] Difficulty subsetting data frames using logical operators

2016-07-01 Thread jim holtman
You may need to re-read the Intro to R. data[data$Ozone > 31,] or subset(data, Ozone > 31) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Jul 1, 2016 at 5:11 AM, Giles Bischoff wrote: &

  1   2   3   4   5   6   7   8   9   10   >