Re: [R] Identifying columns with specific character

2018-04-18 Thread Rui Barradas
Hello, To the OP: The dollar sign is a meta character, so it must be escaped, that is what was wrong with your code. The right regular expression would be grepl("\\$", x) When a regular expression doesn't work, try reading the help page ?regex. Another good source you can try is https://reg

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

2018-04-18 Thread jim holtman
Try this: result <- lapply(71:75, function(x){ # use 'paste0' to add the number to the file name input <- read.csv(paste0("C:/Awork/geneAssociation/removed8samples/neuhausen", x, "/seg.pr3.csv") , head=TRUE ) inpu

Re: [R] Identifying columns with specific character

2018-04-18 Thread Jeff Newmiller
Your message came through all messed up because you did not tell your email program to use plain text format. This at best delays a responds and at worst prevents us from understanding your question as you intended. 1) The columns became factors when you created the data frame because you did n

Re: [R] Identifying columns with specific character

2018-04-18 Thread Jim Lemon
Hi Farnoosh, Perhaps this will help: drop_dollar<-function(x) return(as.numeric(as.character(gsub("\\$","",x sapply(My.Data,drop_dollar) Jim On Thu, Apr 19, 2018 at 7:23 AM, Farnoosh Sheikhi via R-help wrote: > Hello, > I have a data frame with 400 columns and wanted to filter character col

[R] Identifying columns with specific character

2018-04-18 Thread Farnoosh Sheikhi via R-help
Hello, I have a data frame with 400 columns and wanted to filter character columns with "$" in it.For example: >  x <- c("$5", "$89", "$10", "$34")  >  y <- c(1:4)>  My.Data <- data.frame (x,y)> My.Data    x y1  $5 12 $89 23 $10 34 $34 4 I want to detect the columns with $ and remove the $ from t

Re: [R] merge two data frame based on equal and unequal comparisons

2018-04-18 Thread Ding, Yuan Chun
HI All, I found that other R users experienced the same problem when using sqldf package. An expert provided solution, adding "method="raw" at the end as below, one or more of the columns in my data.frame are of class "AsIs" ( I don't know what it is) . When sqldf retrieves the result from SQL

Re: [R] How to replace numeric value in the column contains Text (Factor)?

2018-04-18 Thread Marna Wagley
Hi David and Jeff, Both ways worked for my table. it helped me a lot (I was really struggling on it to change the values and thinking to do manually). You are great. Thank you On Wed, Apr 18, 2018 at 11:13 AM, David L Carlson wrote: > The simplest would be to convert precip to character and then

Re: [R] How to replace numeric value in the column contains Text (Factor)?

2018-04-18 Thread David L Carlson
The simplest would be to convert precip to character and then back to a factor if you really want it to be a factor. This will also remove the levels that no longer exist. str(dat) # 'data.frame': 5 obs. of 3 variables: # $ Sites : Factor w/ 5 levels "Site1","Site2",..: 1 2 3 4 5 # $ temp

Re: [R] How to replace numeric value in the column contains Text (Factor)?

2018-04-18 Thread Jeff Newmiller
I would recommend that you avoid converting (or letting R convert for you) your textual data values into factors until you have finished doing this kind of modification. You can restore the column to character data type either re-reading it with the stringsAsFactors=FALSE option to read.table/r

[R] How to replace numeric value in the column contains Text (Factor)?

2018-04-18 Thread Marna Wagley
Hi R user, Would you mind to help me on how I can change a value in a specific column and row in a big table? but the column of the table is a factor (not numeric). Here is an example. I want to change dat[4:5,3]<-"20" but it generated NA> do you have any suggestions for me? dat<-structure(list(Si

[R] merge two data frame based on equal and unequal comparisons

2018-04-18 Thread Ding, Yuan Chun
Dear R users, I need to merge two data frames based on both equal and unequal comparisons. The "sqldf" package used to work well , but today, I cannot resolve the following error by reinstallation of the sqldf package. Can anyone suggest a different way to perform this kind of merge function

Re: [R] Event-triggered change in value with a time-delay

2018-04-18 Thread David Winsemius
> On Apr 18, 2018, at 1:04 AM, Hannah Meredith wrote: > > Hello, > > I am solving a set of ODEs using deSolve and have run into a problem I > would appreciate some advice on. One of the parameters (m) in the ODEs > changes between two states when one of the variables (D) crosses a > threshold (

Re: [R] Problem with regression line

2018-04-18 Thread CHATTON Anne via R-help
Hi Gerrit! Thank you so much! I mistakenly reversed the order of the variables of the regression. Actually what I meant to write was: lm(BloodPressure ~ Age). Best, Anne -Message d'origine- De : Gerrit Eichner [mailto:gerrit.eich...@math.uni-giessen.de] Envoyé : mercredi 18 avril 2018 16

Re: [R] Problem with regression line

2018-04-18 Thread David L Carlson
To expand on Eik Vettorazzi's answer: Don't use html emails. When the mailing list converts it to plain text, it often re-wraps lines so that your code becomes jumbled. First, you did not define coeff. You need to add coeff <- coef(SimpleLinearReg1) Second, you should use the formula you used

Re: [R] Problem with regression line

2018-04-18 Thread Eik Vettorazzi
Hi Anne, I would suggest to change the linear model to lm(BloodPressure~Age), as this model makes more sense in biological means (you would assume that age influences pressure, not vice versa) and also obeys the statistical assumption of weak exogeneity, that age can be measured without error, at l

Re: [R] Reasons to Use R in a Public Administrations and Ideas for a Short Training

2018-04-18 Thread David L Carlson
Courses are good for people who are motivated to learn. It sounds like you need to generate the motivation first. Why not develop 4 - 5 case study examples? Kinds of analyses currently performed on Excel that would be easier to replicate and repeat using simple R scripts so that you are showing

Re: [R] Problem with regression line

2018-04-18 Thread Gerrit Eichner
Hi, Anne, assign Age and Bloodpressure in the correct order to the axes in your call to plot as in: plot(y = Age, x = BloodPressure) abline(SimpleLinearReg1) Hth -- Gerrit - Dr. Gerrit Eichner Mathematica

Re: [R] Hacked

2018-04-18 Thread Ted Harding
Not necessarily. The R-help archives are publicly accessible, with a "sort by date" option. So if someone sets up a web=page monitor which reports back when new messages appear there (at the bpottom end), then their email addresses are readily copied (subject to " at " --> "@". Once they have the

Re: [R] nMDS with R: missing values

2018-04-18 Thread David L Carlson
I'm not sure how you are incorporating time period into your data structure. Typically we are looking at plots or assemblages as the rows and taxa as the columns. Time period adds a third dimension that could be added as blocks of rows. For example, depending on the resolution of your data, one

[R] Reasons to Use R in a Public Administrations and Ideas for a Short Training

2018-04-18 Thread Lorenzo Isella
Dear All, Ages ago I posted to this mailing list asking for advice about to evangelize the use of R in an international public administration where the fact that R is free is not a decisive factor (actually its being "freeware" may even be seen negatively). After a long time, I think it is worthwh

[R] Problem with regression line

2018-04-18 Thread CHATTON Anne via R-help
Hello, I am trying to graph a regression line using the followings: Age <- c(39, 47, 45, 47, 65, 46, 67, 42, 67, 56, 64, 56, 59, 34, 42, 48, 45, 17, 20, 19, 36, 50, 39, 21, 44, 53, 63, 29, 25, 69) BloodPressure <- c(144, 220, 138, 145, 162, 142, 170, 124, 158, 154, 162, 150, 140, 110, 128, 130, 1

[R] mgcv::gamm error when combining random smooths and correlation/autoregressive term

2018-04-18 Thread Mathew Guilfoyle
I am having difficulty fitting a mgcv::gamm model that includes both a random smooth term (i.e. 'fs' smooth) and autoregressive errors. Standard smooth terms with a factor interaction using the 'by=' option work fine. Both on my actual data and a toy example (below) I am getting the same error

Re: [R] Understanding which

2018-04-18 Thread Ashim Kapoor
Dear Jeff and Eric, Okay and many thanks. Best Regards, Ashim On Wed, Apr 18, 2018 at 4:56 PM, Jeff Newmiller wrote: > Look at > > which(x>100) > > This is a zero-length vector. The negative of nothing is nothing, not a > list of all possible index values. > > Do you want > > x[ !( x > 100 ) ]

Re: [R] Understanding which

2018-04-18 Thread Jeff Newmiller
Look at which(x>100) This is a zero-length vector. The negative of nothing is nothing, not a list of all possible index values. Do you want x[ !( x > 100 ) ] ? On April 18, 2018 6:13:30 AM CDT, Ashim Kapoor wrote: >Dear All, > >Here is a reprex: > >> x<- 1:100 >> x[-which(x>100)] >integer(0

Re: [R] Understanding which

2018-04-18 Thread Eric Berger
Here's a hint: > y <- which(x>100) > identical(y,y) # TRUE > identical(y,-y) # TRUE The '-' is misleading - it is absorbed into the empty y, leaving the request x[y] to be x for an empty set of indices. HTH, Eric On Wed, Apr 18, 2018 at 2:13 PM, Ashim Kapoor wrote: > Dear All, > > Here is a

[R] Understanding which

2018-04-18 Thread Ashim Kapoor
Dear All, Here is a reprex: > x<- 1:100 > x[-which(x>100)] integer(0) In words, I am finding out which indices correspond to values in x which are greater than 100 ( there are no such items ) . Then I remove those indices. I should get back the x that I started with since there are no items in

Re: [R] Hacked

2018-04-18 Thread Fowler, Mark
Seems it must be the R-list. A horde of ‘solicitation’ emails began arriving about 27 minutes after I posted about not seeing any! Had left work by that time, so did not encounter them until now. From: Mark Leeds [mailto:marklee...@gmail.com] Sent: April 18, 2018 12:33 AM To: Rui Barradas Cc: Di

[R] Event-triggered change in value with a time-delay

2018-04-18 Thread Hannah Meredith
Hello, I am solving a set of ODEs using deSolve and have run into a problem I would appreciate some advice on. One of the parameters (m) in the ODEs changes between two states when one of the variables (D) crosses a threshold (D_T) for the first time in either direction. Additionally, when the var