R

169

Solutions

354

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

Are there any recommended Python, R and SQL source code samples which should read for learning purpose and which can be downloaded from GitHub?
0
Can any one help with LC/MS R packages?

The xcms R package for LCMS is very versitile.  It distinguishes between Grouping FTICR-MS data with xcms, LCMS and LCMSMS.  

Quoting from the documentation
This document describes how to use xcms for the analysis of direct injection mass spec data, including peak detection, calibration and correspondence (grouping of peaks across samples). Prior to any other analysis step, peaks have to be identified in the mass spec data. In contrast to the typical metabolomics workflow, in which peaks are identified in the chromatographic (time) dimension, in direct injection mass spec data sets peaks are identified in the m/z dimension. xcms uses functionality from the MassSpecWavelet package to identify such peaks.
 

I cannot find any information related to direct injection.  I understand FTCIR-MS and the reason why peaks can be identified in the m/z dimension, but I don't understand the concept of direct injection and whether this concept is associated with FTICR-MS only and not with LC/MS or LC.MS/MS.
0
VB application that sends PowerShell commands and receives the output.

I am putting the output in to a List view.

The following works fine:

 
[code]      For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties("name").Value.ToString() ' ### WORKS FINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

[/code]


When passed as a variable I get the following:

  For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties(strHeadDSingle).Value.ToString()          ' ### ERRORS THIS LINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

     


it works 100% as a stated item.

When I try to make my reusable code I get the following on this line when debugging:

System.NullReferenceException
Object reference not set to an instance of an object.

I have checked and values are there quite happily... but little confused.,

Please advise

Many thanks in advance

R
0
I'll appreciate if you can suggest the best and easiest CDN option to be integrated to Prestashop. Our target market is Mexico.

Thanks

Luis R
0
Private Sub GetEmployee()
        'Clear COMBOBOX...
        cmbEmployee.Items.Clear()
        OLEDBControls.ExecQuery("SELECT empId,empName FROM Employees;")
        'If Records are found, then add them to COMBOBOX....
        If OLEDBControls.RecordCount > 0 Then
            For Each r As DataRow In OLEDBControls.OledbDS.Tables(0).Rows
                cmbEmployee.Items.Add(r("empName"))
            Next
            cmbEmployee.SelectedIndex = 0
            cmbEmployee.MaxDropDownItems = 5
            cmbEmployee.ValueMember = "empId"
            cmbEmployee.DisplayMember = "Name"

        ElseIf OLEDBControls.Exception <> "" Then
            'Report Error..
            MsgBox(OLEDBControls.Exception)
        End If
    End Sub

    Private Sub GetEmpID()
        Dim id As Integer
        id = Me.cmbSite.SelectedValue
        MsgBox(id)
    End Sub

    Private Sub cmbEmployee_DropDown(sender As Object, e As EventArgs) Handles cmbEmployee.DropDown
        GetEmployee()
    End Sub

    Private Sub CmbEmployee_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbEmployee.SelectedIndexChanged
        GetEmpID()
    End Sub

Please I want to return the employee id for a selected Text but it returns zero...please need your help
0
Hi Experts

