Interpolating three columns2019 Community Moderator ElectionHow to sort a dataframe by multiple column(s)?How to drop columns by name in a data frameInterpolate product attributesInterpolate data using plyr in RCreate an empty data.frameStandardize data columns in Rdata.table vs dplyr: can one do something well the other can't or does poorly?Using mutate to interpolate based on subset of columns in dataframeR Linear interpolation between two data setsFilling NA in timeseries data with different interpolation techniques

Are small insurances worth it?

Is a piano played in the same way as a harmonium?

Is it possible to avoid unpacking when merging Association?

Haman going to the second feast dirty

I reported the illegal activity of my boss to his boss. My boss found out. Now I am being punished. What should I do?

Power Strip for Europe

What will happen if my luggage gets delayed?

Specifying a starting column with colortbl package and xcolor

Does a difference of tense count as a difference of meaning in a minimal pair?

What is better: yes / no radio, or simple checkbox?

Does "Until when" sound natural for native speakers?

Why does liquid water form when we exhale on a mirror?

Why restrict private health insurance?

What do *foreign films* mean for an American?

Plausibility of Mushroom Buildings

Why aren't there more Gauls like Obelix?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

What do you call someone who likes to pick fights?

Can I negotiate a patent idea for a raise, under French law?

What ability score modifier does a javelin's damage use?

Virginia employer terminated employee and wants signing bonus returned

Does an unused member variable take up memory?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?



Interpolating three columns



2019 Community Moderator ElectionHow to sort a dataframe by multiple column(s)?How to drop columns by name in a data frameInterpolate product attributesInterpolate data using plyr in RCreate an empty data.frameStandardize data columns in Rdata.table vs dplyr: can one do something well the other can't or does poorly?Using mutate to interpolate based on subset of columns in dataframeR Linear interpolation between two data setsFilling NA in timeseries data with different interpolation techniques










0















I have a set of data in ranges like:



 x|y|z
-4|1|45
-4|2|68
-4|3|96
-2|1|56
-2|2|65
-2|3|89
0|1|45
0|2|56
0|3|75
2|1|23
2|2|56
2|3|75
4|1|42
4|2|65
4|3|78


Here I need to interpolate between x and y using the z value.



I tried interpolating separately for x and y using z value by using the below code:



interpol<-approx(x,z,method="linear")
interpol_1<-approx(y,z,method="linear")


Now I'm trying to use all the three columns but values are coming wrong.










share|improve this question
























  • What error are you getting and what are you expecting?

    – Stedy
    Mar 7 at 5:30











  • I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

    – Sara
    Mar 7 at 7:07















0















I have a set of data in ranges like:



 x|y|z
-4|1|45
-4|2|68
-4|3|96
-2|1|56
-2|2|65
-2|3|89
0|1|45
0|2|56
0|3|75
2|1|23
2|2|56
2|3|75
4|1|42
4|2|65
4|3|78


Here I need to interpolate between x and y using the z value.



I tried interpolating separately for x and y using z value by using the below code:



interpol<-approx(x,z,method="linear")
interpol_1<-approx(y,z,method="linear")


Now I'm trying to use all the three columns but values are coming wrong.










share|improve this question
























  • What error are you getting and what are you expecting?

    – Stedy
    Mar 7 at 5:30











  • I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

    – Sara
    Mar 7 at 7:07













0












0








0








I have a set of data in ranges like:



 x|y|z
-4|1|45
-4|2|68
-4|3|96
-2|1|56
-2|2|65
-2|3|89
0|1|45
0|2|56
0|3|75
2|1|23
2|2|56
2|3|75
4|1|42
4|2|65
4|3|78


Here I need to interpolate between x and y using the z value.



I tried interpolating separately for x and y using z value by using the below code:



interpol<-approx(x,z,method="linear")
interpol_1<-approx(y,z,method="linear")


Now I'm trying to use all the three columns but values are coming wrong.










share|improve this question
















I have a set of data in ranges like:



 x|y|z
-4|1|45
-4|2|68
-4|3|96
-2|1|56
-2|2|65
-2|3|89
0|1|45
0|2|56
0|3|75
2|1|23
2|2|56
2|3|75
4|1|42
4|2|65
4|3|78


Here I need to interpolate between x and y using the z value.



I tried interpolating separately for x and y using z value by using the below code:



interpol<-approx(x,z,method="linear")
interpol_1<-approx(y,z,method="linear")


Now I'm trying to use all the three columns but values are coming wrong.







r






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 5:27









d.b

19.3k41848




19.3k41848










asked Mar 7 at 5:19









SaraSara

4818




4818












  • What error are you getting and what are you expecting?

    – Stedy
    Mar 7 at 5:30











  • I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

    – Sara
    Mar 7 at 7:07

















  • What error are you getting and what are you expecting?

    – Stedy
    Mar 7 at 5:30











  • I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

    – Sara
    Mar 7 at 7:07
















What error are you getting and what are you expecting?

– Stedy
Mar 7 at 5:30





What error are you getting and what are you expecting?

– Stedy
Mar 7 at 5:30













I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

– Sara
Mar 7 at 7:07





I need to interpolate x,y and z. say there is a missing value for x,y,z for 1st and 2nd row. We need to find this intermediate missing value for x,y,z column.

