similar to: Match strings across two differently sized dataframes and copy corresponding row to dataframe

Displaying 20 results from an estimated 400 matches similar to: "Match strings across two differently sized dataframes and copy corresponding row to dataframe"

2010 Dec 06
1
R cmd batch with parameters
hello! I'm trying to make a very simple calculation using R that would called from bash with two parameters, the names of the input and output files. the first one is just an 4 by 100 numerical table- the function finds the index of the maximal elements in each columns and writes it into the output file. I cannot deal somehow with passing the parameters to the function it works from R with the
2011 Aug 29
3
Basic question about re-writing for loop as a function
Hello- Sorry to ask a basic question, but I've spent many hours on this now and seem to be missing something. I have a loop that looks like this: mainmat=data.frame(matrix(data=0, ncol=92, nrow=length(predata$Words_MH))) for(i in 1:length(predata$Words_MH)){ for(j in 1:92){ mainmat[i,j]=ifelse(j %in% as.numeric(unlist(strsplit(predata$Words_MH[i], split=","))),
2012 Dec 09
1
Some coefficients are doubled when I use the step() function
Hello- Such a strange problem, can't figure it out at all. Using binomial glm models, and the step() function, so the call looks like this: sectionmodel = glm(formula = Target3 ~ S1Q12_NUM.1 + S1Q9_NUM.1 + S1Q5_NUM.1 + S1Q7_NUM.1 + S1Q8_NUM.1 + S1Q6_NUM.1 + S1Q10_NUM.1 + S1Q12_BURG.1 + S1Q12_CD.1 + S1Q4.1 + S1Q12_OTHVIOL.1 + S1Q8.1 + S1Q12_GBH.1 + S1Q11.1 + S1Q7.1 + S1Q12_THEFT.1
2007 Dec 06
0
alternatives to latex() or xtable()
An alternative solution that allows you to break it down by categories is in the functions below. Comments/suggestions welcome and encouraged. Note that much thanks is due to those who responded to an earlier post of mine on a similar topic. To use (assuming you have a data.frame falled pathDist with columns distances (your numeric data of interest), Capacity, Surface, and SITE (vectors of
2009 Aug 04
1
Build a dataframe row by row?
Hi, Time for another of my "newbie" questions. Is it possible to build up a data.frame "row by row" as I go I'm going to be running a bunch of experiments (many in a loop) to test different things. I'm using AUC as my main performance measure. My thought was to add a row to a data.frame for each iteration and then have a nice summary report at the end. I found
2011 May 27
1
Subset command and the : operator
Hello- I have some code that looks like this: with(mydatalocal, sum(table(Service[Time==5:8]))) This is designed to add up the numbers of responses between the Time codes 5 to 8 (which are integers and refer to quarters). Service is just one of the variables, I'm just trying to count the number of responses so I picked any of the variables. However, there is something wrong, it returns far
2010 Aug 24
2
How to remove rows based on frequency of factor and then difference date scores
Hello- A basic question which has nonetheless floored me entirely. I have a dataset which looks like this: Type ID Date Value A 1 16/09/2020 8 A 1 23/09/2010 9 B 3 18/8/2010 7 B 1 13/5/2010 6 There are two Types, which correspond to different individuals in different conditions, and loads of ID labels (1:50)
2011 Jun 20
2
Replace selected columns of a dataframe with NA
I am using the following command to replace all the missing values and assorted typos in a dataframe with NA: mydata[mydata>80]=NA The problem is that the first column contains values which should be more than 80, so really I want to do it just for mydata[,2:length(mydata)] I can't seem to re-write the code to fit: mydata[,2:length(mydata)>80]=NA # no error message, but doesn't
2012 Mar 28
1
Nested brew call yields Error in .brew.cat(26, 28) : unused argument(s) (26, 28)
I am writing several webpages using the brew package and R2HTML. I would like to work off one script so I am using nested brew calls. The documentation for brew states that: "NOTE: brew calls can be nested and rely on placing a function named ?.brew.cat? in the environment in which it is passed. Each time brew is called, a check for the existence of this function is made. If it exists,
2011 Aug 12
1
odfWeave repeats output
Hello all- I'm having a problem with odfWeave. I'm still testing it out, and have used both of these code chunks, which I copied off a blog: Number 1: A sample document last processed \Sexpr{Sys.time()}. This simply illustrates the output from an R command inserted into our document. This is using \Sexpr{version$version.string}. Number 2: <<Sample1>>= summary(iris) @
2012 Jan 09
3
as.numeric() generates NAs inside an apply call, but fine outside of it
Hello- I have rather a messy SPSS file which I have imported to R, I've dput'd some of the columns at the end of this message. I wish to get rid of all the labels and have numeric values using as.numeric. The funny thing is it works like this: as.numeric(mydata[,2]) # generates correct numbers however, if I pass the whole dataframe at once like this: apply(mydata, 1:2, function(x)
2012 May 31
1
anova of lme objects (model1, model2) gives different results depending on order of models
Hello- I understand that it's convention, when comparing two models using the anova function anova(model1, model2), to put the more "complicated" (for want of a better word) model as the second model. However, I'm using lme in the nlme package and I've found that the order of the models actually gives opposite results. I'm not sure if this is supposed to be the case
1999 Jan 18
0
Selecting a subgroup
I use the following function to select a subgroup from a data vector (usually to calculate descriptive stats). select.range<-function (groupvec, min, max, data) { if (nargs() > 3) { min.cond <- groupvec >= min max.cond <- groupvec < max cond <- min.cond & max.cond selected <- na.remove(ifelse(cond, data, NA))
2010 Jul 02
2
Problem with aggregating data across time points
Hello- I have a dataset which basically looks like this: Location Sex Date Time Verbal Self harm Violence_objects Violence A 1 1-4-2007 1800 3 0 1 3 A 1 1-4-2007 1230 2 1 2 4 D 2 2-4-2007 1100 0
2010 Jan 25
3
Matching a character in a string
Hello. Sorry for this very basic question but I didn't find (of didn't understand) the answer either in the help or in the online guide. I have a string, let's say "hello". I want to know if there is some character in it, let's say an 'o'. I tried > charmatch("o", strstplit("hello","")) but it gives NA (why??) Thinking it may
2001 May 08
1
ASCII map?
Is there a way to convert between and integer and a character and vice versa? For instance i <- 65; ch <- intToChar(i); # "A" i <- charToInt(ch); # 65 or even better i <- c(65, 66); ch <- intToChar(i); # c("A", "B") i <- charToInt(ch); # c(65, 66) I have tried to do a ASCII map myself, and I figured out that the ASCII
2003 Aug 26
3
matching-case sensitivity
Hi All, I am trying to match two character arrays (email lists) using either pmatch(), match() or charmatch() functions. However the function is "missing" some matches due to differences in the cases of some letters between the two arrays. Is there any way to disable case sensitivity or is there an entirely better way to match two character arrays that have identical entries but written
2002 Oct 22
3
Loading packages at startup
> 4) One problem with saving an R session and then restoring it is that > the packages in use are not reloaded. Quitting an R session and > saving could write .Rpackages in the current directory (with the > library recorded if it were not the default). Then restarting a > session in that directory would restore the loaded packages > automatically. I've been
2004 Jul 08
7
Problem with the grep function
Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern="b", I would to obtain 2 because "b" is on the second position. First program : nom <- c("a","b","ab") grep("b",nom) 2 3 Then I try the
2004 Nov 24
2
an R function to search on Prof. Baron's site
Inspired by the functions that Barry Rawlingson and Dave Forrest posted for searching Rwiki and R-help archive, I've made up a function that does the search on Prof. Baron's site (Thanks to Prof. Baron's help on setting up the query string!): RSiteSearch <- function(string, restrict="Rhelp", format="long", sortby="score",