Displaying 20 results from an estimated 10000 matches similar to: "lapply to change variable names and variable values"
2011 Jun 06
1
Merge two columns of a data frame
I have the following data:
prefix <- c("cheap", "budget")
roots <- c("car insurance", "auto insurance")
suffix <- c("quote", "quotes")
prefix2 <- c("cheap", "budget")
roots2 <- c("car insurance", "auto insurance")
roots3 <- c("car insurance", "auto
2018 Nov 10
2
Asignar distancias
Utilizo la función merge desde hace poco, pero no se me ocurre cómo
utilizarla para esto. Yo pienso que se puede hacer con una combinación
de ifelse-s pero no sé cómo. Seguro que hay más de una forma ce hacerlo.
Quoting José María Mateos <chema en rinzewind.org>:
> On Sat, Nov 10, 2018 at 07:54:19PM +0100, Manuel Mendoza wrote:
>> Muy buenas. A ver si alguien puede echarme
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All
Sorry for this simple question, I could not solve it by spending days.
My data looks like this:
# data
set.seed(1234)
clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100
level for this factor var;
yvar <- rnorm(40, 10,6);
var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2);
var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15,
2007 Jun 12
3
Read Windows-like .INI files into R data structure?
I need to process some datasets where the configuration information was
stored in .INI-like files, i.e., text files with sections like this:
[Section1]
var1=value1
var2=value2
[Section2]
A=value3
B=value4
...
>From Google and other searches I haven't found any package, or function
within a package, that reads .INI files into an R list, or other data
structure.
Any suggestions, or
2012 Jun 03
2
merging single column from different dataframe
Hi all,
probably really simple to solve, but having no background in programming I
haven't been able to figure this out: I have two dataframes like
df1 <- data.frame(names1=c('aa','ab', 'ac', 'ad'), var1=c(1,5,7,12))
df2 <- data.frame(names2=c('aa', 'ab', 'ac', 'ad', 'ae'),
var2=c(3,6,9,12,15))
Now I want merge
2009 Oct 07
1
merging dataframes with an unequal number of variables
Hallo Everyone
I have the kind of problem that one should never have because one must
always plan well and communicate with your team. But now I haven't so here
is my problem.
I have data coming in on a daily basis from surveys in 10 towns. The
questionnaire has 62 variables but some of the regions have used older
versions of the questionnaire that have a few variables less. I want to
combine
2008 Jan 18
3
Select a group of data from a file
Hello everybody!
I've a file with several data six variables, three quantitative and three qualitative, I would like to select a group of data from the file to analyze then, i.e:
my file is like that (but with 6 variables):
Var1 Var2
2 1
5 1
8 1
7 2
3 2
8 2
I want to use only the data where var2 is "1"
2 1
5 1
8 1
Exist a
2018 Mar 22
1
Calculate weighted proportions for several factors at once
Hi,
I have a grouped data set and would like to calculate weighted proportions for a large number of factor variables within each group member. Rather than using dplyr::count() on each of these factors individually, the idea would be to do it for all factors at once. Does anyone know how this would work? Here is a reproducible example:
############################################################
2012 Nov 09
5
using lapply with recode
Hello:
Forgive me, this is surely a simple question but I can't figure it out, having consulted the help archives and "Data Manipulation With R" (Spector).
I have a list of 11 data frames with one common variable in each (prov). I'd like to use lapply to go through and recode one particular level of that common variable.
I can get the recode to work, but it only returns the
2012 Sep 11
3
Combine two variables
Hi:
I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first variable into the third, then recodes the second variable into the third, overwriting the first recode. I can do this with a rather elaborate indexing process,
2009 Feb 19
3
Multiple merge, better solution?
Hello,
My problem is that I would like to merge multiple files with a common
column but merge accepts only two
data.frames to merge. In the real situation, I have 26 different
data.frames with a common column. I can of course use merge many times
(see below) but what would be more sophisticated solution? For loop?
Any ideas?
DF1 <- data.frame(var1 = letters[1:5], a = rnorm(5))
DF2 <-
2007 Sep 27
2
create data frame(s) from a list with different numbers of rows
# Hello,
# I have a list with 6 categories and with different numbers of rows.
# I would like to change each of them into a unique data frame in order to
match
# values with other data frames and perform some calculations.
# Or I could make each category or list element have the same number of rows
and create one large data.frame.
# below is a creation of a sample list
# I apologize for the
2007 Jul 03
2
vertically concatenating data frames
Hi,
what is the recommended way to vertically concatenate 2 data frames with
the same column names but different number of rows?
My problem is something along these lines:
df1 <- data.frame(var1=var1,var2=var2,var3=var3) # nrow(df1)=1000
df2 <- data.frame(var1=var4,var2=var5,var3=var6) # nrow(df2)=2000
I tried df <- c(df1,df2), no success. stack does not seem to be
appropriate
2017 Oct 10
1
About multiple panels with limited space in-between
Hi R users,
I have a question about plotting. The following two datasets are an
example. What I have in mind is like the attached figure, but just have two
rows, top row is for DF1, bottom row is for DF2. The top and bottom rows,
have x-axis as var1, var2, var3, etc, while the y-axis represents A. For
each row, only the leftmost panel has y-axis ticks and label. For the two
rows, only the bottom
2009 Aug 18
1
adding points to a wireframe
A quick question. I'm trying to plot a surface from a fitted model
along with the original points, as in the following example:
df<-data.frame(expand.grid(100*runif(1:100), 100*runif(1:100)))
df$Var3<-rnorm(length(df$Var1), mean=df$Var1*df$Var2, sd=10)
my.lm<-lm(Var3 ~ Var1*Var2, data=df)
my.fun<-function(x,y) predict(my.lm, data.frame(Var1=x, Var2=y),
2009 Jul 03
2
mapping states with colors
Hi folks,
I'm just learning how to use maps. As an initial foray, I'm mapping the
states that have "duty to retreat" (blue) and "stand your ground" (red)
self-defense standards. Here is my extremely naive script:
dtr <- c('alabama', 'arizona', 'conneticut', 'delaware', 'dist of columbia'
, 'hawaii',
2018 Dec 12
4
Subset dentro de un for
Muy buenas. Quiero hacer un loop en el que en cada iteración se hace
un subset con el que se queda con las muestras para la que cierta
variable es positiva.
Si hago esto, sale bien:
df2<-subset(df, subset = var1>0)
Pero he probado así (y de no sé cuantas formas más), antes de hacer el
for, y no sale:
GT<- c("var1","var2", ? )
df2<-subset(df,
2011 Jul 23
2
sum part of a vector
Dear colleagues, I have a data set that looks roughly like this;
mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5), rep("California", 5)), news=runif(15, min=0, max=8), cum.news=rep(0, 15))
For each state, I'd like to cumulatively sum the value of "news" and make that put that value in cum.news.
I'm trying as follows but I get
2006 Jul 08
6
Trying to create pulldown select menu for US State form fiel
I noticed there is a country_select. Is there anything like
us_state_select maybe?
More specifically - I''m wondering if I manually have to populate an
array with all the U.S. state abbreviations so users can select which
state they live in while entering their mailing address.
--
Posted via http://www.ruby-forum.com/.
2011 Feb 14
5
Transforming relational data
Hi,
I have a large dataset with info on individuals (B) that have been involved
in projects (A) during multiple years (C). The dataset contains three
columns: A, B, C. Example:
A B C
1 1 a 1999
2 1 b 1999
3 1 c 1999
4 1 d 1999
5 2 c 2001
6 2 d 2001
7 3 a 2004
8 3 c 2004
9 3 d 2004
I am interested in how well all the individuals in a project know each
other. To