Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Integer data type vs Number data type

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 21, 2018 1:00 PM
(2189 views)

I have a column matrix, called "a", with x rows. I'm trying to create a matrix filled with 1's that has the same number x rows.

When I say newmat = [](N Rows(a), 2), I get the error "Expected integer for number of rows" when trying to create the matrix.

Type(3), and any other integer argument, will return "Integer" but Type(N Rows(a)) returns "Number". I tried setting the x rows to a variable name and trying that, but I get the same error. Is there another way to do this? I haven't found a way to convert a Number type to an Integer type on the boards or in the documentation.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

```
a = Random Index(100,10);
NewMat = J(N Rows(a),1,1); // Use the J() to do this
```

The above sample worked for me

Best

Uday

Uday

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

```
a = Random Index(100,10);
NewMat = J(N Rows(a),1,1); // Use the J() to do this
```

The above sample worked for me

Best

Uday

Uday

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Integer data type vs Number data type

Here are a couple of ways to create the matrix you are looking for

```
clear symbols();
a=[1 ,2 ,3];
b=j(n rows(a),1,1)
// or
b=a;
b[1::n rows(a)]=1;
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Integer data type vs Number data type

Hi @pen51,

@uday_guntupalli is correct that J() is exactly the right function for this. To get at the reason JMP is yelling at you is that certain JMP functions don't like to take variable names are arguments. If needed, you can solve these kinds of problems with an eval-parse-eval insert sequence like so:

`eval(parse(eval insert("newmat = [](^N Rows(a)^, 2)")));`

Please use Uday's solution, but this tip may help you later when you encounter a similar situation.

-- Cameron Willden