I want to change the following line of R Script code in my current code so the R Script finds the mini date from column "RecordDate" and an maximum date as opposed to using start=c(2018, 5), end=c(2019, 5), frequency=12). and second part is to use column "Count" to get our date points for those date as opposed to using data2 <- ts(c(9,9,14,4,14,15,4,14,17,17,19,16). need to make the R Script more dynamic.

#Begin first set of commands 
library(ggplot2)
library(trend)
library(zoo)
library(dplyr)
library(Kendall)
#End of first set of commands


#Begin second set of commands
data2 <- ts(c(9,9,14,4,14,15,4,14,17,17,19,16), start=c(2018, 5), end=c(2019, 5), frequency=12)
  mk.test(data2)
  data1X <- c(1:length(data1))
  data1Fit <- lm(data1~data1X)
  data1df <- data.frame(date=as.Date(time(data1)), Y=as.matrix(data1))
  ggplot(data=data1df, mapping=aes(x=date, y=Y, ymin = 0))+geom_point() +
    geom_line(color='blue') +
    stat_smooth(method = "lm", col = "red") +
    xlab("Months") + 
    ylab("Complaints") +
    scale_x_date(date_breaks = "1 month", date_labels = '%b %y') +
    labs(title = paste("Adj R2 = ",signif(summary(data1Fit)$adj.r.squared, 5),
                       " Slope =",signif(data1Fit$coef[[2]], 5)))
  #End of second set of commands
  

Open in new window

0
Hi,
I have finally confronted my fears of learning SQL Server
and have managed to export my entire UKHR database to it.
Up until now I have used Excel exclusively as a database and to run regressions
Due to the excessive number of files around 20, with
some of them well and truly exceeding the Excel limits I felt it
was well overdue for me to, shall we say, move on.
I'm hoping some of you would guide me in the direction of a suitable
alternative to Excel. Using SQL Server as a Database Management System.
R springs to mind along with a couple of statistical software packages. One
that I have a licensed copy for is Stata which is now 13 years old. I never had
got my head around it.
If someone can point me in the right direction I would be most appreciative.
Many Thanks
Ian
0
I am running the following query in SSMS:

UPDATE LS.FLIB2.S0647D36.LIB2.MADR SET ADUUCB = 'YES'
 FROM LS_LIB2.S0647D36.LIB2.MADR MBAD
	INNER JOIN V_READY_TO_SHIP R
		ON MBAD.ADCVNB = R.[CO#] AND MBAD.ADDRNB = R.RELEASE_NUMBER
		AND MBAD.ADFCNB = R.LINE_NUMBER AND MBAD.ADAASZ = R.KIT_RELEASE_NUMBER

Open in new window


and getting the following error msg:

Msg 7352, Level 16, State 1, Line 1
The OLE DB provider "IBMDASQL" for linked server "XA_AMFLIB2" supplied inconsistent metadata. The object "(user generated expression)" was missing the expected column "Bmk1000".

Open in new window


The V_READY_TO_SHIP is a SQL Server table and LS.FLIB2.S0647D36.LIB2.MADR  is a file on a AS400.  My only option would be to send the content of the V_READY_TO_SHIP to a AS400 file and run the update query from there but I would prefer to run it on the SQL Server instance because it is part of a longer process. happening in SQL Server.

Any ideas?
0
Cisco R setting DHCP-PD , right method is set a WAN pre 64 bit hex IPv6 left the local mac layer identify ?

The using R wire Cisco only allowed a NAME just  , example 2002 ,  which was on Rv042G set DHCP-PD 2002:: Prefix , is the current Router under previous Rv042G stored at the Server of Cisco caused this ?  Or the apply wont' be processed going on ?
0
I am trying to figure out what is causing my laptop to freeze at random points during the day.  It seems to happen more often when I am connected to external monitor via HDMI, but cant pinpoint what is actually causing it.  What happens is no .exe will process and it "freezes" exes from starting for 15-60 seconds then all of a sudden it "wakes up" and runs all the queued .exe files.  
So when I realize its stopped allowing new things ill hit windows r (i DO get the run box) and type cmd and hit enter...run box goes away but cmd wont launch for 15-60 seconds and then boom everything ive done in those 15-60 seconds happens in an instant (command prompt box opens, calculator opens, changing tabs in chrome  etc).  Then everything is fine and works for another hour or more (random when it does/doesnt happen).  I CAN alt/tab and change between windows, but if I try to do anything in that window it wont work (until it wakes up and does all the stored tasks), I CANT ctrl-alt-del, its another exe that gets "put in queue" and again,  it will pop up along with my command prompt etc.
I have ran memory checks, sfc, cclean, mbam - running on an SSD for primary OS - no errors that I can tell.
I did just install process explorer but not sure how to pinpoint the "queue"...once everything is in "freeze mode" what do I look for on process explorer?
0
hi, i can get postman to POST to create a VM but using pycharm encountered this error.

code 1: obtain a token
==========================================================================
import requests
url = "https://IP/silvan/apigateway/v1.0/"
get_apis = "apis_include_throttles"

##API URLs
get_token_url = "https://iam-apigateway-proxy.domain.com/v3/auth/tokens"

create_volume_url = "https://evs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes"
delete_volume_url = "https://evs.stic-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes/"
create_vm_url = "https://ecs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/servers"



##Images Dictionary
images = {
    "Ubuntu 18.10": "5313ace4-4573-404b-abc6-8548ed14c4f7",
    "RHEL7.5-40G": "aa9d05f3-cb90-4776-9c02-617a9906b271",
    "WindowsServer2016WithGUI": "c54d05fa-5ad8-425e-be56-e60ede395230",
    "Windows10Pro": "29caef55-0617-4813-8a17-cb0bef19de16",
    "RHEL7.5": "c5ccd8a7-d8f3-4a4c-91c3-9d93303aee58",
    "Ubuntu16.04LTS": "3f8948fd-c108-48db-9951-1d617e8e5b03",
    "image-kvm-euler": "298e2912-5a7a-4178-8ac4-b260712d514c",
    "image-ManageOne": "80d9b0ee-a5b3-42fe-99ed-fc32c57da5b3",
    "esight_image": "e1e94234-f3e7-4793-8bdb-0cef9e3194cf"
}


def get_token():
    body = {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
    …
0
hi,

why can't delete my system volumes with error. checked has no more VM, snaps, etc.

use postman to delete with error. ps check my postman.
2.jpg
use python script to delete with error. ps check my python code

import requests

get_token_url = "https://iam-apigateway-proxy.domain.com/v3/auth/tokens"

body = {
    "auth": {
        "identity": {
            "methods": [
                "password"
            ],
            "password": {
                "user": {
                    "domain": {
                        "name": "XXXXX"
                    },
                    "name": "XXXXX",
                    "password": "XXXXX"
                }
            }
        },
        "scope": {
            "project": {
                "id": "cd088007d3b84e7fa894478e6fe667c4",
                "domain": {
                    "name": "XXXXX"
                }
            }
        }
    }
}

# POST to the API
results = requests.post(get_token_url, json=body, verify=False)


token = results.headers['X-Subject-Token']

#Deletion

volume_id = [
    'c3b803ee-f1ab-428d-bc55-01b380c36d49',
    '065ba0b3-959a-4dc0-af23-17b8a1099367',
    'b282ea13-5e24-48fb-b7e2-84fce0973621',
    'aa87fc71-ae1b-47ee-82fc-bcd73a59538d',
    'a72cc934-473e-4cde-8eb0-743ca058e350'

]

delete_url = "https://evs.domain.com/v2/cd088007d3b84e7fa894478e6fe667c4/volumes/"
headers = {
    'content-type': "application/json",
    …
0
How is
model <- lm(
           formula = Petal.Width ~ Petal.Length,
            data = iris
            )
different from
model <- lm(
            formula = iris$Petal.Width ~ iris$Petal.Length,
            data = iris
            )

The output of both the commands are same but my prediction output differs.
NOTE: I had assumed Petal.Width is same as iris$Petal.Width, clearly they are not. I don't understand how are they different.
Attached RScript contains complete code
0
I would like to change the node names of my data.tree object (tjpCPI) from IDs to readable tags. A sample of the tree structure is here:
> print(tjpCPI, "CPI.Tag")
                                levelName                          CPI.Tag
1   378257447                                                          CPI
2    ¦--378257497                                                     Food
3    ¦   ¦--378259447                                              Cereals
4    ¦   ¦   ¦--378259457                                             Rice
5    ¦   ¦   ¦   ¦--378259467                                Non Glutinous
6    ¦   ¦   ¦   ¦   ¦--378259477                                   Rice-A
7    ¦   ¦   ¦   ¦   °--378259487                                   Rice-B
8    ¦   ¦   ¦   °--378259497                                    Glutinous
9    ¦   ¦   ¦--378259507                                            Bread
10   ¦   ¦   ¦   ¦--378259517                                  White Bread
11   ¦   ¦   ¦   ¦--378259527                                Bean Jam Buns
12   ¦   ¦   ¦   °--378259537                                   Curry Buns
13   ¦   ¦   ¦--378259547                                          Noodles

I would like levelName to become CPI.Tag.

How might I do that without needing to iterate through each node?
0
I would like to change the names of the members of the list. The list is of a CPI hierarchy - the trouble is the names are now ID numbers, that are difficult to interpret. Each one of the members has a readable tag, that is "CPI.Tag".

How would I swap the label that is used for the name  currently to the "CPI.Tag"? (the display of a few sample members is attached)
2018-08-14_13-32-00.png

I thought it would be something along the lines of names(jpCPIlist)<-jpCPIlist$CPI.Tag, but evidently not..
0
How to remove any character from a string if it is not part of the below "x character set" .
Remove a character from a given string -if it is not part of the below x character set.
X character set: After removing the character there should not be any space on the character that gets removed.
---------------------
a b c d e f g h I j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9
/ - ? : ( ) . , ‘ +

Example
     '020?Dome@&++;stic CT out;%going?20测试叙事测试叙事@@@@test'
Expected output is
    020?Dome++stic CT outgoing?20test


I am using the below query but it is replacing '+'. I don't want to replace this + because it a part of x character set.

select translate(REGEXP_REPLACE ('020?Dome@&++;stic CT out;%going?20测试叙事测试叙事@@@@test','[^' || CHR(32) ||'-' ||CHR (127) || ']', ''),'+=!“%&*<>;{@#_',' ') AS TEST from dual;
0
I need to execute a substring function on each row of a single column dataframe in R Studio, then assign that value to a new dataframe.
0
Hello,
I'm trying to pass a value to a List, but I get an error Cannot implicitly convert System.Collections.Generic.List<char> to System.Collections.Generic.List<string>.
So, here's my code...
public List<string> NomeContrato { get; set; }

Open in new window


BindingSource bs = new BindingSource();
            bs.DataSource = LoadContratos();
            var editForm = new Concelhos_Edit();
            var editFormModel = new Info();
            editFormModel.Id = concelhos_datagrid.CurrentRow.Cells[0].Value.ToString();
            var _nomeContrato = contratosdt.AsEnumerable().FirstOrDefault(a => a.Field<int>("IdContrato") == ((DataRowView)bs.Current).Row.Field<int>("IdContrato")).Field<string>("Designacao");
            editFormModel.NomeContrato = _nomeContrato.ToList(); //--> Here's where the code breaks and get Error!

Open in new window


Changing this
public List<string> NomeContrato { get; set; }

Open in new window

to this
public List<char> NomeContrato { get; set; }

Open in new window

, I get my Combobox with one letter per line, like this...
W
o
r
l
d

Any help?
Thanks.
0
I would like to perform fractal analysis on a financial series (stock exchange index). What shall I use (prices or log returns) for calculating fractal dimension, Hurst Exponent, for performing R/S Analysis and for predictions? Are there R functions that calculate all of these immediately? Are there any things I need to take care of when analyzing the index? Thank you in advance!
0
First of all I am doing a program kinda simple long program, here is the full details:

The P-v-T relation for real gases can take many forms. The simplest relations are the ideal gas equation and the Van der Waals equation. These relations are to be applied to superheated steam. The file “pvt.txt” contains the P-v-T data of superheated steam (10 – 800 kPa) for the temperature range of 200 oC through 1200 oC, obtained from the steam tables.

Write a C program to read the steam table data “pvt.txt”. In the C program, estimate the density of steam for the pressure range 10 through 800 kPa, and temperature range 200 oC through 1200 oC,

(1) Using the ideal-gas relation: m3/kg where R = 0.4615 kJ/kgK, T is temperature [K] and P is pressure [kPa].

(2) Using the Van der Waals equation:

where R = 0.4615 kJ/kgK, T is temperature [K] and P is pressure [kPa]. The constants are obtained from and where Pcr = 22060 kPa and Tcr = 647.1 K.

In each case, calculate the resulting percentage error of the estimated density as follows: Error = x 100% Submit a report which must include: 1. Introduction, algorithm or flowchart, the C program, and the density from steam table. 2. The estimated density table when using the ideal gas equation. 3. The percentage error table when using the ideal gas equation. 4. The estimated density table when using the Van der Waals equation. 5. The percentage error table when using the Van der Waals equation. 6. Discussion and conclusion. Note: Density…
0
Please help i want the image to be in canny edge n perform fuzzy logic with this code

img1=imread('F:\Matlab Project\7 sem\currency\10.jpg')




Igray = 0.2989*img4(:,:,1)+0.5870*img4(:,:,2)+0.1140*img4(:,:,3);
%Igray1=edge(Igray,'Canny');
%figure
%image(Igray,'CDataMapping','scaled');
%colormap('gray')
%title('Input Image in Grayscale')

%Convert Image to Double-Precision Data
I = double(Igray);


%Scaling the factor
classType = class(Igray);
scalingFactor = double(intmax(classType));
I = I/scalingFactor;

%Obtain the Image Gradient

Gx = [-1 1];
Gy = Gx';
Ix = conv2(I,Gx,'same');
Iy = conv2(I,Gy,'same');

%figure
%image(Ix,'CDataMapping','scaled')
%colormap('gray')
%title('Ix')

%figure
%image(Iy,'CDataMapping','scaled')
%colormap('gray')
%title('Iy')

%Define the Fuzzy Inferences System
edgeFIS = newfis('edgeDetection');

%Specify the image gradients, Ix and Iy, as the inputs of edgeFIS
edgeFIS = addvar(edgeFIS,'input','Ix',[-1 1]);
edgeFIS = addvar(edgeFIS,'input','Iy',[-1 1]);

%
sx = 0.1;
sy = 0.1;
edgeFIS = addmf(edgeFIS,'input',1,'zero','gaussmf',[sx 0]);
edgeFIS = addmf(edgeFIS,'input',2,'zero','gaussmf',[sy 0]);
%
edgeFIS = addvar(edgeFIS,'output','Iout',[0 1]);

%Specify the triangular membership functions, white and black, for Iout.
wa = 0.1;
wb = 1;
wc = 1;
ba = 0;
bb = 0;
bc = 0.7;
edgeFIS = addmf(edgeFIS,'output',1,'white','trimf',[wa wb wc]);
edgeFIS = addmf(edgeFIS,'output',1,'black','trimf',[ba …
0
Hi all,
I am not able to extract data from a package in r called rdota2. Wanted to run a function name get_league_listing from the package. Shows the following error-"Error in (function (..., deparse.level = 1, make.row.names = TRUE, stringsAsFactors = default.stringsAsFactors())  :
  numbers of columns of arguments do not match". please help me out. Thanks in advance.
0
Hi

I am looking for a way to capture standard error and redirect it to standard output in R (Shiny). I can not find any information any where in the web. Is there a way to do this?  the error gets displayed to the console, but I would like to displayed in the Shiny GUI.

Thanks
0
Hi,
 Although the program used to run smoothly on win98 and VB5 now cannot read the pixel info of an image (ie. jpg or gif) and therefore cannot proceed
 to calculate the Lab pixel values from RGB? In particular I have test pics of 100x100 pixel and program now reads 585x1890 !!  Any ideas?

 Following is the part of the program

 Cheers
 Public Sub Command1_Click()

 Dim OFName As OPENFILENAME
 OFName.lStructSize = Len(OFName)
 'Set the parent window
 OFName.hwndOwner = Me.hwnd
 'Set the application's instance
 OFName.hInstance = App.hInstance
 'Select a filter
 OFName.lpstrFilter = "Image Files (*.bmp;*.jpg;*.png)" + Chr$(0) + "*.bmp;*.jpg;*.png" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
 'create a buffer for the file
 OFName.lpstrFile = Space$(254)
 'set the maximum length of a returned file
 OFName.nMaxFile = 255
 'Create a buffer for the file title
 OFName.lpstrFileTitle = Space$(254)
 'Set the maximum length of a returned file title
 OFName.nMaxFileTitle = 255
 'Set the initial directory
 OFName.lpstrInitialDir = "C:\"
 'Set the title
 OFName.lpstrTitle = "Open File"
 'No flags
 OFName.flags = 0

 'Show the 'Open File'-dialog
 If GetOpenFileName(OFName) Then
 Label2 = Trim$(OFName.lpstrFile)

 End If

 End Sub

 Private Sub Command2_Click()
 Dim PicInfo As BITMAP
 Dim pic As Picture
 Dim X, Y As Long
 Dim height, width As Long
 Dim R As Long
 Dim imagesource As String
 Dim hFile As Long, FileInfo As BY_HANDLE_FILE_INFORMATION
 Dim Red, 

Open in new window

0
Hi

So if I manually connect using sftp from a centos box to my Proftpd server and issue a get command to grab a file, all's good.

If I do it in a script, it fails after getting the file  (next step would be to delete the file which it never does)

It's driving me round the bend abit, so any help would be greatly appreciated.

on the sftp client side
Log from Scripted version
2018-03-15 12:34:35,029 [30711] <sftp:6>: received READ (5) SFTP request (request ID 11, channel ID 0)
2018-03-15 12:34:35,030 [30711] <sftp:7>: received request: READ 8fc9867310df242f 0 32768
2018-03-15 12:34:35,030 [30711] <sftp:8>: sending response: STATUS 1 'End of file' ('End of file' [-1])
2018-03-15 12:34:35,030 [30711] <ssh2:9>: sending CHANNEL_DATA (remote channel ID 0, 37 data bytes)
2018-03-15 12:34:35,030 [30711] <ssh2:19>: waiting for max of 600 secs while polling socket 1 using select(2)
2018-03-15 12:34:35,030 [30711] <ssh2:3>: sent SSH_MSG_CHANNEL_DATA (94) packet (80 bytes)
2018-03-15 12:34:35,031 [30711] <ssh2:11>: channel ID 0 remote window size currently at 2096633 bytes
2018-03-15 12:34:35,031 [30711] <ssh2:19>: waiting for max of 600 secs while polling socket 0 using select(2)
2018-03-15 12:34:35,031 [30711] <ssh2:20>: SSH2 packet len = 44 bytes
2018-03-15 12:34:35,031 [30711] <ssh2:20>: SSH2 packet padding len = 5 bytes
2018-03-15 12:34:35,031 [30711] <ssh2:20>: SSH2 packet payload len = 38 bytes
2018-03-15 12:34:35,031 [30711] <ssh2:19>: waiting for max of …
0

R

169

Solutions

354

Contributors

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

Top Experts In
R
<
Monthly
>