similar to: If Then Trouble

Displaying 20 results from an estimated 1000 matches similar to: "If Then Trouble"

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
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)) >
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)
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
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
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
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 Mar 21
3
Replacing Period in String
Dear R Users, I am working with gsub for the first time. I am trying to remove some characters from a string. I have hit the problem where the period is the shorthand for 'everything' in the R language when what I want to remove is the actual periods. In the example below, I simply want to remove the periods as I have removed the comma, but instead the complete string is wiped out. I
2023 Apr 04
1
Simple Stacking of Two Columns
Just to repeat: you have NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly")) and you want NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly")) There must be something I am missing, because NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2)) appears to
2011 May 15
1
Find String Between Characters
Dear R Helpers, I am trying to isolate a set of characters between two other characters in a long string file. I tried some of the examples on the R help pages and elsewhere, but I am not able to get it. Your help would be much appreciated. require(scrapeR)
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 Apr 15
2
Remove Rows Based on Factor
Dear R Helpers, I did a search for deleting rows based on conditions but wasn't able to find an example that addressed the error that I am getting. I am hoping that this is a simple syntax phenomenon that somebody else knows off the top of their head. My apologies for not providing a reproducible example but I think that the information given will allow someone to give me a hint. I want to
2011 Apr 13
1
Assign with Paste Problem
Dear R Helpers, I am trying to change the name of an object using the assign function. When I use paste on the new object but not the old, everything is fine: The new object is a direct copy of the old object. When I use a paste for both the new and the old object, however, the new object is simply the character representation of the old object name, not the old object itself. The example
2011 Mar 18
1
quantmod Some Single Letter Tickers Not getFin
Hi, I have been learning the quantmod package over the last several days. I went to check some of my data pulls against other sources and was surprised to find that a few tickers that have single characters do not successfully scrape from Google Finance using getFin(). Particularly require(quantmod) getFin("A") getFin("E") getFin("F") getFin("G")
2005 Mar 29
2
dependency help for FC2 rpm
I am having difficulty with dependencies for the R rpm for Fedora Core 2. In attempting to load R-2.0.0.0.fdr.1.fc2.i386.rpm it fails the libtk8.4.so dependency even though I have this library loaded. The library is located in: /usr/local/lib. How might I tell R where to find this library? I am new to Linux and loading rpms so I am hoping there is a simple answer and that the problem is
2011 May 24
2
Apply or Tapply to Build Set of Tables
Dear R Helpers, First, I apologize for asking for help on the first of my topics. I have been looking at the posts and pages for apply, tapply etc, and I know that the solution to this must be ridiculously easy, but I just can't seem to get my brain around it. If I want to produce a set of tables for all the variables in my data, how can I do that without having to type them into the table
2012 Mar 04
1
quantmod getOptionChain Not Work
Dear R Helpers, I am still having trouble with the getOptionChain command in quantmod. I have the latest version of quantmod, etc. so I was under the impression that the problem was solved with updates to the package. If someone could let me know what I need to install in order to make this work, I would really appreciate it. My error message as session info are shown below. Thanks a bunch.
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:
2011 Oct 10
3
Superposing mean line to xyplot
Dear R-users, I'm using lattice package and function xyplot for the first time so you will excuse me for my inexperience. I'm facing quite a simple problem but I'm having troubles on how to solve it, I've read tons of old mails in the archives and looked at some slides from?Deepayan Sarkar but still can not get the point. This is the context. I've got data on 9 microRNAs, each
2009 Oct 20
8
Stub that returns hash values
Is it possible to create a stub that returns hash values. For example I would like to convert this: @siteItem = stub(''plmSiteItem'', :one => "uno") To something like this: @siteItem = stub(''plmSiteItem'', {''one'' => ''uno'', ''two'' => ''dos''} ) So that I can do this: