Re: [R] Extract estimate of error variance from glm() object

2024-12-25 Thread Gabor Grothendieck
If the family is Poisson or binomial and the dispersion= argument to summary is omitted then sigma is 1. See ?summary.glm On Tue, Dec 24, 2024 at 8:45 AM Christofer Bogaso wrote: > > Hi, > > I have below GLM fit > > clotting <- data.frame( > u = c(5,10,15,20,30,40,60,80,100), > lot1 = c(

Re: [R] Extract estimate of error variance from glm() object

2024-12-25 Thread Rui Barradas
Às 23:29 de 24/12/2024, Bert Gunter escreveu: ... but do note: glm(lot1 ~ log(u), data = clotting, family = gaussian) is a plain old *linear model*, which is of course a specific type of glm, but not one that requires the machinery of glm() to fit. That is, the above is exactly the same as: lm

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Bert Gunter
... but do note: glm(lot1 ~ log(u), data = clotting, family = gaussian) is a plain old *linear model*, which is of course a specific type of glm, but not one that requires the machinery of glm() to fit. That is, the above is exactly the same as: lm(lot1 ~ log(u), data = clotting) and gives exac

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Ben Bolker
?sigma On 12/24/24 10:13, Bert Gunter wrote: ?deviance ?anova Bert On Tue, Dec 24, 2024 at 6:22 AM Christofer Bogaso wrote: I think vcov() gives estimates of VCV for coefficients. I want estimate of SD for residuals On Tue, Dec 24, 2024 at 7:24 PM Ben Bolker wrote: vcov(). ? On Tu

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Bert Gunter
?deviance ?anova Bert On Tue, Dec 24, 2024 at 6:22 AM Christofer Bogaso wrote: > > I think vcov() gives estimates of VCV for coefficients. > > I want estimate of SD for residuals > > On Tue, Dec 24, 2024 at 7:24 PM Ben Bolker wrote: > > > > vcov(). ? > > > > > > On Tue, Dec 24, 2024, 8:45 AM C

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Christofer Bogaso
I think vcov() gives estimates of VCV for coefficients. I want estimate of SD for residuals On Tue, Dec 24, 2024 at 7:24 PM Ben Bolker wrote: > > vcov(). ? > > > On Tue, Dec 24, 2024, 8:45 AM Christofer Bogaso > wrote: >> >> Hi, >> >> I have below GLM fit >> >> clotting <- data.frame( >> u

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Ben Bolker
vcov(). ? On Tue, Dec 24, 2024, 8:45 AM Christofer Bogaso wrote: > Hi, > > I have below GLM fit > > clotting <- data.frame( > u = c(5,10,15,20,30,40,60,80,100), > lot1 = c(118,58,42,35,27,25,21,19,18), > lot2 = c(69,35,26,21,18,16,13,12,12)) > summary(glm(lot1 ~ log(u), data = clotti

[R] Extract estimate of error variance from glm() object

2024-12-24 Thread Christofer Bogaso
Hi, I have below GLM fit clotting <- data.frame( u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) summary(glm(lot1 ~ log(u), data = clotting, family = gaussian)) Is there any direct function to extract estimate of Error s

Re: [R] Extract

2024-07-22 Thread CALUM POLWART
But have we lured you to the dark side with the tidyverse yet ;-) On Mon, 22 Jul 2024, 15:22 Bert Gunter, wrote: > Thanks. > > I found this to be quite informative and a nice example of how useful > R-Help can be as a resource for R users. > > Best, > Bert > > On Mon, Jul 22, 2024 at 4:50 AM G

Re: [R] Extract

2024-07-22 Thread Gabor Grothendieck
I had missed that one can pass fix.empty.names = TRUE to transform and if we do that then we can put an unnamed data.frame in transform like we can with mutate so making that change we have the following base R solution where there is an inner nested pipeline within the outer pipeline as with the d

Re: [R] Extract

2024-07-22 Thread Bert Gunter
Thanks. I found this to be quite informative and a nice example of how useful R-Help can be as a resource for R users. Best, Bert On Mon, Jul 22, 2024 at 4:50 AM Gabor Grothendieck wrote: > > Base R. Regarding code improvements: > > 1. Personally I find (\(...) ...)() notation hard to read (alt

Re: [R] Extract

2024-07-22 Thread avi.e.gross
till but to evolve. -Original Message- From: R-help On Behalf Of Gabor Grothendieck Sent: Monday, July 22, 2024 7:49 AM To: Bert Gunter Cc: r-help@R-project.org (r-help@r-project.org) Subject: Re: [R] Extract Base R. Regarding code improvements: 1. Personally I find (\(...) ...)() nota

Re: [R] Extract

2024-07-22 Thread Gabor Grothendieck
Base R. Regarding code improvements: 1. Personally I find (\(...) ...)() notation hard to read (although by placing (\(x), the body and )() on 3 separate lines it can be improved somewhat). Instead let us use a named function. The name of the function can also serve to self document the code. 2.

Re: [R] Extract

2024-07-21 Thread Bert Gunter
As always, good point. Here's a piped version of your code for those who are pipe afficianados. As I'm not very skilled with pipes, it might certainly be improved. dat <- dat$string |> read.table( text = _, fill = TRUE, header = FALSE, na.strings = "") |> (\(x)'names<-'(x,p

Re: [R] Extract

2024-07-21 Thread Gabor Grothendieck
Fixing col.names=paste0("S", 1:5) assumes that there will be 5 columns and we may not want to do that. If there are only 3 fields in string, at the most, we may wish to generate only 3 columns. On Sun, Jul 21, 2024 at 2:20 PM Bert Gunter wrote: > > Nice! -- Let read.table do the work of handling

Re: [R] Extract

2024-07-21 Thread Bert Gunter
Nice! -- Let read.table do the work of handling the NA's. However, even simpler is to use the 'colnames' argument of read.table() for the column names no? string <- read.table(text = dat$string, fill = TRUE, header = FALSE, na.strings = "", col.names = paste0("s", 1:5)) dat <- cbind(da

Re: [R] Extract

2024-07-21 Thread Bert Gunter
I get no error. Please show the entirety of the code you used that produced the error. Also, are you using a current R version? I am, and if you are not, there might have been changes from your version to mine that caused the error. However, as you were already given satisfactory solutions before,

Re: [R] Extract

2024-07-21 Thread Gabor Grothendieck
We can use read.table for a base R solution string <- read.table(text = dat$string, fill = TRUE, header = FALSE, na.strings = "") names(string) <- paste0("S", seq_along(string)) cbind(dat[-3], string) On Fri, Jul 19, 2024 at 12:52 PM Val wrote: > > Hi All, > > I want to extract new variables fro

Re: [R] Extract

2024-07-21 Thread Val
Thank you Bert! However, the last line of the script. dat |> names() |> _[4:8] <- paste0("s", 1:5) is giving me an error as shown below Error: pipe placeholder can only be used as a named argument Thank you! On Sat, Jul 20, 2024 at 7:41 PM Bert Gunter wrote: > > Val: > I wanted to add here a

Re: [R] Extract

2024-07-20 Thread Bert Gunter
Val: I wanted to add here a base R solution to your problem that I realize you can happily ignore. However, in the course of puzzling over how to do it using the R native pipe syntax ("|>") , I learned some new stuff that I thought others might find useful, and it seemed sensible to keep the code w

Re: [R] Extract

2024-07-19 Thread Val
Thank you Jeff and Bert for your help! The components of the string could be nixed (i.e, numeric, character or date). Once that is splitted it would be easy for me to format it accordingly. On Fri, Jul 19, 2024 at 2:10 PM Bert Gunter wrote: > > I did not look closely at the solutions that you w

Re: [R] Extract

2024-07-19 Thread Bert Gunter
I did not look closely at the solutions that you were offered, but note that you did not specify in your post whether the numbers in your string were to be character or numeric variables after they are broken out into their own columns. I believe that they are character in the solutions, but you sh

Re: [R] Extract

2024-07-19 Thread Jeff Newmiller via R-help
Factors=FALSE) >> >> # split the 'string' column based on spaces >> dat_separated <- dat |> >> separate(string, into = paste0("S", 1:5), sep = " ", >>fill = "right", extra = "merge") >> >>

Re: [R] Extract

2024-07-19 Thread Val
ALSE) > > # split the 'string' column based on spaces > dat_separated <- dat |> > separate(string, into = paste0("S", 1:5), sep = " ", > fill = "right", extra = "merge") > > Tim > > > -Original Messag

Re: [R] Extract

2024-07-19 Thread Ebert,Timothy Aaron
= paste0("S", 1:5), sep = " ", fill = "right", extra = "merge") Tim -Original Message- From: R-help On Behalf Of Val Sent: Friday, July 19, 2024 12:52 PM To: r-help@R-project.org (r-help@r-project.org) Subject: [R] Extract [Externa

Re: [R] Extract

2024-07-19 Thread Robert Knight
I would split dat$string into it's own vector, break it apart at the spaces into an array, and then place dat$year and dat$sex in positions 1 and 2 of that newly created array. On Fri, Jul 19, 2024, 12:52 PM Val wrote: > Hi All, > > I want to extract new variables from a string and add it to

[R] Extract

2024-07-19 Thread Val
Hi All, I want to extract new variables from a string and add it to the dataframe. Sample data is csv file. dat<-read.csv(text="Year, Sex,string 2002,F,15 xc Ab 2003,F,14 2004,M,18 xb 25 35 21 2005,M,13 25 2006,M,14 ac 256 AV 35 2007,F,11",header=TRUE) The string column has a maximum of five va

Re: [R] extract parts of a list before symbol

2023-05-26 Thread avi.e.gross
e dimensions of a vector for example with dim() as well as get the current dimensions. -Original Message- From: R-help On Behalf Of Evan Cooch Sent: Friday, May 26, 2023 10:38 AM To: r-help@r-project.org Subject: Re: [R] extract parts of a list before symbol Many thanks to all. Wasn

Re: [R] extract parts of a list before symbol

2023-05-26 Thread Evan Cooch
numeric 1 -none- numeric c 1 -none- numeric This puts the variable name, if any, at the start but parsing that is not trivial as it is not plain text. Bottom line, try not to do things the hard way. Just carefully use names() ... -Original Message- From: R-help On Behalf O

Re: [R] extract parts of a list before symbol

2023-05-26 Thread Iris Simmons
You probably want `names(test)`. On Thu, May 25, 2023 at 7:58 PM Evan Cooch wrote: > Suppose I have the following list: > > test <- list(a=3,b=5,c=11) > > I'm trying to figure out how to extract the characters to the left of > the equal sign (i.e., I want to extract a list of the variable names,

Re: [R] extract parts of a list before symbol

2023-05-25 Thread avi.e.gross
not trivial as it is not plain text. Bottom line, try not to do things the hard way. Just carefully use names() ... -Original Message- From: R-help On Behalf Of Jeff Newmiller Sent: Thursday, May 25, 2023 10:32 PM To: r-help@r-project.org Subject: Re: [R] extract parts of a list before

Re: [R] extract parts of a list before symbol

2023-05-25 Thread Jeff Newmiller
n simple by looking at the attributes of your list: > >> attributes(test) >$names >[1] "a" "b" "c" > >> attributes(test)$names >[1] "a" "b" "c" >> attributes(test)$names[3] >[1] "c" > > >-Or

Re: [R] extract parts of a list before symbol

2023-05-25 Thread avi.e.gross
quot; To get one at a time: > names(as.vector(test))[1] [1] "a" You can do it even simple by looking at the attributes of your list: > attributes(test) $names [1] "a" "b" "c" > attributes(test)$names [1] "a" "b" "c"

Re: [R] extract parts of a list before symbol

2023-05-25 Thread Rolf Turner
On Thu, 25 May 2023 13:29:52 -0400 Evan Cooch wrote: > Suppose I have the following list: > > test <- list(a=3,b=5,c=11) > > I'm trying to figure out how to extract the characters to the left of > the equal sign (i.e., I want to extract a list of the variable names, > a, b and c. > > I've tri

[R] extract parts of a list before symbol

2023-05-25 Thread Evan Cooch
Suppose I have the following list: test <- list(a=3,b=5,c=11) I'm trying to figure out how to extract the characters to the left of the equal sign (i.e., I want to extract a list of the variable names, a, b and c. I've tried the permutations I know of involving sub - things like sub("\\=.*"

Re: [R] extract from a list of lists

2022-12-28 Thread Leonard Mada via R-help
Dear Terry, The following approach may be more suitable: fits <- lapply(argument, function) fits.df = do.call(rbind, fits); It works if all the lists returned by "function" have the same number of elements. Example: fits.df = lapply(seq(3), function(id) { list( beta = rnorm(1)

Re: [R] extract from a list of lists

2022-12-27 Thread Bill Dunlap
I find your original sapply(List, function(element)element$name) easy to understand. However replacing sapply with vapply makes for more robust code. vapply requires you to supply the expected mode (type) and length of element$name and if any of the elements don't comply with that, vapply gives a

Re: [R] extract from a list of lists

2022-12-27 Thread Therneau, Terry M., Ph.D. via R-help
Thanks everyone for prodding my gray matter, which seems to be getting stiffer as I approach 70 (< 90 days).  --  I'll continue to use the $ or [[ forms.   That will suffice. --  I thought there might be a base R variant, e.g. something like  extract( list, element-name); probably cross talk

Re: [R] extract from a list of lists

2022-12-27 Thread Bert Gunter
Well, I prefer Greg's approach, but if you want to avoid calls to $ or `[[` then you could do: unlist(fits)[ rep(names(fits[[1]]) == 'iter', length(fits))] Cheers, Bert On Tue, Dec 27, 2022 at 9:46 AM Greg Snow <538...@gmail.com> wrote: > > Another option is the map family of functions in the p

Re: [R] extract from a list of lists

2022-12-27 Thread Greg Snow
Another option is the map family of functions in the purrr package (yes, this depends on another package being loaded, which may affect things if you are including this in your own package, creating a dependency). In map and friends, if the "function" is a string or integer, then it is taken as th

Re: [R] extract from a list of lists

2022-12-27 Thread Greg Snow
Terry, I don't know if it is much cleaner or not, but you can use: sapply(fits, `[[`, 'iter') This calls the `[[` function (to extract list elements) on each element of the top list, with the extra argument of `iter` to say which element. On Tue, Dec 27, 2022 at 10:16 AM Therneau, Terry M., Ph

[R] extract from a list of lists

2022-12-27 Thread Therneau, Terry M., Ph.D. via R-help
I not uncommonly have the following paradym    fits <- lapply(argument, function) resulting in a list of function results.   Often, the outer call is to mclapply, and the function encodes some long calculation, e.g. multiple chains in an MCMC. Assume for illustration that each function returns

Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread Jim Lemon
Hi Roslina, I think you have changed the code as "bc_start" in my code is "BCStartTime" in yours. When I run the attached code, I get a data frame "hourly_SoC" that looks right, and a matrix "result" (hour by SoC) that checks against the data frame. I have tried to comment the code so that you an s

Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread Rui Barradas
Hello, There was a bug in the way I copied&pasted your data to my R session, hence the NA's. Here is a tidyverse way of doing what you want. Its output matches the expected output in your last post. The column names don't start at zero because there was no Starting_SoC_of_12 equal to 0. l

Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread roslinazairimah zakaria
Hi Jim, I tried to run your code and got this error. > # get the temporal order of observations > obs_order <- order(c(as.numeric(dt$BCStartTime),as.numeric(dt$BCStopTime))) Warning messages: 1: In order(c(as.numeric(dt$BCStartTime), as.numeric(dt$BCStopTime))) : NAs introduced by coercion 2: I

[R] Extract time and state of charge (Start and End) and Count

2022-07-17 Thread roslinazairimah zakaria
Dear all, I have data of Battery Electric vehicle (BEV). I would like to extract data from every hour starting from 0.00 to 0.59, 1:00-1:59 for SOC(state of charge) start to end. Some examples: I can extract data from SOC=0 and SOC=12 dt_2014[which(dt_2014$Starting_SoC_of_12==0 & dt_2014$Ending_S

Re: [R] Extract data from .nc file

2021-03-09 Thread Rasmus Liland
Dear Shailendra and Roy, Yes, the info ncvar_get retrieves is of different lengths. soi_final does not have a time variable for the x axis, and tt is a integer vector int [1:2001(1d)] 0 365 730 1095 1460 1825 2190 2555 2920 3285 ... The file is a HDF5 file: rasmus@twosixty ~ % file

Re: [R] Extract data from .nc file

2021-02-24 Thread Roy Mendelssohn - NOAA Federal via R-help
Hi Shailendra: You didn't provide the error messages you received, which makes it difficult to answer. I will say here is at least one typo, in: > write.csv(amo_final, "soi.csv", row.names = FALSE) You have only defined "soi_final". But I would also be surprised if either of the "cbind()" o

[R] Extract data from .nc file

2021-02-24 Thread Shailendra Pratap
Hi, Please help me. I am trying to get information on "soi" from the NetCDF file (please see the attached). The file is showing this info- float soi(time=2001, *MCrun=20, members=100*); :description = "soi"; :long_name = "Southern Oscillation Index"; :units = ""; :level = "sfc"; And Dime

[R] Extract NASA VIIRS data in R

2020-03-18 Thread Miluji Sb
Dear all, Hope everyone is keeping safe. I am trying to extract/read VIIRS nighttime lights data but the output seems rather strange. I have uploaded the file here so as not exceed the size limit of the email. ## Code ## libra

Re: [R] Extract lines from pdf files

2019-11-20 Thread Bert Gunter
I think you are more likely to get a helpful answer if you give a minimal example of what your lines look like. I certainly don't have a clue, though maybe someone else will. Cheers, Bert On Wed, Nov 20, 2019 at 12:21 PM Thomas Subia via R-help < r-help@r-project.org> wrote: > Thanks all for th

Re: [R] Extract lines from pdf files

2019-11-20 Thread Thomas Subia via R-help
Thanks all for the help. I appreciate the feedback I've developed another method to extract my desired data from multiple pdfs in a directory. # Combine all pdfs to a combined pdf files <- list.files(pattern = "pdf$") pdf_combine(files, output = "joined.pdf") # creates a text file from joined.pd

Re: [R] Extract lines from pdf files

2019-11-20 Thread Bert Gunter
t; For a "it works" method I used >> >> start_time <- Sys.time() >> >> insert code of interest >> >> end_time <- Sys.time() >> end_time - start_time >> >> -----Original Message- >> From: R-help On Behalf

Re: [R] Extract lines from pdf files

2019-11-20 Thread Bert Gunter
insert code of interest > > end_time <- Sys.time() > end_time - start_time > > -Original Message- > From: R-help On Behalf Of Eric Berger > Sent: Wednesday, November 20, 2019 9:58 AM > To: Jeff Newmiller > Cc: Thomas Subia ; Thomas Subia via R-help >

Re: [R] Extract lines from pdf files

2019-11-20 Thread Jeff Reichman
20, 2019 9:58 AM To: Jeff Newmiller Cc: Thomas Subia ; Thomas Subia via R-help Subject: Re: [R] Extract lines from pdf files Hi Thomas, As Jeff wrote, your HTML email is difficult to read. This is a "plain text" forum. As for "pointers", here is one suggestion. Since you

Re: [R] Extract lines from pdf files

2019-11-20 Thread Eric Berger
Hi Thomas, As Jeff wrote, your HTML email is difficult to read. This is a "plain text" forum. As for "pointers", here is one suggestion. Since you write that you can do the necessary actions with a specific file, try to write a function that carries out those actions for that same file. Except when

Re: [R] Extract lines from pdf files

2019-11-19 Thread Jeff Newmiller
Please don't spam the mailing list. Especially with HTML format messages. See the Posting Guide. PDF is designed to present data graphically. It is literally possible to place every character in the page in random order and still achieve this visual readability while practically making it nearl

[R] Extract lines from pdf files

2019-11-19 Thread Thomas Subia via R-help
Colleagues,   I can extract specific data from lines in a pdf using:   library(pdftools) pdf_text("10619.pdf") txt <- pdf_text(".pdf") write.table(txt,file="mydata.txt") con <- file('mydata.txt') open(con) serial <- read.table(con,skip=5,nrow=1) #Extract[3]flatness <- read.table(con,sk

Re: [R] Extract row as NA with no matching name

2019-08-08 Thread PIKAL Petr
some",] C.1 C.2 C.3 NA NA NA NA Cheers Petr > -Original Message- > From: R-help On Behalf Of Christofer Bogaso > Sent: Thursday, August 8, 2019 5:44 PM > To: r-help > Subject: [R] Extract row as NA with no matching name > > Hi, > > Let say I have b

Re: [R] Extract row as NA with no matching name

2019-08-08 Thread David Winsemius
I don't know a clean way of delivering that result but if you use logical indexing you can get an empty matrix with three columns: str( mdat["nope" %in% rownames(mdat), ] )  num[0 , 1:3]  - attr(*, "dimnames")=List of 2   ..$ : NULL   ..$ : chr [1:3] "C.1" "C.2" "C.3" # it prints thus to the c

[R] Extract row as NA with no matching name

2019-08-08 Thread Christofer Bogaso
Hi, Let say I have below matrix mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE, dimnames = list(c("row1", "row2"), c("C.1", "C.2", "C.3"))) Now I can extract a raw by rowname as > mdat['row1', ] C.1 C.2 C.3 1 2 3 Howe

[R] Extract hyperplane from kernlab's Support Vector Machine model

2019-05-08 Thread Luigi Marongiu
Dear all, I would like to extract an hyperplance froma SVM model generated with the kernlab package. The model I have made is non-linear and I am looking to plot the line that separates the two groups in order to draw custom plots with more control. I understand that I should use a contour plot but

Re: [R] Extract data of special character

2019-03-15 Thread Rui Barradas
Hello, Something like this? old_par <- par(mar = par("mar") + c(5, 0, -2, 0)) boxplot(SCORE ~ ATTRIBUTE, dd, cex.axis = 0.6, las = 2) par(old_par) Hope this helps, Rui Barradas Às 00:06 de 15/03/2019, roslinazairimah zakaria escreveu: Hi Rui and Ivan, Yes both works well. table(dd$ATTRIBU

Re: [R] Extract data of special character

2019-03-15 Thread Ivan Krylov
В Fri, 15 Mar 2019 08:06:52 +0800 roslinazairimah zakaria пишет: > I want to draw boxplot for each individual score of the > attributes. You mean, a box per every possible ATTRIBUTE value? This is easily doable with the bwplot() function from library(lattice). -- Best regards, Ivan __

Re: [R] Extract data of special character

2019-03-14 Thread roslinazairimah zakaria
Hi Rui and Ivan, Yes both works well. table(dd$ATTRIBUTE, dd$TRAIT) #or xtabs( ~ ATTRIBUTE + TRAIT, dd) I have another question,I also want to extract all the PCT_SCORE to draw box plot. I have tried to draw box of PCT_SCORE for all attribute scores. boxplot(dd$PCT_SCORE, ylim=c(0,100),

Re: [R] Extract data of special character

2019-03-14 Thread roslinazairimah zakaria
Yes, it does. table(dd$ATTRIBUTE, dd$TRAIT) #or xtabs( ~ ATTRIBUTE + TRAIT, dd) Thank you so much Rui and Ivan. On Fri, Mar 15, 2019 at 5:51 AM Rui Barradas wrote: > Hello, > > Or more simple, > > xtabs( ~ ATTRIBUTE + TRAIT, dd) > > > Hope this helps, > > Rui Barradas > > Às 19:27 de 14/03/201

Re: [R] Extract data of special character

2019-03-14 Thread Rui Barradas
Hello, Or more simple, xtabs( ~ ATTRIBUTE + TRAIT, dd) Hope this helps, Rui Barradas Às 19:27 de 14/03/2019, Ivan Krylov escreveu: On Fri, 15 Mar 2019 03:06:28 +0800 roslinazairimah zakaria wrote: how many of ATTRIBUTE related to TRAITS. The table() function can be used to count occurr

Re: [R] Extract data of special character

2019-03-14 Thread Ivan Krylov
On Fri, 15 Mar 2019 03:06:28 +0800 roslinazairimah zakaria wrote: > how many of ATTRIBUTE related to TRAITS. The table() function can be used to count occurrences of each combination of factor levels. Does extracting the two columns by dd[,c('ATTRIBUTE','TRAIT')] and passing the result to table(

[R] Extract data of special character

2019-03-14 Thread roslinazairimah zakaria
Hi r-users, I have these data and I would like to count (frequency) how many of ATTRIBUTE related to TRAITS. > dput(dd) structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4

Re: [R] Extract the coordinates of a Polylines

2019-02-01 Thread Michael Sumner
Use ggplot2::fortify - there's several other ways but no "native" support. If fortify doesn't work try spbabel::sptable. All the best On Fri, Feb 1, 2019, 05:46 David Winsemius wrote: > > On 1/30/19 7:12 AM, javad bayat wrote: > > Dear all; > > Back to my previous question, I am trying to add X

Re: [R] Extract the coordinates of a Polylines

2019-01-31 Thread javad bayat
Dear all; Back to my previous question, I am trying to add X and Y coordinates to every row of the data. topo = readOGR("E:/New/Modelling_Water/MIKE/BathyMetry/GIS_Armator/Chitgar_Topo.shp")#Read shape file of the topo as polylines plot(topo) cords = topo@lines[[1]]@Lines[[1]]@coords###Extracting

Re: [R] Extract the coordinates of a Polylines

2019-01-31 Thread David Winsemius
On 1/30/19 7:12 AM, javad bayat wrote: > Dear all; > Back to my previous question, I am trying to add X and Y coordinates > to every row of the data. > > topo = > readOGR("E:/New/Modelling_Water/MIKE/BathyMetry/GIS_Armator/Chitgar_Topo.shp")#Read > > shape file of the topo as polylines > plot

[R] Extract the coordinates of a Polylines

2019-01-27 Thread javad bayat
Dear R users; I am trying to extract the X and Y coordinates of a polylines along with Elevation data. I have extracted the Elevations as Z, but I do not know how to extract the X and Y of these Elevations. Is it possible to extract X and Y of the Elevation and create a data frame with three variab

Re: [R] extract hyperplan from e1071 model

2018-12-20 Thread Sarah Goslee
Hi, Please don't forget to copy R-help on your reply - other people are likely to have more insight. My understanding is that you want to replicate the shaded polygons produced by plot.svm on your own plot. That's why I suggested you first try add=TRUE, and if that doesn't work, then look at the

Re: [R] extract hyperplan from e1071 model

2018-12-20 Thread Sarah Goslee
Hi, According to the help for svm, which you probably should have started with, SV contains the support vectors, and index contains the position of the support vectors in the data matrix. As for plotting, plot.svm lets you pass additional options to plot so that you can customize the plot to your

[R] extract hyperplan from e1071 model

2018-12-20 Thread Luigi Marongiu
Dear all, I am using the package e1071 for modeling SVM. I obtain a model from the data and I can plot the results; the plot shows the support vectors (as 'X's) and the shaded areas as it should be. However, I don't like the plot generated from the model and I would like instead to have more contro

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Gabor Grothendieck
If you specifically want to know which packages were loaded by the script then using a vanilla version of R (i.e. one where only base packages are loaded): vanilla_search <- search() source("myRprg.R") setdiff(search(), vanilla_search) On Wed, Jun 20, 2018 at 4:08 AM, Sigbert Klinke wrot

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Bert Gunter
... or if the argument is just quoted text or a numeric value as in your library() example, don't parse the text and use regex's to search for the function call and pick out the text of the arguments. Again, this only works (I think) for the simple sort of case of your example. Beyond that, you'll

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Hadley Wickham
You need to recursively walk the parse tree/AST. See, e.g., https://adv-r.hadley.nz/expressions.html#ast-funs Hadley On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke wrote: > Hi, > > I have read an R program with > > expr <- parse("myRprg.R") > > How can I extract the parameters of a specifc R c

[R] Extract function parameters from a R expression

2018-06-20 Thread Sigbert Klinke
Hi, I have read an R program with expr <- parse("myRprg.R") How can I extract the parameters of a specifc R command, e.g. "library"? So, if myprg.R containes the lines library("xyz") library("abc") then I would like to get "xyz" and "abc" back from expr. Thanks in advance Sigbert -- https

Re: [R] extract and re-arrange components of data frame

2018-06-12 Thread Massimo Bressan
ALSE) d Da: "Bert Gunter" A: "Massimo Bressan" Cc: "r-help" Inviato: Martedì, 12 giugno 2018 16:42:18 Oggetto: Re: [R] extract and re-arrange components of data frame You mean like this? > s.new <-with(d, as.numeric(unlist(strsplit(s,"," &

Re: [R] extract and re-arrange components of data frame

2018-06-12 Thread S Ellison
> #I need to get this final result > r<-data.frame(i=c(1,1,1,2,2,3), s=c(97, 98, 99, 103, 105, 118)) Nothing magic to suggest. But maybe: list.s <- strsplit(d$s,",") r <- data.frame(i=rep(d$i, times=sapply(list.s, length)), s=unlist(list.s), stringsAsFactors=FALSE ) S Ellison **

Re: [R] extract and re-arrange components of data frame

2018-06-12 Thread Bert Gunter
You mean like this? > s.new <-with(d, as.numeric(unlist(strsplit(s,"," > s.new <- cut(s.new,breaks = c(0,100,110,200),lab = d$i) > s.new [1] 1 1 1 2 2 3 Levels: 1 2 3 (Obviously, this could be a one-liner) See ?cut Cheers, Bert Bert Gunter "The trouble with having an open mind is th

[R] extract and re-arrange components of data frame

2018-06-12 Thread Massimo Bressan
# considering this data.frame as a reproducible example d<-data.frame(i=c(1,2,3), s=c('97,98,99','103,105', '118'), stringsAsFactors = FALSE) d #I need to get this final result r<-data.frame(i=c(1,1,1,2,2,3), s=c(97, 98, 99, 103, 105, 118)) r #this is my attempt #number of components for

[R] Extract all point in a quadrats by spatstat package

2017-11-28 Thread Mohammad Tanvir Ahamed via R-help
Hi, With the following code i can divides window into quadrats and counts the numbers of points in each quadrat. library(spatstat) X <- runifpoint(50) quadratcount(X) quadratcount(X, 4, 5) quadratcount(X, xbreaks=c(0, 0.3, 1), ybreaks=c(0, 0.4, 0.8, 1)) qX <-  quadratcount(X, 4, 5) plot(X) plot(

[R] Extract XMLAtrributeValue

2017-07-10 Thread Mohan.Radhakrishnan
Hi, I am trying to extract an attribute value which is like this. (e.g) class="whQuestion" The 'extract' function prints this. But I am not sure how to get "whQuestion" from that. The type of 'x' in extract is "character" [1] "XMLAttributeValue" class "whQuestion" attr(,"class") extrac

Re: [R] Extract cells and their adjacent cells that may appear anywhere in a dataframe.

2017-05-08 Thread Jeff Newmiller
Please don't post in HTML... what YOU see is almost never what WE see (look below for something like what I saw). Read the Posting Guide for more help on how to use the list, including the recommendation to formulate your question as a minimal R example (runnable code). See for example [1] and/o

[R] Extract cells and their adjacent cells that may appear anywhere in a dataframe.

2017-05-08 Thread Brian Leo
Hello, I have a dataframe that contains information about vegetation cover and percent coverage, collected using a quadrat. The dataframe is set up so that each row represents a single quadrat. If there are multiple species within one quadrat, they are all listed within the same row with respect

Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread roslinazairimah zakaria
ike to select the student id where the third and fourth value >> represent the year they register data is eg. AA15..., AE14,... and I would >> also to select their cgpa value. >> >> Thank you. >> >> On Mon, Mar 13, 2017 at 2:26 PM, roslinazairimah zakaria < >&

Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread Rui Barradas
15..., AE14,... and I would also to select their cgpa value. Thank you. On Mon, Mar 13, 2017 at 2:26 PM, roslinazairimah zakaria < roslina...@gmail.com> wrote: Thank you so much for your help. On Mon, Mar 13, 2017 at 1:52 PM, bioprogrammer wrote: Hi. I would use the "substr" f

Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread roslinazairimah zakaria
slinazairimah zakaria < roslina...@gmail.com> wrote: > Thank you so much for your help. > > On Mon, Mar 13, 2017 at 1:52 PM, bioprogrammer > wrote: > >> Hi. >> >> I would use the "substr" function: >> >> https://stat.ethz.ch/R-manual/R-devel/library

Re: [R] Extract student ID that match certain criteria

2017-03-13 Thread Jim Lemon
Hi Roslinazairimah, What you seem to want is fairly simple: dt<-c("AA14068","AA13194","AE11054","AA12251","AA13228", "AA13286","AA14090","AA13256","AA13260","AA13291", "AA14099","AA15071","AA13143","AA14012","AA14039", "AA15018","AA13234","AA13149","AA13282","AA13218") dt[grep(pattern="AA14"

Re: [R] Extract student ID that match certain criteria

2017-03-13 Thread Ulrik Stervbo
Hi Roslinazairimah, As Bert suggested, you should get acquainted with regular expressions. It can be confusing at times, but pays off in the long run. In your case, the pattern of "^[A-Z]{2}14.*" might work. Best, Ulrik On Mon, 13 Mar 2017 at 06:20 roslinazairimah zakaria wrote: > Another que

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Another question, How do I extract ID based on the third and fourth letter: I have for example, AA14004, AB15035, CB14024, PA14009, PA14009 etc I would like to extract ID no. of AB14..., CB14..., PA14... On Mon, Mar 13, 2017 at 12:37 PM, roslinazairimah zakaria < roslina...@gmail.com> wrote: >

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Hi Bert, Thank you so much for your help. However I don't really sure what is the use of y values. Can we do without it? x <- as.character(FKASA$STUDENT_ID) y <- c(1,786) My.Data <- data.frame (x,y) My.Data[grep("^AA14", My.Data$x), ] I got the following data: x y 1 AA14068 1

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread Bert Gunter
1. Your code is incorrect. All entries are character strings and must be quoted. 2. See ?grep and note in particular (in the "Value" section): "grep(value = TRUE) returns a character vector containing the selected elements of x (after coercion, preserving names but no other attributes)." 3. Wh

[R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Dear r-users, I have this list of student ID, dt <- c(AA14068, AA13194, AE11054, AA12251, AA13228, AA13286, AA14090, AA13256, AA13260, AA13291, AA14099, AA15071, AA13143, AA14012, AA14039, AA15018, AA13234, AA13149, AA13282, AA13218) and I would like to extract all student of ID AA14... only. I

Re: [R] Extract input and filter data using extracted value.

2017-01-24 Thread PIKAL Petr
Hi see in line > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sathiaraj S > P via R-help > Sent: Tuesday, January 24, 2017 11:26 AM > To: r-help@r-project.org > Subject: [R] Extract input and filter data using extracted value. &g

[R] Extract input and filter data using extracted value.

2017-01-24 Thread Sathiaraj S P via R-help
Hi, I raised this question @ stack overflow and got below partial answer. Hope this mailing list can help on rest to complete. library(dplyr) library(tidyr) input <- "1.8 - versicolor" temp <- data.frame(input = input) %>% tidyr::separate(input, c("Petal.Width", "Species"),sep = " -

Re: [R] extract minimal variables from model

2017-01-06 Thread Marc Schwartz
> On Jan 6, 2017, at 11:03 AM, Jacob Wegelin wrote: > > Given any regression model, created for instance by lm, lme, lmer, or rqs, > such as > > z1<-lm(weight~poly(Time,2), data=ChickWeight) > > I would like a general way to obtain only those variables used for the model. > In the current e

  1   2   3   4   5   6   7   8   >