MWE: a dataframe shown below.
"TVF" "minEuler" "E_avg"
29.63 -12 3.65
30.00 -26 3.311
30.24 -72 8.247
30.82 -47 13.02
20.25 -6 2.085
14.53 -32 2.154
14.66 -1 1.44
24.12 -82 6.784
21.25 -35 4.309
25.82 -17 2.697
26.15 -42 2.832
18.38 -29 2.038
18.51 -80 5.514
14.67 -58 1.91
20.40 -166 2.786
26.50 -69 6.794
40.97 -12 24.852
18.98 -102 3.107
19.15 -75 3.85
40.54 -48 16.347
35.09 -41 18.847
28.15 -73 5.963
40.25 -94 21.82
24.28 -53 6.245
30.34 -42 25.578
CODE:
plot_ly(x = S_TVF_Euler_E_axes$TVF, y = S_TVF_Euler_E_axes$minEuler,
z = S_TVF_Euler_E_axes$E_avg, type = 'surface')
OUTPUT:
GOAL: Fit a surface to the scatter plot (or directly plot a surface). I could plot the scatterplot using plot_ly but the surface isn't working.
I have tried also this, which did not work for me.
I am new to 3D plots and any help or hint is greatly appreciated!
As explained by s_t, we need to have a matrix for plotting the surface. I tried a little different way, using the interp function from the package akima. I got the idea from the answer by "mschilli" here.
> S_TVF_Euler_E_axes_plotly <- with(S_TVF_Euler_E_axes, interp(TVF,
minEuler, E_avg, duplicate = "mean"))
> plot_ly(x = S_TVF_Euler_E_axes_plotly$x, y = S_TVF_Euler_E_axes_plotly$y,
z = S_TVF_Euler_E_axes_plotly$z, type = 'surface')
Now, I am worried if my surface is right or wrong, it doesn't match at all to the solution provided by s_t!
Related
I have followed this documentation https://rdrr.io/cran/hexbin/man/hexplom.html to build some scatter plot matrices for my continuous variables.
my data is like this
dep_delay temp dewp humid wind_speed precip visib date
1 39.02 28.04 64.43 11.50 13.24 0.00 10.00 2013-01-01
...
301 43 39.20 30.20 69.88 14.96 0.00 3.0 2013-03-25
...
1253 392 46.04 42.98 88.99 4.60 0.00 10.0 2013-12-21
my code
library(hexbin)
hexplom(~df_w_delays_num[1:7] , data = df_w_delays_num,
xbins = 15, colramp = BTC, varnames = c("dep\ndelay", "temp", "dew", "humidity", "wind\nspeed","wind\ngust", "precipi\ntation", "visibility"))
Does anyone know how to remove the ticks and values obstructing the names of my variables?
Try adding pscales = 0. pscales is documented in ?lattice::panel.pairs.
I have datasheets with multiple measurements that look like the following:
FILE DATE TIME LOC QUAD LAI SEL DIFN MTA SEM SMP
20 20210805 08:38:32 H 1161 2.80 0.68 0.145 49. 8. 4
ANGLES 7.000 23.00 38.00 53.00 68.00
CNTCT# 1.969 1.517 0.981 1.579 1.386
STDDEV 1.632 1.051 0.596 0.904 0.379
DISTS 1.008 1.087 1.270 1.662 2.670
GAPS 0.137 0.192 0.288 0.073 0.025
A 1 08:38:40 31.66 33.63 34.59 39.13 55.86
1 2 08:38:40 -5.0e-006
B 3 08:38:48 25.74 20.71 15.03 2.584 1.716
B 4 08:38:55 0.344 1.107 2.730 0.285 0.265
B 5 08:39:02 3.211 5.105 13.01 4.828 1.943
B 6 08:39:10 8.423 22.91 48.77 16.34 3.572
B 7 08:39:19 12.58 14.90 18.34 18.26 4.125
I would like to read the entire datasheet and extract the values for 'QUAD' and 'LAI' only. For example, for the data above I would only be extracting a QUAD of 1161 and an LAI of 2.80.
In the past the datasheets were formatted as long data, and I was able to use the following code:
library(stringr)
QUAD <- as.numeric(str_trim(str_extract(data, "(?m)(?<=^QUAD).*$")))
LAI <- as.numeric(str_trim(str_extract(data, "(?m)(?<=^LAI).*$")))
data_extract <- data.frame(
QUAD = QUAD[!is.na(QUAD)],
LAI = LAI[!is.na(LAI)]
)
data_extract
Unfortunately, this does not work because of the wide formatting in the current datasheet. Any help would be hugely appreciated. Thanks in advance for your time.
I tried to fit a simple GARCH model for following data set(which contains weekly prices of a agricultural commodity) using fGarch package. But, after every other variant of model, r gives following error message, implying the function is not running correctly.
"Warning message:
Using formula(x) is deprecated when x is a character vector of length > 1.
Consider formula(paste(x, collapse = " ")) instead."
I do not know how to correct the error and proceed with modelling. Seeking advises to run the model correctly. Thank you very much in advance.
Codes used:
library(fGarch)
garch<-read.csv("crrp.csv",header=T,sep="," )
attach(garch)
head(garch)
tcrrp = ts(garch$crrp, start=c(1997,1),end=c(1998,52), frequency=52)
lcr<-(log(tcrrp))
dlcr<-diff(lcr)
dat<-cbind(dlcr)
car1<-garchFit(dlcr~garch(1, 0), data = dat, trace=FALSE, cond.dist='std')
summary(car1)
"Warning message:
Using formula(x) is deprecated when x is a character vector of length > 1.
Consider formula(paste(x, collapse = " ")) instead"
Data
crrp
35.57
33.89
33.65
32.48
32.5
32.59
34.01
34.35
35.32
35
35
36.5
34.29
33.09
43.59
42.44
43.1
40.38
45.28
47.49
53.57
59.96
60.15
60.16
61.53
57.24
52.24
49.68
47.73
40.95
36
33.67
32.82
32
32
32
31.9
31.67
31.14
31.73
31.87
32.44
33.49
37.5
40.51
45.76
51.16
59.33
67.27
75.72
76.05
84.19
89.33
87.1
88.25
84.86
91.14
90.72
72.84
59.18
59.9
62.2
54.05
47.02
43.86
42.18
44.1
45.67
42.49
43.36
46.93
44.56
66.11
66.76
64.62
65.9
69.86
68.58
63.72
56.46
54.2
56.62
51.3
50.3
42.88
40.14
43.37
38.27
36.29
34.26
33.2
34.1
34.11
34.9
35.93
34.93
33.8
34.1
34.95
35.02
34.64
34.16
38.49
48.13
I had the same question with you,and I solved it by I run the following code at the same time instead of run them separately(taking an example as your code).
car1 <- garchFit(dlcr~garch(1, 0), data = dat, trace=FALSE, cond.dist='std')
summary(car1)
I am generating scatterplots with some acoustics data. I am finding the way the data is mapped in ggplot I am unable to reorder the legend in the traditional way with renaming the levels.
Here is the toy example for you:
tickpointer$stt
[1] 0.000 0.166 0.324 0.515 0.734 0.909 1.059 1.191 1.319 1.445 1.561 1.683
tickpointer$highhz
[1] 7338 7073 7312 7948 7975 7709 7895 7736 8293 8373 8081 9920
tickpointer$peakhz
[1] 4969 4969 4969 4969 5250 5438 3938 4125 4594 4875 5531 7125
tickpointer$lowhz
[1] 2351 2404 2510 2351 2802 2908 2882 3174 3598 4022 4580 5587
looking like: Highhz,peakhz,lowhz,stt in a dataframe
I plotted each of these in a ggplot:
require(ggplot2)
tickpointer
ggplot(tickpointer,aes(stt))+#fileoff is choosen as the x value to have a standardized starttime
geom_line(aes(y=highhz,col="High"))+
geom_point(aes(y=highhz,col="High"))+
geom_line(aes(y=peakhz,col="Peak"))+
geom_point(aes(y=peakhz,col="Peak"))+
geom_line(aes(y=lowhz,col="Low"))+
geom_point(aes(y=lowhz,col="Low"))
notice the legend is in the order: High, Peak, Low.
I would like it to be: High, Low, Peak.
Any leads or help trying to figure this out would be great.
Cheers
Is there a way to add confidence intervals to a qqplot?
I have a dataset of gene expression values, which I've visualized using PCA:
pca1 = prcomp(data, scale. = TRUE)
I'm now looking for outliers by checking the distribution of the data against the normal distribution through:
qqnorm(pca1$x,pch = 20, col = c(rep("red", 73), rep("blue", 33)))
qqline(pca1$x)
This is my data:
data = [2.48 104 4.25 219 0.682 0.302 1.09 0.586 90.7 344 13.8 1.17 305 2.8 79.7 3.18 109 0.932 562 0.958 1.87 0.59 114 391 13.5 1.41 208 2.37 166 3.42]
I would now like to plot 95% confidence intervals to check which data points lie outside. Any tips on how to do this?
The library car provides the function qqPlot(...) which adds a pointwise confidence envelope to the normal qq-plot by default:
library(car)
qqPlot(pca1$x)