– Sara
Mar 7 at 7:07












1 Answer
1






active

oldest

votes


















1














In your script you forgot to direct to your data.frame. Note the use of $ in the approx function.



interpol <- approx(df$x,df$z,method="linear")
interpol_1 <- approx(df$y,df$z,method="linear")


Data:



df <- data.frame(
x = c(-4, -4, -4, -2, -2, -2, 0, 0, 0, 2, 2, 2, 4, 4, 4),
y = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3),
z = c(45, 68, 96, 56, 65, 89, 45, 56, 75, 23, 56, 75, 42, 65, 78)
)





share|improve this answer























  • Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

    – Sara
    Mar 7 at 7:17







  • 1





    Are you looking to interpolate from 3 columns? I don't think approx supports that.

    – DJV
    Mar 7 at 8:49











  • yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

    – Sara
    Mar 7 at 9:00











  • yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

    – Sara
    Mar 7 at 9:04










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036567%2finterpolating-three-columns%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














In your script you forgot to direct to your data.frame. Note the use of $ in the approx function.



interpol <- approx(df$x,df$z,method="linear")
interpol_1 <- approx(df$y,df$z,method="linear")


Data:



df <- data.frame(
x = c(-4, -4, -4, -2, -2, -2, 0, 0, 0, 2, 2, 2, 4, 4, 4),
y = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3),
z = c(45, 68, 96, 56, 65, 89, 45, 56, 75, 23, 56, 75, 42, 65, 78)
)





share|improve this answer























  • Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

    – Sara
    Mar 7 at 7:17







  • 1





    Are you looking to interpolate from 3 columns? I don't think approx supports that.

    – DJV
    Mar 7 at 8:49











  • yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

    – Sara
    Mar 7 at 9:00











  • yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

    – Sara
    Mar 7 at 9:04















1














In your script you forgot to direct to your data.frame. Note the use of $ in the approx function.



interpol <- approx(df$x,df$z,method="linear")
interpol_1 <- approx(df$y,df$z,method="linear")


Data:



df <- data.frame(
x = c(-4, -4, -4, -2, -2, -2, 0, 0, 0, 2, 2, 2, 4, 4, 4),
y = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3),
z = c(45, 68, 96, 56, 65, 89, 45, 56, 75, 23, 56, 75, 42, 65, 78)
)





share|improve this answer























  • Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

    – Sara
    Mar 7 at 7:17







  • 1





    Are you looking to interpolate from 3 columns? I don't think approx supports that.

    – DJV
    Mar 7 at 8:49











  • yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

    – Sara
    Mar 7 at 9:00











  • yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

    – Sara
    Mar 7 at 9:04













1












1








1







In your script you forgot to direct to your data.frame. Note the use of $ in the approx function.



interpol <- approx(df$x,df$z,method="linear")
interpol_1 <- approx(df$y,df$z,method="linear")


Data:



df <- data.frame(
x = c(-4, -4, -4, -2, -2, -2, 0, 0, 0, 2, 2, 2, 4, 4, 4),
y = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3),
z = c(45, 68, 96, 56, 65, 89, 45, 56, 75, 23, 56, 75, 42, 65, 78)
)





share|improve this answer













In your script you forgot to direct to your data.frame. Note the use of $ in the approx function.



interpol <- approx(df$x,df$z,method="linear")
interpol_1 <- approx(df$y,df$z,method="linear")


Data:



df <- data.frame(
x = c(-4, -4, -4, -2, -2, -2, 0, 0, 0, 2, 2, 2, 4, 4, 4),
y = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3),
z = c(45, 68, 96, 56, 65, 89, 45, 56, 75, 23, 56, 75, 42, 65, 78)
)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 7:10









DJVDJV

1,6131417




1,6131417












  • Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

    – Sara
    Mar 7 at 7:17







  • 1





    Are you looking to interpolate from 3 columns? I don't think approx supports that.

    – DJV
    Mar 7 at 8:49











  • yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

    – Sara
    Mar 7 at 9:00











  • yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

    – Sara
    Mar 7 at 9:04

















  • Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

    – Sara
    Mar 7 at 7:17







  • 1





    Are you looking to interpolate from 3 columns? I don't think approx supports that.

    – DJV
    Mar 7 at 8:49











  • yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

    – Sara
    Mar 7 at 9:00











  • yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

    – Sara
    Mar 7 at 9:04
















Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

– Sara
Mar 7 at 7:17






Thanks for you suggestion. I tried using dataframe. I looking for code like: interpol <- approx(df$x,df$y,df$z,method="linear") Is there any possiblity to include three columns?

– Sara
Mar 7 at 7:17





1




1





Are you looking to interpolate from 3 columns? I don't think approx supports that.

– DJV
Mar 7 at 8:49





Are you looking to interpolate from 3 columns? I don't think approx supports that.

– DJV
Mar 7 at 8:49













yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

– Sara
Mar 7 at 9:00





yes exactly... then can u suggest me which function supports to interpolate three columns?? @DJV

– Sara
Mar 7 at 9:00













yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

– Sara
Mar 7 at 9:04





yes exactly.. can u please suggest me which function works out to interpolate three columns in R?

– Sara
Mar 7 at 9:04



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036567%2finterpolating-three-columns%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page