Error while loading Rdata file in R - r

I used the following command to load an Rdata file:
xk <- load("sarima_data.Rdata")
plot(xk)
The following Errors occur :
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
How to resolve this issue in R?

Related

Keep getting the same error when I try to plot this data, what could be the issue?

Here is the code and the error message I keep getting
# Plot volume vs. basal area
plot(tree_dat$ba, tree_dat$vol, xlab= "Basal Area (ft^2)", ylab = "Volume (Intl. 1/4-in BF)")
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

Plotting data in R: Error in plot.window(...) : need finite 'xlim' values

Trying to plot some data in R - I am a basic user and teaching myself. However, whenever I try to plot, it fails, and I am not sure why.
> View(Pokemon_BST)
> Pokemon_BST <- read.csv("~/Documents/Pokemon/Pokemon_BST.csv")
> View(Pokemon_BST)
> plot("Type_ID", "Gender_ID")
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf
This is my code, but I thought it might be an issue with my .csv file? I have attributed numbers to the "Type_ID" and "Gender_ID" columns. Type_ID has values between 1-20; Gender_ID has 1 for male, 2 for female, and 3 for both. I should state that both ID columns are just made of numeric values. Nothing more.
I then tried using barplot function. This error occurred:
> barplot("Gender_ID", "Type_ID")
Error in width/2 : non-numeric argument to binary operator
In addition: Warning message:
In mean.default(width) : argument is not numeric or logical: returning NA
There are no missing values, no characters within these columns, nothing that SHOULD cause an error according to my basic knowledge. I am just not sure what is going wrong.
To me it seems as you are giving the plot function the wrong inputs.
For the x and y axis plot expects numeric values and you are only providing a single string. The function does not know that the "Type_ID" and "Gender_ID" come from the Pokemon_BST data frame.
To reach your data you must tell R where the object comes from. You do this by opening square brackets behind the object you want to access and write the names of the objects to be accessed into it.
View(Pokemon_BST)
Pokemon_BST <- read.csv("~/Documents/Pokemon/Pokemon_BST.csv")
# Refer to the object
plot(Pokemon_BST["Type_ID"], Pokemon_BST["Gender_ID"])
# Sould also work now
barplot(Pokemon_BST["Gender_ID"], Pokemon_BST["Type_ID"])
See also here for a introduction on subsetting in R
The problem is how you're passing the values to the plot function. In your code above, "Gender_ID" is just some string and the plot function doesn't know what to do with that. One way to plot your values is to pass the vectors Pokemon_BST$Gender_ID and Pokemon_BST$Type_ID to the function.
Here's a sample dataframe with the plot you were intending.
Pokemon_BST <- data.frame(
Type_ID = sample(1:20, 10, replace = TRUE),
Gender_ID = sample(1:3, 10, replace = TRUE))
plot(Pokemon_BST$Gender_ID, Pokemon_BST$Type_ID)

Opening .tiff gives me a plot.window() error

I created a raster and saved it as a .tif file. However, when I tried to open the .tiff, I get the following error:
> plot("20200105.tif")
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
The strange thing is, before I saved the file it worked fine.
How do I manage this error?
This make no sense
plot("20200105.tif")
You are trying to plot a character string
Instead do
library(raster)
r <- raster("20200105.tif")
# or
# b <- brick("20200105.tif")
plot(r)

nonlinear least squares troubleshooting

I am trying to run a nonlinear least squares regression in R and keep coming across the same error message which I can't seem to fix.
My function so far:
nls(y ~ 1033.89+(2461*cos*(2*3.14*(t-18)/24)),
data=data.frame, start=list(x=1, y=1))
where t=c(1:24) and data.frame contains x and y variables of equal length.
This error message continues to pop up:
Error in parse(text = x, keep.source = FALSE) :
:2:0: unexpected end of input
1: ~
^
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
Any suggestions?

Hi all i am ploting a graph between in R

I am plotting a graph between 2 variable in R.
Time and city are variable in city.
like my code plot(time ~ City,table)
i am getting below error message..
could you please any one advise..
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Maybe try using the following syntax
plot(1:10,21:30)
Or, probably in your case
plot(table$time,table$City)
Good luck with it! The start is always difficult.

Resources