S-plus question about length of data

In summary, the user is trying to program the Exponential Integral function and make it compute values for a vector of data. They have written a function called "expint" but are getting an error when trying to use it with a vector of values. The error may be related to the length of the vector not being a multiple of 15 and a warning message about the condition having 72 elements. More information about the vector and its use may be needed for further assistance.
  • #1
ToxicBug
84
0
Hello, I'm trying to figure out how to program the Exponential Integral function, and then make it compute values for a vector of data.

I have this:
Code:
expint <- function(s){ 
     integrand <- function(x) {exp(x)/x} 
     integrate(integrand, lower = -Inf, upper = s)$integral
}

if I put expint(-1) then it works, but it doesn't work if I put expint(vectorofvalues), it gives me the following error:

Warning messages:
1: Condition has 72 elements: only the first used in: e1 && e2
2: Condition has 72 elements: only the first used in: e1 || e2
Problem in bound + (sgn * (1 - nodes))/nodes: length of longer operand (72) should be a multiple of length of shorter (15)

Anyone know what I need to change for it to work with vectors?
 
Physics news on Phys.org
  • #2
It looks like you need to make sure the length of your vector is a multiple of 15. You might also want to look into the "condition has 72 elements" warning, as that could be related to the error you are getting. If you can provide more information about what your vector is and how it is being used, it may help other users give you more specific advice.
 
  • #3


I would suggest first checking the length of the vector of values you are trying to input into the function. It seems that the length of the vector is causing an issue with the integration process. You may need to adjust the code to accommodate for a vector input, such as using a for loop or vectorized operations. Additionally, you may need to consider the bounds of integration for each element in the vector. It may be helpful to consult a programming expert or reference materials on vectorized functions for further assistance.
 

Related to S-plus question about length of data

What is the importance of determining the length of data in S-plus?

The length of data in S-plus is important because it allows us to understand the size and complexity of our data. This information can help us make decisions about how to analyze and visualize the data, and also identify any potential limitations or biases.

How do I find the length of my data in S-plus?

To find the length of your data in S-plus, you can use the length() function. Simply input the name of the dataset or object you want to find the length of, and the function will return the number of observations or elements in that dataset.

Can the length of data in S-plus change?

Yes, the length of data in S-plus can change depending on how the data is manipulated. For example, if you add or remove observations or elements from a dataset, the length will be affected. Additionally, if you filter or subset the data, the length will also change.

What is the difference between length and size in S-plus?

In S-plus, length refers to the number of observations or elements in a dataset, while size refers to the total number of bytes used to store the data. The size of a dataset can be affected by the type and format of the data, while the length remains constant.

Why is it important to check the length of data in S-plus before and after data manipulation?

Checking the length of data in S-plus before and after manipulation is important to ensure that the data has been processed correctly. If there is a significant change in length, it may indicate an error in the manipulation process or the presence of missing data. This can help identify and troubleshoot any issues with the data.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
504
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • STEM Educators and Teaching
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
999
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Replies
3
Views
843
Back
Top