R won't return vesctor | بلاگ

R won't return vesctor

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I'm writing a program in R and I create the following vector:

nums <- c(224, 352, 320, 352, 352, 352, 223, 223, 352, 368, 368, 368, 368, 56, 309, 256)

I then print it out, like so:

print(nums)

It runs, but doesn't print anything out. If I run it through a function, and return nums, it prints NULL. I tried putting just the 2 lines above into a new file and running it and it returns:

224 352 320 352 352

Earlier in the testing process, I typed into the command prompt:

> nums <- c(224, 352, 320, 352, 352)
> nums
[1] 224 352 320 352 352
> for(i in nums){}
> print(nums[i])
[1] NA
> for(i in nums){print(nums[i])}
[1] NA
[1] NA
[1] NA
[1] NA
[1] NA
> nums[1]
[1] 224
> nums[1:3]
[1] 224 352 320

Why is it doing this?

asked 57 secs ago
Stacey K.

...
نویسنده : استخدام کار بازدید : 7 تاريخ : جمعه 25 اسفند 1396 ساعت: 1:52