R

106

Solutions

254

Contributors

R is a programming language and environment used primarily for statistical data analysis.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have an excel spread sheet that has a column with either b, g or r
I would like to create a formula in a separate column which will convert this to either Blue, Green or red

Gordon
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Installing SQL 2017 we were asked to "Accept" on "Microsoft R Open".  We looked it up some sort of open source, but What is it to us Microsoft product users?, also  Why click "Accept" it in this SQL install? and How can we take advantage of this "Microsoft R Open"?
0
I have a data frame with some names (rows) and I have some positions that I want to use, for instance 35th row and 145th row. How do I get the names of the rows which are in this positions? I uploaded a print screen that may help understanding. Thanks!

I tried something like

names1 <- row.names(which(size_96 < median(size_96, na.rm= T)))
0
Hi, I have one data frame (df1) with 20 observations (one for each year) and 597 variables (each one is one stock). The values are a ratio called book-to-market ratio. I need to build two portfolios for each year which consists of the stocks with values lower than the median and stocks with values above the median. The names of the stocks are the columns from df1. So I need to check if each value from each row (each year) is below or above the median and identify each stock name (columns in df1). Then I need to match it with the columns from another data frame (df2) which has data from the return of each stock in each year (20x597). The end result would be a vector with 20 entries, which are the differences of average returns between the two portfolios. I hope it was clear enough, thanks for the answer and I`m here for any explanation.
0
TABLEI have a table with data R. Virgo (3 Rows). I want to query the most recent only the frist row and not all the data with this code:

    Private Sub DISPLAY()
        conn.Close()
        Dim cmd2 As New MySqlCommand
        Dim myDA2 As New MySqlDataAdapter(cmd2)
        Dim myDT2 As New DataTable
        cmd2.Connection = conn
        cmd2.CommandText = "SELECT * FROM esd_reco where IDNumber = '" & txtG.Text & "' ORDER BY Date DESC"
        myDA2.Fill(myDT2)
        dghistory.DataSource = myDT2
        conn.Close()

Open in new window


txtG.text is the ID Number
Help please, thank you.
0
Hi,

I've logged into a Microsoft R Server using mrsdeploy::remoteLogin()

Test with session:

REMOTE> result <- system("gpg --yes --batch -r [e-mail] --passphrase=[youPassphrase] --armor --utf8-strings --decrypt youFile", intern = TRUE)

REMOTE> result
character(0)
attr(,"status")
[1] 2

REMOTE> exit
>Logout from remote R session complete

Open in new window


Test without session:

result <- system("gpg --yes --batch -r [e-mail] --passphrase= youPassphrase] --armor --utf8-strings --decrypt youFile", intern = TRUE)

gpg: encrypted with 2048-bit RSA key, ID XXXXXXX, created 2017-11-20 "name<e-mail>"

>result
[1] "Esta es la frase\r"
[2] "que he encriptado\r"

Open in new window


I need that it work based on remote session because this way works on service.


Thanks for your reply.

Kind regards,
0
Best Ways To Get Smarter With Your Content And SEO

Despite the many ways Google has changed the search game over the last five years, one truth remains: content is the vehicle that drives your consumer interactions, engagements, experiences and, ultimately, conversions.

However, only 41 percent of marketers think their organization is clear on what an effective or successful content marketing program looks like, according to the Content Marketing Institute (CMI).

Marketers aren’t just lacking confidence in their efforts; these are real and measurable deficits. In fact, only 20 percent of B2C and 50 percent of B2B content earns any engagement at all, my company’s research has found.

That’s a lot of wasted effort and resources invested in content that ends up just floating around the web, winning zero business benefit for its creators.

In this article, we’re going to take a look at content through the SMART lens. SMART is a goal-setting framework in which S stands for Specific, M for measurable, A for achievable, R for relevant and T for timely.

Below is my variation that explains how to apply search engine optimization (SEO) to your content within a SMART framework, giving you 14 concrete ways to make your marketing more effective and to win you more business.

S — Specific Content Wins Every Time
Content is not about what your marketing team wants to say. It is about providing insight and information that your audience actually wants to hear.

0
Why the R Programming Language Will Become Your Go To Language
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
0
I had this question after viewing How to change this macro to find last column instead of A to J?.

Sub Commas2Rows()
  ' hiker95, 05/18/2017, ME1006027
  Dim lr As Long, lc As Long, r As Long, s, i As Long
  Application.ScreenUpdating = False
  With ActiveSheet
    lr = .Cells(Rows.Count, 1).End(xlUp).Row
    lc = .Cells(2, Columns.Count).End(xlToLeft).Column
    For r = lr To 2 Step -1
      If InStr(.Range("G" & r), ", ") Then
        s = Split(.Range("G" & r), ", ")
        .Rows(r + 1).Resize(UBound(s)).Insert
        .Range("G" & r).Resize(UBound(s) + 1) = Application.Transpose(s)
        .Range("A" & r + 1 & ":F" & r + 1).Resize(UBound(s)).Value = .Range("A" & r & ":F" & r).Value
'        .Range("H" & r + 1 & ":J" & r + 1).Resize(UBound(s)).Value = .Range("H" & r & ":J" & r).Value
        .Range("H" & r + 1 & ":" & Chr(64 + lc) & r + 1).Resize(UBound(s)).Value = .Range("H" & r & ":" & Chr(64 + lc) & r).Value
      End If
    Next r
  End With
  Application.ScreenUpdating = True
End Sub
0
I am putting the finishing touches on a tutorial about how to use R programming interfaced with MS-Excel. I decided to show how to obtain stock prices from Yahoo Finance. I realize that this can be done directly in Excel. However, R has some great libraries that make getting prices from third-party providers seamless. But, as you know, R is weak in its front-end feature. Besides, people who use spreadsheets regularly (or should I say religiously) can now take advantage of these libraries with the interface. They get the benefit of R without having to give up Excel. That's a win-win in my book.

I was wondering if this concept seems like something you would want to learn. There are many libraries (packages) developed in R and more are being developed constantly. Let me know if this sounds like a concept you want to learn
3
 
LVL 35

Expert Comment

by:[ fanpages ]
Hi James,

Your article, "Why R Programming Will Become Your Go To Language", has piqued my interest in learning more so, yes, the suggestion of a tutorial for an 'R' interface with MS-Excel is certainly something I would wish to read.

Thank you :)
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I have to install an R program and several open source proteomics programs in a linux box.  The R program calls the open source proteomics programs.  The pipe line starts by one of the programs taking as input a raw data file and all the programs produce output files some of which may be input to the other programs in the pipe line.  The users will be able to run the R program online.
1. Is it possible to do this? I am using the open open source version of RStudio which s single threaded (users responses to program requests wait until the previous user in the chain finishes running the pipeline. This implies that the proteomics programs called by R will be called by a single user at a time.

2.  Is there any way of synchronizing the linux box and the users pcs so that the files can be created in both the linux server and the PCs, otherwise the users will have to send the raw data file to the Linux box and to import data files from the linux box to their PCs.
0
The R program that we have calls other proteomics open source software installed in the user PCs.  I am going to install RStudio server and the Sniny server in linux so that everyone can access the program remotely.  The idea is to keep the proteomics software in the user PCS and just install the R program in the server.  Is this possible? Will the server be able to locate the software installed in the user PCs?
0
Guys I have codes here that is working in Numeric only.
I need a code that whatever is the last number it will generate the next number.Whether I changed the last or not it will generate a next number. Here's my code for the numeric number but I need to generate a number  using alpha-numeric.

Dim Ws As Worksheet
    Dim r As Long
    Dim ReqNo As String
    Set Ws = Worksheets("MainRecord")
getNum:
    r = Ws.Cells(Ws.Rows.Count, "D").End(xlUp)
    ReqNo = CODES.Text & "-" & r + 1
    If IsNumeric(Application.Match(ReqNo, Worksheets("MainRecord").Range("D:D"), False)) Then GoTo getNum
    On Error Resume Next
    Me.REQUESTNO.Value = ReqNo

I dont know what code to use.To generate an Alpha-Numeric number
0
Hi,
we are using xunit and moq for unit testing.
How can I "mock" a method which is taking readonlycollection<employee> and it is updating one of its property and returning readonlycollection<employee>?

I really appreciate your help.

The method is doing following functionality.

public async Task<ReadOnlyCollection<Employee>> CalculateAsync(ReadOnlyCollection<Employee> employees)
        {
            if (employees == null)
            {
                throw new ArgumentNullException(nameof(employees));
            }

            ReadOnlyCollection<int> Ids = employees.Select(x => x.Id).Distinct().ToList().AsReadOnly();

            var Results = (await Repository.GetAsync(Ids));          

            foreach (var r in Results)
            {
                var Employeeid= employee.FirstOrDefault(x => x.Id == r.Id);
                if Employeeid!= null)
                {
                    employee.BillDate = r.StartDate;
                }
            }

            return employee.ToList().AsReadOnly();

        }
0
 
LVL 25

Expert Comment

by:Brian B
You have entered this as a post, but it looks like it is a question. To get the best response from the Experts, you should probably re-submit this as a question using the "ask a question" button at the top of the screen, or this link: https://www.experts-exchange.com/askQuestion.jsp

Please see here for further details: http://support.experts-exchange.com/customer/portal/articles/756544-how-to-succeed-at-ee-as-an-asker
0
 
LVL 7

Expert Comment

by:Brian Matis
Also, Experts Exchange has text formatting support for code snippets which should help them be a little bit easier for others to read and copy. Be sure to try that out if you haven't already. When writing your question, just select the text that is for your code snippet and then choose the "CODE" formatting option.

Here's an example of what that would look like:
def myFunction(foo, bar):
    print(f"{foo} and {bar}")
    # more code goes here

Open in new window

   
Hope this helps, cheers!
0
In process of rebuilding...installed SSD...Win 7 / 64 Pro...new RAM...
All drivers installed...correctly...

HOWEVER...this bugger will NOT update BIOS...

According to Belarc which I ran before the rebuild...I have BIOS v2.7...
The latest BIOS on Toshiba download site is BIOS v4.10
Everytime I try to install the BIOS i get the error message......"This computer is not supported"...

Any suggestons appreciated...
0
We hv external consultants who will be stationed at our office to do
Data warehse statistical analysis using R & Python :
what are the risks to watch out for ?  We provide hardened PCs

Don't allow Internet access?
Any patches needed?
Secure Coding to adhere to?
0
I have this query that returns the count within each dollar range of quotes. I would like to add the sum of the dollar value of those quotes as well. Is that possible within this one query? If so, how would you do it?

SELECT T.RANGE AS [Range_Value],COUNT(*) AS [Number_of_Quotes]
FROM (
      SELECT CASE
            WHEN CONT_AMNT >=0 AND CONT_AMNT <= 1000 THEN ' 1) $0-$1000'
            WHEN CONT_AMNT >1000   AND CONT_AMNT <= 5000 THEN ' 2) $1000-$5000'
            WHEN CONT_AMNT >5000   AND CONT_AMNT <= 10000 THEN ' 3) $5000-$10000'
            WHEN CONT_AMNT >10000  AND CONT_AMNT <= 50000 THEN ' 4) $10000-$50000'
            WHEN CONT_AMNT >50000  AND CONT_AMNT <= 100000 THEN ' 5) $50000-$100000'
            WHEN CONT_AMNT >100000 AND CONT_AMNT <= 150000 THEN ' 6) $100000-$150000'
            WHEN CONT_AMNT >150000 AND CONT_AMNT <= 200000 THEN ' 7) $150000-$200000'
            WHEN CONT_AMNT >200000 AND CONT_AMNT <= 500000 THEN ' 8) $200000-$500000'
            WHEN CONT_AMNT >500000 AND CONT_AMNT <= 1000000 THEN ' 9) $500000-$1000000'
            WHEN CONT_AMNT >1000000 THEN '10) $1000000+'
     END AS RANGE
       FROM (
         SELECT SUM(TOTAL_SELL_PRC) AS CONT_AMNT,CUSTOMER_NUMBER AS CUSTNMBR
   FROM [CSTQUTHD]
   WHERE DATE_OF_QUOTE>= '2016/01/01' AND DATE_OF_QUOTE<'2016/12/31'
   GROUP BY CUSTOMER_NUMBER) R ) T
   GROUP BY T.RANGE
0
I dont think SQL can store a table with 190,005 columns and 5000 Rows.

What I have now.
Right now what I have is a table with 5001 observations. Each observation has 190,005 possible scenarios.  That's 950,215,005 rows.

My objective.
I would like to pivot this table so my observations is the first column and all the possible outcomes are columns.
The observation is an int and the possible observations are bit (basically yes or no for outcome).

I am using Microsoft SQL server 2016.

My goal.
I am trying to create a matrix to do correlation analysis. I will be bring the data into R some how i am sure that's going to be a challenge as well.

If SQL cant do it that's fine but how then can I get this data into a Text file from SQL?

Basically Type becomes columns and isTrue flag is now going horizontal so there is 1 row per Key. Remember there are 190,005 different Types for each member. Yes I do know every possible Type value. For the sake of this example I didnt think it would be wise to list all 190,005.
Here are my columns
Key, Type, isTrue
1,V3201,1
1,F123,0
1,S20341,0
2,99080,1
2,R4570,1
2,S26995,0
3,D4567,0
3,SX34526,0
3,F5678,1
3,E9807,1
3,ST5688,0

Open in new window


Thank you in advance for your help.
0
I am getting the following error when running make while trying to cross-compile OpenSSL:

make[1]: mips-linuxar: Command not found
Makefile:652: recipe for target 'libcrypto.a' failed
make[1]: *** [libcrypto.a] Error 127
make[1]: Leaving directory '/home/dev/openwrt/package/openssl-1.1.0f'
Makefile:128: recipe for target 'all' failed
make: *** [all] Error 2


From the Makefile:

PLATFORM=linux-generic32
OPTIONS=--cross-compile-prefix=mips-linux no-asan no-crypto-mdebug no-crypto-mdebug-backtrace no-ec_nistp_64_gcc_128 no-egd no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-ssl-trace no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic
CONFIGURE_ARGS=("linux-generic32", "--cross-compile-prefix=mips-linux")

ARFLAGS=
AR=$(CROSS_COMPILE)ar $(ARFLAGS) r


Line 652
      $(AR) $@ $?

I am new to this. Please tell me how I can make this question more useful.

Thank you.
Makefile
Configure
0
What does it mean to be "Always On"?
LVL 5
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

How to find the returns of multiple, irregular inflows & outflows over a short period, lets say in 4 months?

I don't want to use the XIRR as it gives the compounded annualized return, which will be misleading. I want to calculate the returns for the duration of the investment only.

For eg., please refer to the attached excel sheet which lists out 5 transactions of Buy & Sell over 4 months period.

Thanks and regards

R
Question.xlsx
0
Hi,
I received a new computer last week but cannot get Task Scheduler to successfully run a VBS script.  It says it is running but the spreadsheets are not updating.  I created a new script to open Notepad and type a few words and Task Scheduler says it is running, ran successfully, but it did not..Notepad never opened.

I can manually run both scripts and they work fine.  Spreadsheets get updated and Notepad opens, types a few words, and stays open until I close Notepad.

My company's computer support has not been able to help at this time and I am currently waiting for the next level of help.  However, that could be more than a week until someone contacts me.

Attached are some screen shots I hope will help, with some identifying text blacked out with a description of what info was there.

Would any of you have any ideas as to why the scripts work when I double click on them manually to get them to run but Task Scheduler will not successfully get them to run, even though it says they are running?

Thanks.
0
I run VMware 6.0 one of my ESXI hosts lose two datastores
This host has 4 datastores 3 are local ATA drives and one is NFS
Two 0f the ATA drives are Dead or Error.
If I restart the ESXI Host they come back.

I swapped the drives out with two other drives and the same thing happened Dead or Error after about 24 hours.

I was lucky to have Veeam B& R nd I was able to recover the VMs on those two datastores.

Is my ESXi host corrupted ? or do you guys think I have a hardware problem

I found this
http://www.enterprisedaddy.com/2017/06/datastore-shows-inactive-unplanned-pdl/

And ran those commands but I had no VMS running on these datastores

Maybe if I put the original drives back in the results may be different I would rather keep the existing drives in now

If there some sort of cache or something I need to clear on this host?

Thanks Tom
0
I have written the function below. It works, but is slow. On my windows 7 R installation, what should I do to get this function working with the parallel library? Or is there some other obvious performance improvement I could do?

I followed the answer which led me to try vectorising but the improvement is minimal. Given I have another 23 cores and 50GB of RAM available I suspect the biggest improvement would be parallel processing. Albeit tricky to do on my Windows OS and using my newly learnt R skills.

https://stackoverflow.com/questions/2908822/speed-up-the-loop-operation-in-r 

# Build the encoding function

  encode <- function(dataframe, columnName, code_key){
    
    library(dplyr)
    asc <- function(x) { strtoi(charToRaw(x),16L) }
    chr <- function(n) { rawToChar(as.raw(n)) } 
    encoded <- c()
    
    for (j in 1:length(dataframe[[columnName]])) {
      asc1<- NULL
      asc1 <- c()
      if((j%%(1E4)) == 0) {print(paste0(j," of ",length(dataframe[[columnName]]), " records processed"))}
      
      for (i in 1:nchar(dataframe[[columnName]][j])) {
        asc1[i] <- chr(asc(substr(dataframe[[columnName]][j], i, i ))  + i + code_key)  
        encoded[j] <- paste(asc1, collapse='')}} 
    
    encName <- paste0(columnName, "_Encoded")
    dataframe[[encName]] <- encoded
    return(dataframe)
    }

# Example data set to work function on

  df1 <- as.data.frame(rep(iris$Species, 10000))
  colnames(df1) <- "Species"
  df1$Species <- 

Open in new window

0
Please look at the following VBA code that relates to the attached spreadsheet. The relevant section of this sub is the second paragraph where the first line comment is 'Delete all data in the "TME" tab older than one week. The other paragraphs of this sub work fine as far as I can tell.

This section of the sub refers to the attached sheet, which is the TME tab of a much larger workbook. As you see, the intent of this section of the sub is to delete all records on the TME sheet older than one week from TODAY (the date in column I, Row 1 or relative cell 1,9). For reference, the formula in I1 is =(TODAY()-MOD(TODAY()-1,7))-3. This formula works fine - no need to change it.

The problem is that this second paragraph of the sub below does not actually do any deleting of rows. It also does not stop execution for any errors, but proceeds right on to the next section of the sub without doing anything. I want it to delete all rows from row 2 of the attached sheet and continue deleting until the date in column A is one week older than the date in cell I1.

What needs to be changed to this section of the sub to get it to properly delete the required rows?

Thanks!

Glenn S.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub sub1()
'Import the daily data from the Cognos extract
Dim rng As Range, region As Range, col As Range
Dim rcount As Long, r As …
0
I need to ensure ALL mandatory cells in a row are filled in before another row is added.  Please see attached file for example.  
I've intentionally left blank columns I, O, R and S.  
Before I add a second row, I'd like to see an error message identifying the unfilled cells, or even better those unfilled cells highlighted.
If this is not able to be done, any suggestions are most welcome.
EE-Assets-Multi-Road-Template.xlsx
0

R

106

Solutions

254

Contributors

R is a programming language and environment used primarily for statistical data analysis.