Displaying 20 results from an estimated 10000 matches similar to: "Looping Over Data Frames"
2013 May 01
3
Adding Column to Data Frames Using a Loop
Dear R Helpers,
I am trying to do calculations on multiple data frames and do not want to
create a list of them to go through each one. I know that lists have many
wonderful advantages, but I believe the better thing is to work df by df
for my particular situation. For background, I have already received some
wonderful help on how to handle some situations, such as removing columns:
2013 Apr 29
3
Function for Data Frame
Dear R Helpers,
I have about 20 data frames that I need to do a series of data scrubbing
steps to. I have the list of data frames in a list so that I can use
lapply. I am trying to build a function that will do the data scrubbing
that I need. However, I am new to functions and there is something
fundamental that I am not understanding. I use the return function at the
end of the function and
2013 May 17
2
Selecting A List of Columns
Dear R Helpers,
I need help with a slightly unusual situation in which I am trying to
select some columns from a data frame. I know how to use the subset
statement with column names as in:
x=as.data.frame(matrix(c(1,2,3,
1,2,3,
1,2,2,
1,2,2,
1,1,1),ncol=3,byrow=T))
all.cols<-colnames(x)
to.keep<-all.cols[1:2]
Kept<-subset(x,select=to.keep)
Kept
2013 Feb 07
1
Select only unique rows from a data frame
Hello!
I have a data frame with several rows, for example:
x=as.data.frame(matrix(c(1,2,3,
1,2,3,
1,2,2,
1,2,2,
1,1,1),ncol=3,byrow=T))
I would like to find y - a data frame that only has the unique rows from x,
i.e.:
1,2,3
1,2,2
1,1,1
Thanks a lot for your hints!
Dimitri
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML
2008 Jun 26
1
Layout() coordinates and drawing lines / segments
Hello,
I am trying to wrap my head around the coordinates systems associated with
the layout() function ...with the end goal of simply drawing a decorative
line in the upper margin of my figure, which is composed of three plots.
My output is defined as this:
----------------------------------------------------------------------------
postscript("out.ps", horizontal=FALSE,
2013 Apr 14
3
Create New Column Inside Data Frame for Many Data Frames
Dear R Helpers,
I have a large number of data frames and I need to create a new column
inside each data frame. Because there is a large number, I need to "loop"
through this, but I don't know the syntax of assigning a new column name
dynamically.
Below is a simple example of what I need to do. Assume that I have to do
this for all 26 letters and you should see the form of the
2005 Mar 28
2
Generating list of vector coordinates
Hi.
Can anyone suggest a simple way to obtain in R a list of vector
coordinates of the following form? The code below is Mathematica.
In[5]:=
Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2]
Out[5]=
{{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1
,2,4},{1,2,
5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3},
{1,4,
2011 Oct 18
1
Function in nested loop
Hi all,
I would like to run a function with several nested conditions, which are
completely factorial.
The input data (x1) has two different sample sizes, so:
x1 <- dat1
x1 <- dat2
Then a can have 3 different values:
a <- 0.15
a <- 0.35
a <- 0.50
Then b can have 2 different values:
b <- data.matrix (c(0.5,0.5,0.5))
b <- data.matrix (c(0.2,0.4,0.6))
Then d can have 5
2023 Apr 03
1
Simple Stacking of Two Columns
Hi,
You were on the right track using stack(), but you just pass the entire data frame as a single object, not the separate columns:
> stack(NamesWide)
? values ? ind
1 ? ?Tom Name1
2 ? Dick Name1
3 ?Larry Name2
4 ?Curly Name2
Note that stack also returns the index (second column of 'ind' values), which tells you which column in the source data frame the stacked values originated
2023 Apr 03
4
Simple Stacking of Two Columns
Hi R-Helpers,
Sorry to bother you, but I have a simple task that I can't figure out how to do.
For example, I have some names in two columns
NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
and I simply want to get a single column
2008 Jun 21
2
Generating groupings of ordered observations
Dear List,
I have a problem I'm finding it difficult to make headway with.
Say I have 6 ordered observations, and I want to find all combinations
of splitting these 6 ordered observations in g groups, where g = 1, ...,
6. Groups can only be formed by adjacent observations, so observations 1
and 4 can't be in a group on their own, only if 1,2,3&4 are all in the
group.
For example,
2018 Mar 05
0
Interpret List Label as Date from Quantmod getOptionChain
Package?
The **names** of the top levels of your lists, "Mar.09.2018", "Mar.23.2018"
certainly look like dates and if they are -- I have no idea what
package/context is -- they certainly could be formatted as such. See e.g.
"date-time" . There are also several package that provide date tools.
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is
2011 Apr 12
2
Assign Character Value to Data Frame
Dear R Helpers,
I am trying to write a character value to the row of a data frame and am
running into a problem that I don't have when I do this for numeric
arguments. For example, the following works just fine:
> test<-data.frame(number=numeric(1))
> test[1,]<-.5
> test
number
1 0.5
But the following bombs out:
> hold<-data.frame(symbol=character(1))
>
2011 Mar 19
2
persuade tabulate function to count NAs in a data frame
Hi,
I'd like to ask you a question again. It is basically about data frames, NAs and tabulate function.
I have this data frame. I already used this in one of the previous questions of mine. It intentionally looks this simple, my real 'df' dataframe is much bigger actually and again, I am not willing to annoy anyone with huge databases... So, my database:
id
2018 Mar 05
2
Interpret List Label as Date from Quantmod getOptionChain
Package? Quantmod. In the subject line.
I agree that they look like dates, I don't know how to determine if they are actually dates.
Josh Ulrich usually answers questions along these lines very informatively and quickly. One reasonable course of action is to wait to see if he does the same with this one.
--JJS
________________________________
From: Bert Gunter <bgunter.4567 at
2011 Apr 24
3
If Then Trouble
Dear R Helpers,
I have another one of those problems involving a very simple step, but due
to my inexperience I can't find a way to solve it. I had a look at a
number of on-line references, but they don't speak to this problem.
I have a variable with 20 values
> table (testY2$redgroups)
1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16
2018 Mar 05
2
Interpret List Label as Date from Quantmod getOptionChain
Hi R Helpers,
Is it possible to interpret the top level of the list as a date after downloading all the option chain data for a ticker?
For example, after I run
aapl_total<-getOptionChain("AAPL", NULL)
the top descriptor of the lists is a date (Mar.09.2018, Mar.23.2018, etc.).
So if want to subset down to those parts of the list that correspond to say, (expiration)
2011 Jul 16
2
Finding all rows of a matrix equal to vector
Hi everyone,
my question might be very trivial, but I could not come up with an answer...
I want to find out how often a matrix contains a certain vector as row:
x1<-c(1,2,3)
x2<-c(1,5,6)
x3<-c(7,8,9)
A<-matrix(c(rep(x1,5),rep(x2,5),rep(x3,5),rep(x1,5)),nrow=20,ncol=3,byrow=T)
How can I find out, how many times x1 is a row of A?
Thanks in advance and best regards,
Sebastian
2015 Oct 26
2
Still fighting localboot on EFI - looping
On 10/26/2015 1:46 PM, Geert Stappers via Syslinux wrote:
> On Mon, Oct 26, 2015 at 12:09:40PM -0600, Alan Sparks via Syslinux wrote:
>> I'm still trying fruitlessly to get some sort of local disk boot from
>> syslinux EFI to work... using the 6.03 modules. Tried various
>> combinations of configurations on Gene's test binaries.
>
> The test binariers Gene
2010 Feb 20
3
aggregating using 'with' function
Hi All,
I am interested in aggregating a data frame based on 2
categories--mean effect size (r) for each 'id's' 'mod1'. The
'with' function works well when aggregating on one category (e.g.,
based on 'id' below) but doesnt work if I try 2 categories. How can
this be accomplished?
# sample data
id<-c(1,1,1,rep(4:12))
n<-c(10,20,13,22,28,12,12,36,19,12,